Exemplo n.º 1
0
 /** @return $this */
 public function addParticipation(BaseEventParticipation $participation)
 {
     if (!$participation instanceof EventParticipation) {
         throw new InvalidArgumentException('Only a Google EventParticipation may be added as an attendee to a Google Event');
     }
     return parent::addParticipation($participation);
 }
Exemplo n.º 2
0
 /** {@inheritDoc} */
 public function persist(AbstractEvent $event, array $options = [])
 {
     if (!$event instanceof Event) {
         throw new InvalidArgumentException('Wrong event provided, expected an office event');
     }
     $params = ['headers' => ['Content-Type' => 'application/json'], 'body' => json_encode($event->export())];
     $method = 'POST';
     $url = sprintf('calendars/%s/events', $event->getCalendar()->getId());
     if (null !== $event->getId()) {
         $method = 'PATCH';
         $url = sprintf('%s/%s', $url, $event->getId());
     }
     $request = $this->guzzle->createRequest($method, $url, $params);
     $response = $this->guzzle->send($request);
     $this->handleResponse($response);
     return Event::hydrate($response->json());
 }