Skip to content

Commit

Permalink
Merge pull request #8 from lcherone/patch-3
Browse files Browse the repository at this point in the history
Update AbstructEndpoint.php
  • Loading branch information
ashleyhood authored Feb 8, 2017
2 parents e9fd821 + 5909a7c commit 88089ec
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Endpoint/AbstructEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function get($path, array $parameters = [], array $requestHeaders = []
* @param array $data POST data to be JSON encoded.
* @param array $requestHeaders Request headers.
*/
protected function post($path, array $data = [], array $parameters = [], array $requestHeaders = [])
protected function post($path, $data = [], array $parameters = [], array $requestHeaders = [])
{
$response = $this->client->getHttpClient()->post(
$this->buildPath($path, $parameters),
Expand Down Expand Up @@ -120,7 +120,11 @@ protected function delete($path, array $parameters = [], array $requestHeaders =
*/
protected function createJsonBody(array $data)
{
return (count($data) === 0) ? null : json_encode($data, empty($data) ? JSON_FORCE_OBJECT : 0);
if (is_array($data)) {
return (count($data) === 0) ? null : json_encode($data, empty($data) ? JSON_FORCE_OBJECT : 0);
} else {
return $data;
}
}

/**
Expand Down

0 comments on commit 88089ec

Please sign in to comment.