当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::setDescription方法代码示例

本文整理汇总了PHP中Guzzle\Service\Client::setDescription方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::setDescription方法的具体用法?PHP Client::setDescription怎么用?PHP Client::setDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Guzzle\Service\Client的用法示例。


在下文中一共展示了Client::setDescription方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor
  *
  * @param string $accessToken
  */
 public function __construct($accessToken)
 {
     $this->accessToken = $accessToken;
     $this->client = new Client();
     $this->client->setDescription(ServiceDescription::factory(__DIR__ . '/Resources/config/service.json'));
     $this->client->getEventDispatcher()->addListener('client.create_request', [$this, 'onClientCreateRequest']);
     $this->client->getEventDispatcher()->addListener('request.error', [$this, 'onRequestError']);
 }
开发者ID:cocoiti,项目名称:qiita-php,代码行数:13,代码来源:Qiita.php

示例2: __construct

 /**
  * Initializes initializer
  *
  * @param Client $client
  * @param array  $parameters
  */
 public function __construct(Client $client, array $parameters)
 {
     $this->client = $client;
     $this->parameters = $parameters;
     if (!empty($parameters['service_descriptions'])) {
         $this->client->setDescription(ServiceDescription::factory($parameters['service_descriptions']));
     }
 }
开发者ID:teaandcode,项目名称:behat-guzzle-extension,代码行数:14,代码来源:GuzzleAwareInitializer.php

示例3: __construct

 public function __construct($request_options)
 {
     $description = ServiceDescription::factory(__DIR__ . "/../../clients/index.json");
     $this->client = new Client($request_options['base_url']);
     $this->client->setDescription($description);
     $this->client->setConfig($request_options);
     $tokenPlugin = new \Gitlab\Auth\Token\Plugin($this, $request_options);
     $urlEncoder = new \Gitlab\Core\Plugin\UrlEncoder();
     $this->client->addSubscriber($tokenPlugin);
     $this->client->addSubscriber($urlEncoder);
 }
开发者ID:dw250100785,项目名称:gitlab-api,代码行数:11,代码来源:Api.php

示例4: getClient

 protected function getClient()
 {
     $service = ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'TestData' . DIRECTORY_SEPARATOR . 'test_service.xml');
     $client = new Client('http://www.google.com/');
     $client->setDescription($service);
     return $client;
 }
开发者ID:MicroSDHC,项目名称:justinribeiro.com-examples,代码行数:7,代码来源:AbstractCommandTest.php

示例5: testClientConstruct

 /**
  * @return Client
  */
 public function testClientConstruct()
 {
     // Define a service with a test() method
     $service = new ServiceDescription(array('name' => 'test-service', 'operations' => array('test' => array('uri' => '/test.json', 'httpMethod' => 'GET', 'responseClass' => 'TestModel', 'class' => '\\Loco\\Utils\\Swizzle\\Command\\StrictCommand'), 'testlist' => array('uri' => '/testlist.json', 'httpMethod' => 'GET', 'responseClass' => 'array', 'class' => '\\Loco\\Utils\\Swizzle\\Command\\StrictCommand', 'items' => array('$ref' => 'TestModel')), 'testwrap' => array('uri' => '/testwrap.json', 'httpMethod' => 'GET', 'responseClass' => 'TestModelList', 'class' => '\\Loco\\Utils\\Swizzle\\Command\\StrictCommand'), 'testwrapobj' => array('uri' => '/testwrapobj.json', 'httpMethod' => 'GET', 'responseClass' => 'TestModelListObject', 'class' => '\\Loco\\Utils\\Swizzle\\Command\\StrictCommand')), 'models' => array('TestModel' => array('type' => 'object', 'additionalProperties' => false, 'properties' => array('foo' => array('type' => 'integer', 'location' => 'json', 'required' => true), 'bar' => array('type' => 'integer', 'location' => 'json', 'required' => false))), 'TestModelList' => array('type' => 'array', 'items' => array('$ref' => 'TestModel')), 'TestModelListObject' => array('type' => 'object', 'additionalProperties' => false, 'properties' => array('list' => array('type' => 'array', 'location' => 'json', 'items' => array('$ref' => 'TestModel')))))));
     $client = new Client();
     $client->setDescription($service);
     // test models are defined ok
     $op = $service->getOperation('test');
     $this->assertEquals('model', $op->getResponseType());
     $this->assertEquals('TestModel', $op->getResponseClass());
     // listing is just an array
     $op = $service->getOperation('testlist');
     $this->assertEquals('primitive', $op->getResponseType());
     $this->assertEquals('array', $op->getResponseClass());
     // test listing is aware of models in itself
     // It's not. Operation has no 'items' property
     // list wrapper is a model
     $op = $service->getOperation('testwrap');
     $this->assertEquals('model', $op->getResponseType());
     $this->assertEquals('TestModelList', $op->getResponseClass());
     // test model resolved from $ref
     $listModel = $service->getModel('TestModelList');
     $this->assertInstanceOf('\\Guzzle\\Service\\Description\\Parameter', $listModel);
     // items should be single schema specifying one allowed model type
     $items = $listModel->getItems();
     $this->assertInstanceOf('\\Guzzle\\Service\\Description\\Parameter', $items);
     $this->assertEquals('object', $items->getType());
     $this->assertArrayHasKey('foo', $items->getProperties());
     return $client;
 }
