/** * The customerCreate method prepares data for Stripe_Customer::create and attempts to * create a customer. * * @param array $data The data passed directly to Stripe's API. * @return array $customer if success, string $error if failure. */ public function updateEvent($data) { $client = new Google_Client(); $client->setApplicationName("Plat"); $key = file_get_contents($this->googleApiKeyFile); // separate additional scopes with a comma $scopes = "https://www.googleapis.com/auth/calendar"; //$client->setScopes(array($scopes)); $cred = new Google_Auth_AssertionCredentials($this->googleEmailAddress, array($scopes), $key); $client->setAssertionCredentials($cred); if ($client->getAuth()->isAccessTokenExpired()) { $client->getAuth()->refreshTokenWithAssertion($cred); } $service = new Google_Service_Calendar($client); $event = new Google_Service_Calendar_Event(); //$event->setId($data['eventId']); $event->setSummary($data['eventSummary']); $event->setDescription($data['eventDescription']); $event->setLocation($data['eventLocation']); $start = new Google_Service_Calendar_EventDateTime(); $start->setDateTime($data['eventStartDate']); $start->setTimeZone($data['eventTimeZone']); $event->setStart($start); $end = new Google_Service_Calendar_EventDateTime(); $end->setDateTime($data['eventEndDate']); $end->setTimeZone($data['eventTimeZone']); $event->setEnd($end); $attendee1 = new Google_Service_Calendar_EventAttendee(); $attendee1->setEmail(Configure::read("ADMIN_ORDER_EVENT_EMAIL")); $attendees = array($attendee1); $event->attendees = $attendees; $event->setSequence(Configure::read("GOOGLE_CALENDAR_API_SEQUENCE")); $calendar_id = Configure::read("GOOGLE_CALENDAR_ID"); try { $updateEvent = $service->events->update($calendar_id, $data['eventId'], $event); // $new_event_status = $updateEvent->getStatus(); return $new_event_status; } catch (Google_Service_Exception $e) { syslog(LOG_ERR, $e->getMessage()); return $e->getMessage(); } }