@@ 210-230 (lines=21) @@ | ||
207 | * @param array $args |
|
208 | * @return array |
|
209 | */ |
|
210 | protected function postRequest(...$args): array |
|
211 | { |
|
212 | $logger = null; |
|
213 | if ($this->getContainer()) |
|
214 | { |
|
215 | $logger = $this->container->getLogger('kitsu-request'); |
|
216 | } |
|
217 | ||
218 | $response = $this->getResponse('POST', ...$args); |
|
219 | $validResponseCodes = [200, 201]; |
|
220 | ||
221 | if ( ! in_array((int) $response->getStatusCode(), $validResponseCodes)) |
|
222 | { |
|
223 | if ($logger) |
|
224 | { |
|
225 | $logger->warning('Non 201 response for POST api call', $response->getBody()); |
|
226 | } |
|
227 | } |
|
228 | ||
229 | return JSON::decode($response->getBody(), TRUE); |
|
230 | } |
|
231 | ||
232 | /** |
|
233 | * Remove some boilerplate for delete requests |
@@ 214-234 (lines=21) @@ | ||
211 | * @param array $args |
|
212 | * @return array |
|
213 | */ |
|
214 | protected function postRequest(...$args): array |
|
215 | { |
|
216 | $logger = null; |
|
217 | if ($this->getContainer()) |
|
218 | { |
|
219 | $logger = $this->container->getLogger('mal-request'); |
|
220 | } |
|
221 | ||
222 | $response = $this->getResponse('POST', ...$args); |
|
223 | $validResponseCodes = [200, 201]; |
|
224 | ||
225 | if ( ! in_array((int) $response->getStatus(), $validResponseCodes)) |
|
226 | { |
|
227 | if ($logger) |
|
228 | { |
|
229 | $logger->warning('Non 201 response for POST api call', $response->getBody()); |
|
230 | } |
|
231 | } |
|
232 | ||
233 | return XML::toArray($response->getBody()); |
|
234 | } |
|
235 | } |