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 unlinkDoctorAccount(Doctor $doctor) { $token = AccessToken::getByDoctor($doctor); if ($token instanceof AccessToken) { $token->remove(); } }
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; }
$debug = false; if (isset($argv[2]) && $argv[2] == 'debug') { $debug = true; } try { $opts = new Zend_Console_Getopt(array('help' => 'Displays usage information', 'refresh_tokens' => 'Refresh doctor\'s access tokens', 'sync_events' => 'Sync reservations', 'add_pages' => 'Add pages to admin panel', 'clinic_text_block' => 'Add index text block', 'remove_clinic_text_block' => 'Remove old clinic blocks', 'create_advice_galleries' => 'Create advice empty galleries', 'second_phone' => '')); $opts->parse(); } catch (Zend_Console_Getopt_Exception $e) { exit($e->getMessage() . "\n\n" . $e->getUsageMessage()); } if (isset($opts->help)) { echo $opts->getUsageMessage(); exit; } if (isset($opts->refresh_tokens)) { $tokens = AccessToken::getList(); foreach ($tokens as $token) { /** @var AccessToken $token */ if ($token->isAlmostExpired()) { if ($debug) { echo 'Token before:' . PHP_EOL; print_r($token->toArray()); } $token->refresh(); if ($debug) { echo 'Token after:' . PHP_EOL; print_r($token->toArray()); } } } exit;