Пример #1
0
 /**
  * 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));
 }
Пример #2
0
 /**
  * Returns this user as a GenericUser
  *
  * @return UserLike
  * @throws OasysException
  * @throws \InvalidArgumentException
  */
 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');
     $_nameGoogle = Option::get($_profile, 'name');
     $_name = array('formatted' => Option::get($_profile, 'displayName'), 'familyName' => Option::get($_nameGoogle, 'familyName'), 'givenName' => Option::get($_nameGoogle, 'givenName'));
     $_email = null;
     // Get the account email. Google returns a list of emails.
     foreach (Option::get($_profile, 'emails') as $_emailIteration) {
         if (Option::get($_emailIteration, 'type') == 'account') {
             $_email = Option::get($_emailResult, 'value');
             break;
             // ugly, but works
         }
     }
     return new GenericUser(array('user_id' => $_profileId, 'name' => $_name, 'gender' => Option::get($_profile, 'gender'), 'email_address' => $_email, 'urls' => array(Option::get($_profile, 'url')), 'thumbnail_url' => Option::getDeep($_profile, 'image', 'url'), 'user_data' => $_profile));
 }
Пример #3
0
 /**
  * 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));
 }