@@ 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 | { |
@@ 117-139 (lines=23) @@ | ||
114 | /** |
|
115 | * @throws OmsRequestErrorException |
|
116 | */ |
|
117 | private function request(string $token, string $method, string $uri, array $query = [], $body = null): string |
|
118 | { |
|
119 | $options = [ |
|
120 | RequestOptions::BODY => $body, |
|
121 | RequestOptions::HEADERS => [ |
|
122 | 'Content-Type' => 'application/json', |
|
123 | 'clientToken' => $token, |
|
124 | ], |
|
125 | RequestOptions::QUERY => $query, |
|
126 | RequestOptions::HTTP_ERRORS => true, |
|
127 | ]; |
|
128 | ||
129 | $uri = ltrim($uri, '/'); |
|
130 | ||
131 | try { |
|
132 | $result = $this->client->request($method, $uri, $options); |
|
133 | } catch (\Throwable $exception) { |
|
134 | /* @noinspection PhpUnhandledExceptionInspection */ |
|
135 | throw $this->handleRequestException($exception); |
|
136 | } |
|
137 | ||
138 | return (string)$result->getBody(); |
|
139 | } |
|
140 | ||
141 | private function handleRequestException(\Throwable $exception): OmsClientExceptionInterface |
|
142 | { |