private function handleClient($value, array &$args)
 {
     if (!$value instanceof ClientInterface) {
         throw new InvalidArgumentException('client must be an instance of GuzzleHttp\\ClientInterface, ' . get_class($value) . ' passed');
     }
     if (isset($args['defaults']) && is_array($args)) {
         foreach ($args['defaults'] as $defaultName => $defaultValue) {
             $args['client']->setDefaultOption($defaultName, $defaultValue);
         }
     }
     // Make sure the user agent is prefixed by the SDK version
     $args['client']->setDefaultOption('headers/User-Agent', 'sellercenter-sdk-php/' . Sdk::VERSION . ' ' . Utils::getDefaultUserAgent());
 }
Beispiel #2
0
 public function testProvidesDefaultUserAgent()
 {
     $ua = Utils::getDefaultUserAgent();
     $this->assertEquals(1, preg_match('#^Guzzle/.+ curl/.+ PHP/.+$#', $ua));
 }
Beispiel #3
0
 /**
  * @deprecated Use GuzzleHttp\Utils::getDefaultUserAgent
  */
 public static function getDefaultUserAgent()
 {
     return Utils::getDefaultUserAgent();
 }
Beispiel #4
0
 public function testAddsDefaultUserAgentHeaderWithoutDefaultOptions()
 {
     $client = new Client();
     $this->assertEquals(['User-Agent' => Utils::getDefaultUserAgent()], $client->getDefaultOption('headers'));
 }