| @@ 71-93 (lines=23) @@ | ||
| 68 | /** |
|
| 69 | * @throws OmsClientExceptionInterface |
|
| 70 | */ |
|
| 71 | private function request(string $token, string $method, string $uri, array $query = [], $body = null): string |
|
| 72 | { |
|
| 73 | $options = [ |
|
| 74 | RequestOptions::BODY => $body, |
|
| 75 | RequestOptions::HEADERS => [ |
|
| 76 | 'Content-Type' => 'application/json', |
|
| 77 | 'clientToken' => $token, |
|
| 78 | ], |
|
| 79 | RequestOptions::QUERY => $query, |
|
| 80 | RequestOptions::HTTP_ERRORS => true, |
|
| 81 | ]; |
|
| 82 | ||
| 83 | $uri = ltrim($uri, '/'); |
|
| 84 | ||
| 85 | try { |
|
| 86 | $result = $this->client->request($method, $uri, $options); |
|
| 87 | } catch (\Throwable $exception) { |
|
| 88 | /* @noinspection PhpUnhandledExceptionInspection */ |
|
| 89 | throw $this->handleRequestException($exception); |
|
| 90 | } |
|
| 91 | ||
| 92 | return (string) $result->getBody(); |
|
| 93 | } |
|
| 94 | ||
| 95 | private function handleRequestException(\Throwable $exception): OmsClientExceptionInterface |
|
| 96 | { |
|
| @@ 86-108 (lines=23) @@ | ||
| 83 | /** |
|
| 84 | * @throws OmsRequestErrorException |
|
| 85 | */ |
|
| 86 | private function request(string $token, string $method, string $uri, array $query = [], $body = null): string |
|
| 87 | { |
|
| 88 | $options = [ |
|
| 89 | RequestOptions::BODY => $body, |
|
| 90 | RequestOptions::HEADERS => [ |
|
| 91 | 'Content-Type' => 'application/json', |
|
| 92 | 'clientToken' => $token, |
|
| 93 | ], |
|
| 94 | RequestOptions::QUERY => $query, |
|
| 95 | RequestOptions::HTTP_ERRORS => true, |
|
| 96 | ]; |
|
| 97 | ||
| 98 | $uri = ltrim($uri, '/'); |
|
| 99 | ||
| 100 | try { |
|
| 101 | $result = $this->client->request($method, $uri, $options); |
|
| 102 | } catch (\Throwable $exception) { |
|
| 103 | /* @noinspection PhpUnhandledExceptionInspection */ |
|
| 104 | throw $this->handleRequestException($exception); |
|
| 105 | } |
|
| 106 | ||
| 107 | return (string)$result->getBody(); |
|
| 108 | } |
|
| 109 | ||
| 110 | private function handleRequestException(\Throwable $exception): OmsClientExceptionInterface |
|
| 111 | { |
|