Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make headers of last response available trough (base) client #57

Merged
merged 6 commits into from
Jan 27, 2025
Merged
12 changes: 12 additions & 0 deletions src/BaseClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class BaseClient
/** @var ?callable */
private $accessTokenExpiredCallback = null;

private $lastResponseHeaders = null;

/**
* BaseClient constructor.
*/
Expand Down Expand Up @@ -375,9 +377,19 @@ public function request(string $method, string $url, array $options, array $resp
}
}

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

return $this->decodeResponse($response, $responseTypes, $url);
}

/**
* @return array|null
*/
public function getLastResponseHeaders(): ?array
{
return $this->lastResponseHeaders;
}

/**
* Validates the existence of the token and its expiration. If the token is expired, the accessTokenExpiredCallback is
* called.
Expand Down
Loading