1 | <?php |
||
12 | class Client |
||
13 | { |
||
14 | use Options; |
||
15 | |||
16 | /** @var HttpClientInterface */ |
||
17 | protected $client; |
||
18 | |||
19 | /** @var Config */ |
||
20 | protected $config; |
||
21 | |||
22 | /** |
||
23 | * @param Config|null $config |
||
24 | * |
||
25 | * @return Client |
||
26 | */ |
||
27 | public static function create(Config $config = null) |
||
31 | |||
32 | /** |
||
33 | * @param Config|null $config |
||
34 | */ |
||
35 | public function __construct(Config $config = null) |
||
44 | |||
45 | /** |
||
46 | * @return $this |
||
47 | */ |
||
48 | protected function transferThrowErrorsFromConfig(): self |
||
54 | |||
55 | /** |
||
56 | * @return $this |
||
57 | */ |
||
58 | protected function transferBodyFormatFromConfig(): self |
||
64 | |||
65 | /** |
||
66 | * @param string $endpoint |
||
67 | * |
||
68 | * @return Response|mixed |
||
69 | * |
||
70 | * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface |
||
71 | */ |
||
72 | public function get(string $endpoint) |
||
76 | |||
77 | /** |
||
78 | * @param string $endpoint |
||
79 | * |
||
80 | * @return Response|mixed |
||
81 | * |
||
82 | * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface |
||
83 | */ |
||
84 | public function head(string $endpoint) |
||
88 | |||
89 | /** |
||
90 | * @param string $endpoint |
||
91 | * |
||
92 | * @return Response|mixed |
||
93 | * |
||
94 | * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface |
||
95 | */ |
||
96 | public function post(string $endpoint) |
||
100 | |||
101 | /** |
||
102 | * @param string $endpoint |
||
103 | * |
||
104 | * @return Response|mixed |
||
105 | * |
||
106 | * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface |
||
107 | */ |
||
108 | public function put(string $endpoint) |
||
112 | |||
113 | /** |
||
114 | * @param string $endpoint |
||
115 | * |
||
116 | * @return Response|mixed |
||
117 | * |
||
118 | * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface |
||
119 | */ |
||
120 | public function patch(string $endpoint) |
||
124 | |||
125 | /** |
||
126 | * @param string $endpoint |
||
127 | * |
||
128 | * @return Response |
||
129 | * |
||
130 | * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface |
||
131 | */ |
||
132 | public function delete(string $endpoint) |
||
136 | |||
137 | /** |
||
138 | * @param string $method |
||
139 | * @param string $endpoint |
||
140 | * |
||
141 | * @return mixed|Response |
||
142 | * |
||
143 | * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface |
||
144 | */ |
||
145 | protected function request(string $method, string $endpoint) |
||
154 | |||
155 | /** |
||
156 | * @param string $pathToFile |
||
157 | * @param string|null $name |
||
158 | * @param string|null $contentType |
||
159 | * |
||
160 | * @return DataPart |
||
161 | */ |
||
162 | public static function fileHandler( |
||
169 | |||
170 | /** |
||
171 | * @param ResponseInterface|ResponseInterface[]|iterable $responses |
||
172 | * |
||
173 | * @return ResponseStreamInterface |
||
174 | */ |
||
175 | public function stream($responses): ResponseStreamInterface |
||
183 | |||
184 | /** |
||
185 | * @return HttpClientInterface |
||
186 | */ |
||
187 | protected function buildClient(): HttpClientInterface |
||
191 | |||
192 | /** |
||
193 | * @return array<String|Array> |
||
194 | */ |
||
195 | public function config(): array |
||
199 | |||
200 | /** |
||
201 | * @return array<mixed> |
||
202 | */ |
||
203 | public function options(): array |
||
207 | |||
208 | /** |
||
209 | * @return HttpClientInterface |
||
210 | */ |
||
211 | public function client(): HttpClientInterface |
||
215 | } |
||
216 |