WorkOS PHP SDK

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

$clientId read-only

private string|null $clientId

$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
string

getApiKey()

public getApiKey() : string|null
Return values
string|null

getClientId()

public getClientId() : string|null
Return values
string|null

request()

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>|null

requestPage()

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
PaginatedResponse

requireApiKey()

public requireApiKey() : string
Return values
string

requireClientId()

public requireClientId() : string
Return values
string

buildRequestOptions()

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>|null

isTimeoutException()

private isTimeoutException(Throwable $exception) : bool
Parameters
$exception : Throwable
Return values
bool

mapApiException()

private mapApiException(ResponseInterface $response[, Throwable|null $previous = null ]) : ApiException
Parameters
$response : ResponseInterface
$previous : Throwable|null = null
Return values
ApiException

mapTransportException()

private mapTransportException(Throwable $exception) : Exception
Parameters
$exception : Throwable
Return values
Exception

parseRetryAfter()

private parseRetryAfter(string|null $retryAfter) : int|null
Parameters
$retryAfter : string|null
Return values
int|null

sleep()

private sleep(int $attempt[, string|null $retryAfter = null ]) : void
Parameters
$attempt : int
$retryAfter : string|null = null

        
On this page

Search results