Skip to content

Commit

Permalink
Merge pull request #32 from mobixon/master
Browse files Browse the repository at this point in the history
added last response header property for Client
  • Loading branch information
Alexandr Vronskiy authored Aug 14, 2020
2 parents 7ba61ca + fcb0809 commit 809a465
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class Client
*/
protected $authToken;

/**
* @var array|string[][]
*/
protected $lastResponseHeaders = [];

/**
* Client constructor.
*
Expand Down Expand Up @@ -155,6 +160,7 @@ protected function getParams($organizationId, array $data = [])
*/
protected function processResult(ResponseInterface $response)
{
$this->lastResponseHeaders = $response->getHeaders();
try {
if (preg_grep('/json/', $response->getHeader('Content-Type'))) {
$result = \GuzzleHttp\json_decode($response->getBody(), true);
Expand Down Expand Up @@ -195,6 +201,9 @@ private function auth($email, $password)
],
]
);

$this->lastResponseHeaders = $response->getHeaders();

$authToken = '';
if (preg_match('/AUTHTOKEN=(?<token>[a-z0-9]+)/', (string) $response->getBody(), $matches)) {
$authToken = $matches['token'];
Expand Down

0 comments on commit 809a465

Please sign in to comment.