Skip to content

Commit

Permalink
response split to content & json
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan-DPC committed Sep 5, 2017
1 parent 4c6757d commit a5816f9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/GuzzleClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class GuzzleClient implements RequestClientContract
{
protected $client;

protected $response;

/**
* GuzzleClient constructor.
*/
Expand All @@ -19,12 +21,26 @@ public function __construct()

public function send(string $method, string $uri, array $body = null, array $headers = null, array $options = null)
{
return json_decode($this->client->request($method, $uri, [
$this->response = $this->client->request($method, $uri, [
'form_params' => $body,
'headers' => $headers,
'options' => $options,
])->getBody());
])->getBody();

return $this;
}

public function content() : string
{
return $this->response;
}

public function json()
{
return json_decode($this->response);

}



}
4 changes: 4 additions & 0 deletions src/RequestClientContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
interface RequestClientContract
{
public function send(string $method, string $uri, array $body = null, array $headers = null, array $options = null);

public function json();

public function content();
}

0 comments on commit a5816f9

Please sign in to comment.