Skip to content

Commit

Permalink
Merge pull request #24 from limenet/master
Browse files Browse the repository at this point in the history
Don't double JSON-encode the request
  • Loading branch information
IcyApril authored Oct 6, 2017
2 parents ca80e2c + 70ee68f commit e1cf1ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 deletions src/Adapter/Guzzle.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@ public function post(String $uri, array $headers = [], array $body = []): Respon
*/
public function put(String $uri, array $headers = [], array $body = []): ResponseInterface
{
$jsonBody = json_encode($body);

$response = $this->client->put(
$uri,
[
'headers' => $headers,
'json' => $jsonBody
'json' => $body
]
);

Expand All @@ -86,13 +84,11 @@ public function put(String $uri, array $headers = [], array $body = []): Respons
*/
public function patch(String $uri, array $headers = [], array $body = []): ResponseInterface
{
$jsonBody = json_encode($body);

$response = $this->client->patch(
$uri,
[
'headers' => $headers,
'json' => $jsonBody
'json' => $body
]
);

Expand Down
4 changes: 2 additions & 2 deletions tests/Adapter/GuzzleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testPut()
$this->assertEquals("application/json", $headers["Content-Type"][0]);

$body = json_decode($response->getBody());
$this->assertEquals("Testing a PUT request.", json_decode($body->json)->{"X-Put-Test"});
$this->assertEquals("Testing a PUT request.", $body->json->{"X-Put-Test"});
}

public function testPatch()
Expand All @@ -73,7 +73,7 @@ public function testPatch()
$this->assertEquals("application/json", $headers["Content-Type"][0]);

$body = json_decode($response->getBody());
$this->assertEquals("Testing a PATCH request.", json_decode($body->json)->{"X-Patch-Test"});
$this->assertEquals("Testing a PATCH request.", $body->json->{"X-Patch-Test"});
}

public function testDelete()
Expand Down

0 comments on commit e1cf1ae

Please sign in to comment.