/** * Returns this user as a GenericUser * * @param \stdClass|array $profile * * @throws \DreamFactory\Oasys\Exceptions\ProviderException * @throws \InvalidArgumentException * @return UserLike */ public function getUserData($profile = null) { $_result = parent::getUserData(); if (empty($_result)) { throw new \InvalidArgumentException('No profile available to convert.'); } if (null === ($_profile = Option::get($_result, 'result'))) { throw new ProviderException('No profile available to convert.'); } // Log::debug( 'Profile retrieved: ' . print_r( $_profile, true ) ); $_profileId = Option::get($_profile, 'id'); $_login = Option::get($_profile, 'login'); $_formatted = Option::get($_profile, 'name', $_login); $_parts = explode(' ', $_formatted); $_name = array('formatted' => $_formatted); if (!empty($_parts)) { if (sizeof($_parts) >= 1) { $_name['givenName'] = $_parts[0]; } if (sizeof($_parts) > 1) { $_name['familyName'] = $_parts[1]; } } return new GenericUser(array('provider_id' => $this->getProviderId(), 'user_id' => $_profileId, 'published' => Option::get($_profile, 'created_at'), 'display_name' => $_formatted, 'name' => $_name, 'email_address' => Option::get($_profile, 'email'), 'preferred_username' => $_login, 'urls' => array(Option::get($_profile, 'url')), 'thumbnail_url' => Option::get($_profile, 'avatar_url'), 'updated' => Option::get($_profile, 'updated_at'), 'relationships' => Option::get($_profile, 'followers'), 'user_data' => $_profile)); }
/** * Clear out the last errors and stuff from last request * * @return void */ protected function _resetRequest() { parent::_resetRequest(); $this->_queryDone = $this->_totalSize = $this->_nextRecordsUrl = null; }
/** * Google Plus does not allow the state parameter when making access tokens requests, so it is removed from the * payload. * * @param string $grantType * @param array $payload * * @return array|false * @throws \InvalidArgumentException */ public function requestAccessToken($grantType = GrantTypes::AUTHORIZATION_CODE, array $payload = array()) { Option::remove($payload, 'state'); return parent::requestAccessToken($grantType, $payload); }
/** * Returns this user as a GenericUser * * * @throws \DreamFactory\Oasys\Exceptions\OasysException * @throws \InvalidArgumentException * @return UserLike */ public function getUserData() { $_response = parent::getUserData(); if (HttpResponse::Ok != ($_code = Option::get($_response, 'code', Curl::getLastHttpCode()))) { throw new OasysException('Unexpected response code', $_code, null, $_response); } $_profile = Option::get($_response, 'result'); if (empty($_profile)) { throw new \InvalidArgumentException('No profile available to convert.'); } $_profileId = Option::get($_profile, 'id'); $_name = array('formatted' => Option::get($_profile, 'name'), 'familyName' => Option::get($_profile, 'last_name'), 'givenName' => Option::get($_profile, 'first_name')); return new GenericUser(array('user_id' => $_profileId, 'published' => Option::get($_profile, 'updated_time'), 'updated' => Option::get($_profile, 'updated_time'), 'display_name' => $_name['formatted'], 'name' => $_name, 'preferred_username' => Option::get($_profile, 'username'), 'gender' => Option::get($_profile, 'gender'), 'email_address' => Option::get($_profile, 'email'), 'urls' => array(Option::get($_profile, 'link')), 'relationships' => Option::get($_profile, 'friends'), 'thumbnail_url' => $this->_config->getEndpointUrl() . '/' . $_profileId . '/picture?width=150&height=150', 'user_data' => $_profile)); }