1 | <?php |
||
11 | class Client |
||
12 | { |
||
13 | use Options; |
||
14 | |||
15 | /** @var HttpClientInterface */ |
||
16 | protected $client; |
||
17 | |||
18 | /** @var Config|null */ |
||
19 | protected $config; |
||
20 | |||
21 | /** @var array<mixed> */ |
||
22 | protected $options = []; |
||
23 | |||
24 | /** @var string */ |
||
25 | protected $bodyFormat = 'json'; |
||
26 | |||
27 | /** @var bool */ |
||
28 | protected $throwErrors = false; |
||
29 | |||
30 | /** |
||
31 | * @param Config|null $config |
||
32 | * |
||
33 | * @return Client |
||
34 | */ |
||
35 | public static function create(Config $config = null) |
||
39 | |||
40 | /** |
||
41 | * @param Config|null $config |
||
42 | */ |
||
43 | public function __construct(Config $config = null) |
||
52 | |||
53 | /** |
||
54 | * @return $this |
||
55 | */ |
||
56 | protected function transferThrowErrorsFromConfig(): self |
||
62 | |||
63 | /** |
||
64 | * @return $this |
||
65 | */ |
||
66 | protected function transferBodyFormatFromConfig(): self |
||
72 | |||
73 | /** |
||
74 | * @param string $endpoint |
||
75 | * |
||
76 | * @return Response|mixed |
||
77 | * |
||
78 | * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface |
||
79 | */ |
||
80 | public function get(string $endpoint) |
||
84 | |||
85 | /** |
||
86 | * @param string $endpoint |
||
87 | * |
||
88 | * @return Response|mixed |
||
89 | * |
||
90 | * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface |
||
91 | */ |
||
92 | public function head(string $endpoint) |
||
96 | |||
97 | /** |
||
98 | * @param string $endpoint |
||
99 | * |
||
100 | * @return Response|mixed |
||
101 | * |
||
102 | * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface |
||
103 | */ |
||
104 | public function post(string $endpoint) |
||
108 | |||
109 | /** |
||
110 | * @param string $endpoint |
||
111 | * |
||
112 | * @return Response|mixed |
||
113 | * |
||
114 | * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface |
||
115 | */ |
||
116 | public function put(string $endpoint) |
||
120 | |||
121 | /** |
||
122 | * @param string $endpoint |
||
123 | * |
||
124 | * @return Response|mixed |
||
125 | * |
||
126 | * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface |
||
127 | */ |
||
128 | public function patch(string $endpoint) |
||
132 | |||
133 | /** |
||
134 | * @param string $endpoint |
||
135 | * |
||
136 | * @return Response |
||
137 | * |
||
138 | * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface |
||
139 | */ |
||
140 | public function delete(string $endpoint) |
||
144 | |||
145 | /** |
||
146 | * @param string $method |
||
147 | * @param string $endpoint |
||
148 | * |
||
149 | * @return mixed|Response |
||
150 | * |
||
151 | * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface |
||
152 | */ |
||
153 | protected function request(string $method, string $endpoint) |
||
162 | |||
163 | /** |
||
164 | * @param ResponseInterface|ResponseInterface[]|iterable $responses |
||
165 | * |
||
166 | * @return ResponseStreamInterface |
||
167 | */ |
||
168 | public function stream($responses): ResponseStreamInterface |
||
176 | |||
177 | /** |
||
178 | * @return HttpClientInterface |
||
179 | */ |
||
180 | protected function buildClient(): HttpClientInterface |
||
184 | |||
185 | /** |
||
186 | * @return array<String|Array> |
||
187 | */ |
||
188 | public function config(): array |
||
192 | |||
193 | /** |
||
194 | * @return array<mixed> |
||
195 | */ |
||
196 | public function options(): array |
||
200 | |||
201 | /** |
||
202 | * @return HttpClientInterface |
||
203 | */ |
||
204 | public function client(): HttpClientInterface |
||
208 | } |
||
209 |