protected function buildConnector($provider, array $params)
 {
     if ($this->connection === 'sandbox') {
         $connectorClass = ucfirst(strtolower($provider)) . 'MockConnector';
         $reflectionClass = new \ReflectionClass("RAM\\Connectors\\Mock\\{$connectorClass}");
     } else {
         if ($this->connection === 'live') {
             $connectorClass = ucfirst(strtolower($provider)) . 'Connector';
             $reflectionClass = new \ReflectionClass("RAM\\Connectors\\{$connectorClass}");
         } else {
             throw new \RuntimeException("No valid connection type was found. Valid types are 'sandbox' or 'live'");
         }
     }
     require_once $reflectionClass->getFileName();
     $connector = $reflectionClass->newInstance($this->client, $this->proxy);
     if ($this->connection === 'live') {
         $connection = new Connection();
         if ($connector instanceof Oauth1Connector) {
             $connector->key = $params['api_key'];
             $connector->secret = $params['api_secret'];
             $connection->setIdentifier($params['access_token']);
             $connection->setSecret($params['access_token_secret']);
         } else {
             $connection->setAccessToken($params['access_token']);
         }
         $connector->buildToken($connection);
     } else {
         if (!isset($this->responses[$provider])) {
             throw new \RuntimeException("You requested sandbox environment for '{$provider}', but you haven't defined any responses in app/config/responses.yml");
         }
         $connector->setResponses($this->responses[$provider]);
     }
     return $connector;
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function buildToken(Connection $connection)
 {
     $token = new TokenCredentials();
     $token->setSecret($connection->getSecret());
     $token->setIdentifier($connection->getIdentifier());
     $this->setToken($token);
     $this->setupProvider();
 }
Exemple #3
0
 public function testCreate()
 {
     $connection = new Connection();
     $connection->setAccessToken(self::ACCESS_TOKEN);
     $connection->setIdentifier(self::IDENTIFIER);
     $connection->setExpires(self::EXPIRES);
     $connection->setRefreshToken(self::REFRESH_TOKEN);
     $connection->setSecret(self::SECRET);
     $connection->setUid(self::UID);
     $this->assertEquals(self::ACCESS_TOKEN, $connection->getAccessToken());
     $this->assertEquals(self::IDENTIFIER, $connection->getIdentifier());
     $this->assertEquals(self::EXPIRES, $connection->getExpires());
     $this->assertEquals(self::REFRESH_TOKEN, $connection->getRefreshToken());
     $this->assertEquals(self::SECRET, $connection->getSecret());
     $this->assertEquals(self::UID, $connection->getUid());
 }
Exemple #4
0
 /**
  * {@inheritdoc}
  */
 public function buildToken(Connection $connection)
 {
     $token = new AccessToken(['access_token' => $connection->getAccessToken(), 'refresh_token' => $connection->getRefreshToken(), 'expires' => $connection->getExpires()]);
     $this->setToken($token);
 }
 /**
  * Build connector token, based on subscription's connection
  *
  * @param Connection $connection
  */
 public function buildToken(Connection $connection)
 {
     $this->clientId = $connection->getAccessToken();
 }