public function refresh(Application_Model_Api_Google_AccessToken $accessToken) { $client = MedOptima_Service_Google_Config::getCalendarClient(); $client->setAccessToken($accessToken->jsonSerialize()); $client->refreshToken($accessToken->getRefreshToken()); return (new MedOptima_Service_Google_AccessToken_Initializer())->updateFromEncodedData($accessToken, $client->getAccessToken()); }
public function __construct(Application_Model_Medical_Doctor $doctor) { parent::__construct('', '', ''); $this->_doctor = $doctor; $this->_accessToken = Application_Model_Api_Google_AccessToken::getByDoctor($this->_doctor); if (!$this->_accessToken) { $this->_client = MedOptima_Service_Google_Config::getCalendarClient($this->_doctor->getId()); } }
public function __construct(Doctor $doctor) { $token = AccessToken::getByDoctor($doctor); if ($token instanceof AccessToken && !$token->isExpired()) { $client = MedOptima_Service_Google_Config::getCalendarClient(); $client->setAccessToken($token->jsonSerialize()); $this->_cal = new Google_CalendarService($client); } return $this; }
public function linkDoctorAccount(Doctor $doctor) { $token = AccessToken::getByDoctor($doctor); if (!$token instanceof AccessToken) { $token = AccessToken::create(); $token->setDoctor($doctor); } $client = MedOptima_Service_Google_Config::getCalendarClient(); if ($this->_request->getParam('code')) { $client->authenticate($this->_request->getParam('code')); (new MedOptima_Service_Google_AccessToken_Initializer())->updateFromEncodedData($token, $client->getAccessToken()); } $token->save(); return true; }