Skip to content

Commit

Permalink
post method
Browse files Browse the repository at this point in the history
  • Loading branch information
justijndepover committed Jun 22, 2021
1 parent 8cabdc5 commit 807cb87
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Teamleader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 807cb87

Please sign in to comment.