开发者ID:rodsouto,项目名称:swizzle,代码行数:33,代码来源:ModelTest.php

示例6: getClient

 protected function getClient()
 {
     $description = new ServiceDescription(array('operations' => array('test' => array('httpMethod' => 'PUT', 'parameters' => array('ContentMD5' => array(), 'Body' => array('location' => 'body'))))));
     $client = new Client();
     $client->setDescription($description);
     return $client;
 }
开发者ID:Frinstio,项目名称:AlfredWorkflow.com,代码行数:7,代码来源:CommandContentMd5PluginTest.php

示例7: testClientConstruct

 /**
  * Construct Swagger client for calling the petstore
  * @depends testServiceBuild
  * @return Client
  */
 public function testClientConstruct(ServiceDescription $service)
 {
     $client = new Client();
     $client->setDescription($service);
     $this->assertEquals('http://petstore.swagger.wordnik.com/api', $client->getBaseUrl());
     // @todo add Accept: application/json to every request?
     return $client;
 }
开发者ID:rodsouto,项目名称:swizzle,代码行数:13,代码来源:PetstoreTest.php

示例8: testAllowsForJsonBasedArrayParamsFunctionalTest

 public function testAllowsForJsonBasedArrayParamsFunctionalTest()
 {
     $description = new ServiceDescription(array('operations' => array('test' => new Operation(array('httpMethod' => 'PUT', 'parameters' => array('data' => array('required' => true, 'filters' => 'json_encode', 'location' => 'body')))))));
     $client = new Client();
     $client->setDescription($description);
     $command = $client->getCommand('test', array('data' => array('foo' => 'bar')));
     $request = $command->prepare();
     $this->assertEquals('{"foo":"bar"}', (string) $request->getBody());
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:9,代码来源:ServiceDescriptionTest.php

示例9: testAllowsForJsonBasedArrayParamsFunctionalTest

 public function testAllowsForJsonBasedArrayParamsFunctionalTest()
 {
     $service = array('test' => new ApiCommand(array('method' => 'PUT', 'params' => array('data' => array('required' => true, 'type' => 'type:array', 'filters' => 'json_encode', 'location' => 'body')))));
     $description = new ServiceDescription($service);
     $client = new Client();
     $client->setDescription($description);
     $command = $client->getCommand('test', array('data' => array('foo' => 'bar')));
     $request = $command->prepare();
     $this->assertEquals(json_encode(array('foo' => 'bar')), (string) $request->getBody());
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:10,代码来源:ServiceDescriptionTest.php

示例10: createEchaleGasClient

 public function createEchaleGasClient()
 {
     $client = new Client();
     $client->setDescription(ServiceDescription::factory('config/services/echalegas.json'));
     $logger = new Logger('debug');
     $logger->pushHandler(new StreamHandler('logs/debug.log'));
     $logPlugin = new LogPlugin(new MonologLogAdapter($logger), MessageFormatter::DEBUG_FORMAT);
     $client->addSubscriber($logPlugin);
     return $client;
 }
开发者ID:comphppuebla,项目名称:echale-gas-app,代码行数:10,代码来源:IndexService.php

示例11: getMockedClient

 protected function getMockedClient(Response $response)
 {
     $operation = new Operation(array('httpMethod' => 'GET', 'name' => 'Mock'));
     $service = new ServiceDescription();
     $service->addOperation($operation);
     $plugin = new MockPlugin();
     $plugin->addResponse($response);
     $client = new Client();
     $client->setDescription($service);
     $client->addSubscriber($plugin);
     return $client;
 }
开发者ID:teaandcode,项目名称:behat-guzzle-extension,代码行数:12,代码来源:GuzzleContextSpec.php

示例12: testValidatesAdditionalParameters

 public function testValidatesAdditionalParameters()
 {
     $description = ServiceDescription::factory(array('operations' => array('foo' => array('httpMethod' => 'PUT', 'parameters' => array('bar' => array('location' => 'header')), 'additionalParameters' => array('location' => 'json')))));
     $client = new Client();
     $client->setDescription($description);
     $command = $client->getCommand('foo');
     $command['bar'] = 'test';
     $command['hello'] = 'abc';
     $request = $command->prepare();
     $this->assertEquals('test', (string) $request->getHeader('bar'));
     $this->assertEquals('{"hello":"abc"}', (string) $request->getBody());
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:12,代码来源:DefaultRequestSerializerTest.php

示例13: testVisitsLocationWithMultipleFiles

 public function testVisitsLocationWithMultipleFiles()
 {
     $description = ServiceDescription::factory(array('operations' => array('DoPost' => array('httpMethod' => 'POST', 'parameters' => array('foo' => array('location' => 'postFile', 'type' => array('string', 'array')))))));
     $this->getServer()->flush();
     $this->getServer()->enqueue(array("HTTP/1.1 200 OK\r\nContent-Length:0\r\n\r\n"));
     $client = new Client($this->getServer()->getUrl());
     $client->setDescription($description);
     $command = $client->getCommand('DoPost', array('foo' => array(__FILE__, __FILE__)));
     $command->execute();
     $received = $this->getServer()->getReceivedRequests();
     $this->assertContains('name="foo[0]";', $received[0]);
     $this->assertContains('name="foo[1]";', $received[0]);
 }
开发者ID:rahilmomin,项目名称:ci_bootstrap_3,代码行数:13,代码来源:PostFileVisitorTest.php

示例14: testUsesProcessedModelsWhenEnabled

 public function testUsesProcessedModelsWhenEnabled()
 {
     $d = ServiceDescription::factory(array('operations' => array('foobar' => array('name' => 'foobar', 'httpMethod' => 'PUT', 'responseClass' => 'foo', 'responseType' => 'model', 'class' => 'Aws\\Common\\Command\\JsonCommand', 'parameters' => array('test' => array('location' => 'query')))), 'models' => array('foo' => array('type' => 'object', 'properties' => array('test' => array('type' => 'string', 'location' => 'json', 'filters' => array('strtoupper')))))));
     $response = new Response(200, array('Content-Type' => 'application/json'), '{"test":"bar"}');
     $client = new Client('http://localhost:1245');
     $client->setDescription($d);
     $this->setMockResponse($client, array($response));
     $command = $client->getCommand('foobar');
     $this->assertEquals(array('test' => 'bar'), $command->execute()->toArray());
     $this->setMockResponse($client, array($response));
     $command = $client->getCommand('foobar');
     $command->set('command.model_processing', true);
     $this->assertEquals(array('test' => 'BAR'), $command->execute()->toArray());
 }
开发者ID:romainneutron,项目名称:aws-sdk-php,代码行数:14,代码来源:JsonCommandTest.php

示例15: testSupportsServiceDescriptionBaseUrls

 public function testSupportsServiceDescriptionBaseUrls()
 {
     $description = new ServiceDescription(array('baseUrl' => 'http://foo.com'));
     $client = new Client();
     $client->setDescription($description);
     $this->assertEquals('http://foo.com', $client->getBaseUrl());
 }
开发者ID:creazy412,项目名称:vmware-win10-c65-drupal7,代码行数:7,代码来源:ClientTest.php


注:本文中的Guzzle\Service\Client::setDescription方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。