Skip to content

Commit

Permalink
Add response var on Service class to save the Response of request
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelwendel committed Oct 10, 2022
1 parent 66035f6 commit 5a0bb26
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

namespace PHPSupabase;

use GuzzleHttp\Psr7\Response;

class Service {
private $apiKey;
private $uriBase;
private $httpClient;
private $error;
private $response;

private $headers = [
'Content-Type' => 'application/json'
Expand Down Expand Up @@ -84,6 +87,16 @@ public function getHttpClient() : \GuzzleHttp\Client
return $this->httpClient;
}

/**
* Returns the Response of last request
* @access public
* @return Response
*/
public function getResponse() : Response
{
return $this->response;
}

/**
* Set a header to be use in the API request
* @access public
Expand Down Expand Up @@ -180,12 +193,12 @@ public function formatRequestException(\GuzzleHttp\Exception\RequestException $e
public function executeHttpRequest(string $method, string $uri, array $options)
{
try{
$response = $this->httpClient->request(
$this->response = $this->httpClient->request(
$method,
$uri,
$options
);
return json_decode($response->getBody());
return json_decode($this->response->getBody());
} catch(\GuzzleHttp\Exception\RequestException $e){
$this->formatRequestException($e);
throw $e;
Expand Down

0 comments on commit 5a0bb26

Please sign in to comment.