1 | <?php |
||
30 | final class DefaultServiceMethod implements ServiceMethod |
||
31 | { |
||
32 | /** |
||
33 | * Request method |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | private $method; |
||
38 | |||
39 | /** |
||
40 | * Request base url |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | private $baseUrl; |
||
45 | |||
46 | /** |
||
47 | * Request path |
||
48 | * |
||
49 | * @var string |
||
50 | */ |
||
51 | private $path; |
||
52 | |||
53 | /** |
||
54 | * @var array |
||
55 | */ |
||
56 | private $headers; |
||
57 | |||
58 | /** |
||
59 | * Array of parameter handlers |
||
60 | * |
||
61 | * @var ParameterHandler[] |
||
62 | */ |
||
63 | private $parameterHandlers; |
||
64 | |||
65 | /** |
||
66 | * The call adapter to use |
||
67 | * |
||
68 | * @var CallAdapter |
||
69 | */ |
||
70 | private $callAdapter; |
||
71 | |||
72 | /** |
||
73 | * Response body converter |
||
74 | * |
||
75 | * @var ResponseBodyConverter |
||
76 | */ |
||
77 | private $responseBodyConverter; |
||
78 | |||
79 | /** |
||
80 | * Error body converter |
||
81 | * |
||
82 | * @var ResponseBodyConverter |
||
83 | */ |
||
84 | private $errorBodyConverter; |
||
85 | |||
86 | /** |
||
87 | * Constructor |
||
88 | * |
||
89 | * @param string $method |
||
90 | * @param string $baseUrl |
||
91 | * @param string $uri |
||
92 | * @param array $headers |
||
93 | * @param array $parameterHandlers |
||
94 | * @param CallAdapter $callAdapter |
||
95 | * @param ResponseBodyConverter $responseBodyConverter |
||
96 | * @param ResponseBodyConverter $errorBodyConverter |
||
97 | */ |
||
98 | 27 | public function __construct( |
|
117 | |||
118 | /** |
||
119 | * Apply runtime arguments and build request |
||
120 | * |
||
121 | * @param array $args |
||
122 | * @return RequestInterface |
||
123 | * @throws \LogicException |
||
124 | */ |
||
125 | 16 | public function toRequest(array $args): RequestInterface |
|
150 | |||
151 | /** |
||
152 | * Take a response and convert it to expected value |
||
153 | * |
||
154 | * @param ResponseInterface $response |
||
155 | * @return mixed |
||
156 | */ |
||
157 | 15 | public function toResponseBody(ResponseInterface $response) |
|
161 | |||
162 | /** |
||
163 | * Take a response and convert it to expected value |
||
164 | * |
||
165 | * @param ResponseInterface $response |
||
166 | * @return mixed |
||
167 | */ |
||
168 | 1 | public function toErrorBody(ResponseInterface $response) |
|
172 | |||
173 | /** |
||
174 | * Take a [@see Call] and adapt to expected value |
||
175 | * |
||
176 | * @param Call $call |
||
177 | * @return mixed |
||
178 | */ |
||
179 | 16 | public function adapt(Call $call) |
|
183 | } |
||
184 |