1 | <?php |
||
13 | class GuzzleClient extends ServiceClient |
||
14 | { |
||
15 | /** @var array $config */ |
||
16 | private $config; |
||
17 | |||
18 | /** @var DescriptionInterface Guzzle service description */ |
||
19 | private $description; |
||
20 | |||
21 | /** |
||
22 | * The client constructor accepts an associative array of configuration |
||
23 | * options: |
||
24 | * |
||
25 | * - defaults: Associative array of default command parameters to add to |
||
26 | * each command created by the client. |
||
27 | * - validate: Specify if command input is validated (defaults to true). |
||
28 | * Changing this setting after the client has been created will have no |
||
29 | * effect. |
||
30 | * - process: Specify if HTTP responses are parsed (defaults to true). |
||
31 | * Changing this setting after the client has been created will have no |
||
32 | * effect. |
||
33 | * - response_locations: Associative array of location types mapping to |
||
34 | * ResponseLocationInterface objects. |
||
35 | * |
||
36 | * @param ClientInterface $client HTTP client to use. |
||
37 | * @param DescriptionInterface $description Guzzle service description |
||
38 | * @param callable $commandToRequestTransformer |
||
39 | * @param callable $responseToResultTransformer |
||
40 | * @param HandlerStack $commandHandlerStack |
||
41 | * @param array $config Configuration options |
||
42 | */ |
||
43 | 19 | public function __construct( |
|
59 | |||
60 | /** |
||
61 | * Returns the command if valid; otherwise an Exception |
||
62 | * @param string $name |
||
63 | * @param array $args |
||
64 | * @return CommandInterface |
||
65 | * @throws \InvalidArgumentException |
||
66 | */ |
||
67 | 16 | public function getCommand($name, array $args = []) |
|
83 | |||
84 | /** |
||
85 | * Return the description |
||
86 | * |
||
87 | * @return DescriptionInterface |
||
88 | */ |
||
89 | 1 | public function getDescription() |
|
93 | |||
94 | /** |
||
95 | * Returns the passed Serializer when set, a new instance otherwise |
||
96 | * |
||
97 | * @param callable|null $commandToRequestTransformer |
||
98 | * @return \GuzzleHttp\Command\Guzzle\Serializer |
||
99 | */ |
||
100 | 19 | private function getSerializer($commandToRequestTransformer) |
|
106 | |||
107 | /** |
||
108 | * Returns the passed Deserializer when set, a new instance otherwise |
||
109 | * |
||
110 | * @param callable|null $responseToResultTransformer |
||
111 | * @return \GuzzleHttp\Command\Guzzle\Deserializer |
||
112 | */ |
||
113 | 19 | private function getDeserializer($responseToResultTransformer) |
|
121 | |||
122 | /** |
||
123 | * Get the config of the client |
||
124 | * |
||
125 | * @param array|string $option |
||
126 | * @return mixed |
||
127 | */ |
||
128 | 16 | public function getConfig($option = null) |
|
134 | |||
135 | /** |
||
136 | * @param $option |
||
137 | * @param $value |
||
138 | */ |
||
139 | 1 | public function setConfig($option, $value) |
|
143 | |||
144 | /** |
||
145 | * Prepares the client based on the configuration settings of the client. |
||
146 | * |
||
147 | * @param array $config Constructor config as an array |
||
148 | */ |
||
149 | 19 | protected function processConfig(array $config) |
|
169 | } |
||
170 |