|
@@ -71,29 +71,44 @@ class ApiRequestService implements ApiRequestInterface
|
|
|
return $this->request('GET', $path, $parameters, $options);
|
|
return $this->request('GET', $path, $parameters, $options);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param array $options
|
|
|
|
|
+ * @param array|string $body
|
|
|
|
|
+ * @return array
|
|
|
|
|
+ */
|
|
|
|
|
+ private function addBodyOption(array $options, array | string $body): array
|
|
|
|
|
+ {
|
|
|
|
|
+ $option = is_array($body) ? ['json' => $body] : ['body' => $body];
|
|
|
|
|
+ return array_merge($options, $option);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Sends a POST request and returns the response.
|
|
* Sends a POST request and returns the response.
|
|
|
*
|
|
*
|
|
|
|
|
+ * @param array<mixed>|string $body
|
|
|
* @param array<mixed> $parameters
|
|
* @param array<mixed> $parameters
|
|
|
* @param array<mixed> $options
|
|
* @param array<mixed> $options
|
|
|
*
|
|
*
|
|
|
* @throws HttpException
|
|
* @throws HttpException
|
|
|
*/
|
|
*/
|
|
|
- public function post(string $path, array $parameters = [], array $options = []): ResponseInterface
|
|
|
|
|
|
|
+ public function post(string $path, array | string $body, array $parameters = [], array $options = []): ResponseInterface
|
|
|
{
|
|
{
|
|
|
|
|
+ $options = $this->addBodyOption($options, $body);
|
|
|
return $this->request('POST', $path, $parameters, $options);
|
|
return $this->request('POST', $path, $parameters, $options);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Sends a PUT request and returns the response.
|
|
* Sends a PUT request and returns the response.
|
|
|
*
|
|
*
|
|
|
|
|
+ * @param array<mixed>|string $body
|
|
|
* @param array<mixed> $parameters
|
|
* @param array<mixed> $parameters
|
|
|
* @param array<mixed> $options
|
|
* @param array<mixed> $options
|
|
|
*
|
|
*
|
|
|
* @throws HttpException
|
|
* @throws HttpException
|
|
|
*/
|
|
*/
|
|
|
- public function put(string $path, array $parameters = [], array $options = []): ResponseInterface
|
|
|
|
|
|
|
+ public function put(string $path, array | string $body, array $parameters = [], array $options = []): ResponseInterface
|
|
|
{
|
|
{
|
|
|
|
|
+ $options = $this->addBodyOption($options, $body);
|
|
|
return $this->request('PUT', $path, $parameters, $options);
|
|
return $this->request('PUT', $path, $parameters, $options);
|
|
|
}
|
|
}
|
|
|
|
|
|