/**
  * Factory method to create a new OpenstackClient
  *
  * @static
  *
  * @param array|Collection $config Configuration data. Array keys:
  *                                 auth_url - Authentication service URL
  *                                 username - API username
  *                                 password - API password
  *                                 tenantName - API tenantName
  *
  * @return \Guzzle\Common\FromConfigInterface|OpenstackClient|\Guzzle\Service\Client
  */
 public static function factory($config = array())
 {
     $default = array('compute_type' => 'compute', 'identity_type' => 'identity', 'storage_type' => 'storage', 'region' => 'RegionOne');
     $required = array('auth_url');
     $config = Inspector::prepareConfig($config, $default, $required);
     $client = new self($config->get('auth_url'), $config->get('username'), $config->get('password'), $config->get('tenantName'));
     $client->setConfig($config);
     return $client;
 }
 /**
  * Factory method to create a new ComputeClient
  *
  * @static
  *
  *
  * @param array|Collection $config Configuration data. Array keys:
  *                                 base_url - Base URL of web service
  *                                 token - Authentication token
  *                                 tenant_id Tenant id
  *
  * @return \Guzzle\Common\FromConfigInterface|ComputeClient|\Guzzle\Service\Client
  */
 public static function factory($config = array())
 {
     $default = array();
     $required = array('base_url', 'token', 'tenant_id');
     $config = Inspector::prepareConfig($config, $default, $required);
     $client = new self($config->get('base_url'), $config->get('token'), $config->get('tenant_id'));
     $client->setConfig($config);
     $client->getEventDispatcher()->addSubscriber(new AuthenticationObserver());
     return $client;
 }
 /**
  * @covers Guzzle\Service\Inspector::prepareConfig
  */
 public function testPreparesConfig()
 {
     $c = Inspector::prepareConfig(array('a' => '123', 'base_url' => 'http://www.test.com/'), array('a' => 'xyz', 'b' => 'lol'), array('a'));
     $this->assertInstanceOf('Guzzle\\Common\\Collection', $c);
     $this->assertEquals(array('a' => '123', 'b' => 'lol', 'base_url' => 'http://www.test.com/'), $c->getAll());
     try {
         $c = Inspector::prepareConfig(null, null, array('a'));
         $this->fail('Exception not throw when missing config');
     } catch (ValidationException $e) {
     }
 }
 /**
  * Create an instance of the client
  * 
  * @param array $config
  * 
  * @return \GuzzleAmazonWebservices\ProductAdvertising
  */
 public static function factory($config = array())
 {
     $defaults = array('base_url' => '{{scheme}}://{{locale}}/onca/xml', 'scheme' => 'http', 'locale' => self::LOCALE_US, 'version' => self::VERSION);
     $required = array('access_key', 'secret_key', 'associate_tag');
     $config = Inspector::prepareConfig($config, $defaults, $required);
     $signature = new SignatureV2($config->get('access_key'), $config->get('secret_key'));
     $client = new self($config->get('base_url'), $config->get('access_key'), $config->get('secret_key'), $config->get('associate_tag'), $config->get('version'));
     $client->setConfig($config);
     $client->addSubscriber(new SignaturePlugin($signature, $config->get('version')));
     return $client;
 }
Exemplo n.º 5
0
 public static function factory($config = array())
 {
     $default = array('base_url' => '{scheme}://blockchain.info/merchant/{guid}', 'scheme' => 'https');
     $required = array('base_url', 'guid', 'password');
     $config = Inspector::prepareConfig($config, $default, $required);
     $client = new self($config->get('base_url'), $config->get('guid'), $config->get('password'));
     $client->setConfig($config);
     // Uncomment the following two lines to use an XML service description
     $client->setDescription(ServiceDescription::factory(__DIR__ . '/' . 'client.xml'));
     return $client;
 }
Exemplo n.º 6
0
 public static function factory($config = array())
 {
     $default = array('base_url' => '{scheme}://mtgox.com/', 'scheme' => 'https');
     $required = array('base_url', 'api_key', 'api_secret');
     $config = Inspector::prepareConfig($config, $default, $required);
     $client = new self($config->get('base_url'), $config->get('api_key'), $config->get('api_secret'));
     $client->setConfig($config);
     // Uncomment the following two lines to use an XML service description
     $client->setDescription(ServiceDescription::factory(__DIR__ . '/' . 'client.xml'));
     return $client;
 }
Exemplo n.º 7
0
 /**
  * Factory method to create a new SmsBoxClient
  *
  * @param array|Collection $config Configuration data. Array keys:
  *
  *    base_url - Base URL of the smsBox service endpoint
  *    username - API username
  *    password - API password
  *
  * @return SmsBoxClient
  */
 static function factory($config = array())
 {
     $default = array('test' => false);
     $required = array('base_url', 'username', 'password');
     $config = Inspector::prepareConfig($config, $default, $required);
     $client = new self($config->get('base_url'), $config->get('username'), $config->get('password'), $config->get('test'));
     $client->setConfig($config);
     // Add the XML service description to the client
     $description = ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'guzzle_smsbox.xml');
     $client->setDescription($description);
     return $client;
 }
Exemplo n.º 8
0
 /**
  * Factory method to create a new mock client
  *
  * @param array|Collection $config Configuration data. Array keys:
  *    base_url - Base URL of web service
  *    api_version - API version
  *    scheme - URI scheme: http or https
  *  * username - API username
  *  * password - API password
  *  * subdomain - Unfuddle account subdomain
  *
  * @return MockClient
  */
 public static function factory($config = array())
 {
     $config = Inspector::prepareConfig($config, array('base_url' => '{{scheme}}://127.0.0.1:8124/{{api_version}}/{{subdomain}}', 'scheme' => 'http', 'api_version' => 'v1'), array('username', 'password', 'subdomain'));
     return new self($config->get('base_url'), $config);
 }
Exemplo n.º 9
0
 /**
  * Create a new OAuth 1.0 plugin
  *
  * @param array $config Configuration array containing these parameters:
  *     - string 'consumer_key'         Consumer key
  *     - string 'consumer_secret'      Consumer secret
  *     - string 'token'                Token
  *     - string 'token_secret'         Token secret
  *     - string 'version'              OAuth version.  Defaults to 1.0
  *     - string 'signature_method'     Custom signature method
  *     - bool   'disable_post_params'  Set to true to prevent POST parameters from being signed
  *     - array|Closure 'signature_callback' Custom signature callback that accepts a string to sign and a signing key
  */
 public function __construct($config)
 {
     $this->config = Inspector::prepareConfig($config, array('version' => '1.0', 'consumer_key' => 'anonymous', 'consumer_secret' => 'anonymous', 'signature_method' => 'HMAC-SHA1', 'signature_callback' => function ($stringToSign, $key) {
         return hash_hmac('sha1', $stringToSign, $key, true);
     }), array('signature_method', 'signature_callback', 'version', 'consumer_key', 'consumer_secret'));
 }