Exemplo n.º 1
0
 /**
  * @param array $options
  * @throws BasicAuthException
  */
 public function __construct($options = array())
 {
     if (!is_array($options)) {
         throw new BasicAuthException('Adapter parameters must be in an array', Exception::PARAMETER_NOT_SPECIFIED);
     }
     foreach (array('username', 'password') as $reqParam) {
         if (!isset($options[$reqParam])) {
             throw new BasicAuthException('Parameter "' . $reqParam . '" is required', Exception::PARAMETER_NOT_SPECIFIED);
         }
     }
     $this->username = $options['username'];
     $this->password = $options['password'];
     parent::__construct($options);
 }
Exemplo n.º 2
0
 /**
  * @param array $options
  *
  * Example:
  * {
  *      entrypoint:     'http://shop.com',
  *      client_id:      'xxxxx',
  *      client_secret:  'xxxxx',
  *      auth_code:      'xxxxx',
  *      refresh_token:  'xxxxx',
  *      access_token:   'xxxxx'
  * }
  * @throws Exception
  * @throws OAuthException
  */
 public function __construct($options = array())
 {
     if (!is_array($options)) {
         throw new OAuthException('Adapter parameters must be an array', Exception::PARAMETER_NOT_SPECIFIED);
     }
     foreach (array('client_id', 'client_secret') as $reqParam) {
         if (!isset($options[$reqParam])) {
             throw new OAuthException('Parameter "' . $reqParam . '" is required', Exception::PARAMETER_NOT_SPECIFIED);
         }
     }
     $this->clientId = $options['client_id'];
     $this->clientSecret = $options['client_secret'];
     if (isset($options['auth_code'])) {
         $this->authCode = $options['auth_code'];
     }
     if (isset($options['access_token'])) {
         $this->accessToken = $options['access_token'];
     }
     if (isset($options['refresh_token'])) {
         $this->refreshToken = $options['refresh_token'];
     }
     parent::__construct($options);
 }