diff --git a/src/Teamleader.php b/src/Teamleader.php index 62d64f3..01bc9f2 100644 --- a/src/Teamleader.php +++ b/src/Teamleader.php @@ -202,6 +202,22 @@ public function get(string $endpoint, array $parameters = []) } } + public function post(string $endpoint, array $body, array $parameters = []) + { + $body = json_encode($body); + + try { + $request = $this->createRequest('POST', $endpoint, $body, $parameters); + $response = $this->client->send($request); + + return $this->parseResponse($response); + } catch (ClientException $e) { + $this->parseExceptionForErrorMessages($e); + } catch (Exception $e) { + throw ApiException::make($e->getCode(), $e->getMessage()); + } + } + private function createRequest($method, $endpoint, $body = null, array $parameters = [], array $headers = []) { $endpoint = $this->buildUrl($endpoint);