HttpClient
in package
Table of Contents
Constants
- RETRY_STATUS_CODES = [429, 500, 502, 503, 504]
Properties
- $apiKey : string
- $baseUrl : string
- $client : Client
- $clientId : string|null
- $maxRetries : int
- $timeout : int
- $userAgent : string|null
Methods
- __construct() : mixed
- buildUrl() : string
- Build a fully-qualified URL without making an HTTP request.
- getApiKey() : string|null
- getClientId() : string|null
- request() : array<string|int, mixed>|null
- requestPage() : PaginatedResponse
- requireApiKey() : string
- requireClientId() : string
- buildRequestOptions() : array<string|int, mixed>
- decodeErrorBody() : array{message: string, code: ?string, error: ?string}
- decodeResponse() : array<string|int, mixed>|null
- isTimeoutException() : bool
- mapApiException() : ApiException
- mapTransportException() : Exception
- parseRetryAfter() : int|null
- resolveMaxRetries() : int
- resolveTimeout() : int
- resolveUrl() : string
- sleep() : void
Constants
RETRY_STATUS_CODES
private
mixed
RETRY_STATUS_CODES
= [429, 500, 502, 503, 504]
Properties
$apiKey read-only
private
string
$apiKey
$baseUrl read-only
private
string
$baseUrl
$client
private
Client
$client
$clientId read-only
private
string|null
$clientId
$maxRetries read-only
private
int
$maxRetries
$timeout read-only
private
int
$timeout
$userAgent read-only
private
string|null
$userAgent
= null
Methods
__construct()
public
__construct(string $apiKey, string|null $clientId, string $baseUrl, int $timeout, int $maxRetries[, HandlerStack|null $handler = null ][, string|null $userAgent = null ]) : mixed
Parameters
- $apiKey : string
- $clientId : string|null
- $baseUrl : string
- $timeout : int
- $maxRetries : int
- $handler : HandlerStack|null = null
- $userAgent : string|null = null
buildUrl()
Build a fully-qualified URL without making an HTTP request.
public
buildUrl(string $path[, array<string, mixed> $query = [] ][, RequestOptions|null $options = null ]) : string
Used for redirect endpoints (e.g., SSO authorize, logout) where the caller needs a URL to redirect the user's browser to.
Parameters
- $path : string
- $query : array<string, mixed> = []
- $options : RequestOptions|null = null
Return values
stringgetApiKey()
public
getApiKey() : string|null
Return values
string|nullgetClientId()
public
getClientId() : string|null
Return values
string|nullrequest()
public
request(string $method, string $path[, array<string|int, mixed>|null $query = null ][, array<string|int, mixed>|null $body = null ][, RequestOptions|null $options = null ]) : array<string|int, mixed>|null
Parameters
- $method : string
- $path : string
- $query : array<string|int, mixed>|null = null
- $body : array<string|int, mixed>|null = null
- $options : RequestOptions|null = null
Return values
array<string|int, mixed>|nullrequestPage()
public
requestPage(string $method, string $path[, array<string|int, mixed>|null $query = null ][, array<string|int, mixed>|null $body = null ][, string|null $modelClass = null ][, RequestOptions|null $options = null ]) : PaginatedResponse
Parameters
- $method : string
- $path : string
- $query : array<string|int, mixed>|null = null
- $body : array<string|int, mixed>|null = null
- $modelClass : string|null = null
- $options : RequestOptions|null = null
Return values
PaginatedResponserequireApiKey()
public
requireApiKey() : string
Return values
stringrequireClientId()
public
requireClientId() : string
Return values
stringbuildRequestOptions()
private
buildRequestOptions(string $method, array<string|int, mixed>|null $query, array<string|int, mixed>|null $body, RequestOptions|null $options) : array<string|int, mixed>
Parameters
- $method : string
- $query : array<string|int, mixed>|null
- $body : array<string|int, mixed>|null
- $options : RequestOptions|null
Return values
array<string|int, mixed>decodeErrorBody()
private
decodeErrorBody(ResponseInterface $response) : array{message: string, code: ?string, error: ?string}
Parameters
- $response : ResponseInterface
Return values
array{message: string, code: ?string, error: ?string}decodeResponse()
private
decodeResponse(ResponseInterface $response) : array<string|int, mixed>|null
Parameters
- $response : ResponseInterface
Return values
array<string|int, mixed>|nullisTimeoutException()
private
isTimeoutException(Throwable $exception) : bool
Parameters
- $exception : Throwable
Return values
boolmapApiException()
private
mapApiException(ResponseInterface $response[, Throwable|null $previous = null ]) : ApiException
Parameters
- $response : ResponseInterface
- $previous : Throwable|null = null
Return values
ApiExceptionmapTransportException()
private
mapTransportException(Throwable $exception) : Exception
Parameters
- $exception : Throwable
Return values
ExceptionparseRetryAfter()
private
parseRetryAfter(string|null $retryAfter) : int|null
Parameters
- $retryAfter : string|null
Return values
int|nullresolveMaxRetries()
private
resolveMaxRetries(RequestOptions|null $options) : int
Parameters
- $options : RequestOptions|null
Return values
intresolveTimeout()
private
resolveTimeout(RequestOptions|null $options) : int
Parameters
- $options : RequestOptions|null
Return values
intresolveUrl()
private
resolveUrl(string $path, RequestOptions|null $options) : string
Parameters
- $path : string
- $options : RequestOptions|null
Return values
stringsleep()
private
sleep(int $attempt[, string|null $retryAfter = null ]) : void
Parameters
- $attempt : int
- $retryAfter : string|null = null