Documentation

Requestor
in package

Table of Contents

handleApiError()  : void
Handles API errors returned from EasyPost.
interpretResponse()  : mixed
Interpret the response body we receive from the API.
request()  : mixed
Make a request to the EasyPost API.
utf8()  : string
Converts a set of values to UTF-8 encoding.
absoluteUrl()  : string
Get the API URL.
encodeObjects()  : array<string|int, mixed>|string
Encodes an EasyPost object and prepares the data for the request.
requestRaw()  : array<string|int, mixed>
Internal logic required to make a request to the EasyPost API.
traverseJsonElement()  : string
Recursively traverses a JSON element to extract error messages and returns them as a comma-separated string.

Methods

handleApiError()

Handles API errors returned from EasyPost.

public static handleApiError(string|null $httpBody, int $httpStatus, array<string|int, mixed> $response) : void
Parameters
$httpBody : string|null
$httpStatus : int
$response : array<string|int, mixed>
Tags
throws
BadRequestException
throws
GatewayTimeoutException
throws
InternalServerException
throws
InvalidRequestException
throws
JsonException
throws
MethodNotAllowedException
throws
NotFoundException
throws
PaymentException
throws
RateLimitException
throws
RedirectException
throws
ServiceUnavailableException
throws
TimeoutException
throws
UnauthorizedException
throws
UnknownApiException
Return values
void

interpretResponse()

Interpret the response body we receive from the API.

public static interpretResponse(string $httpBody, int $httpStatus) : mixed
Parameters
$httpBody : string
$httpStatus : int
Tags
throws
JsonException
Return values
mixed

request()

Make a request to the EasyPost API.

public static request(EasyPostClient $client, string $method, string $url[, mixed $params = null ][, bool $beta = false ]) : mixed
Parameters
$client : EasyPostClient
$method : string
$url : string
$params : mixed = null
$beta : bool = false
Return values
mixed

utf8()

Converts a set of values to UTF-8 encoding.

public static utf8(mixed $value) : string
Parameters
$value : mixed
Return values
string

absoluteUrl()

Get the API URL.

private static absoluteUrl(EasyPostClient $client[, string $url = '' ][, bool $beta = false ]) : string
Parameters
$client : EasyPostClient
$url : string = ''
$beta : bool = false
Return values
string

encodeObjects()

Encodes an EasyPost object and prepares the data for the request.

private static encodeObjects(mixed $data) : array<string|int, mixed>|string
Parameters
$data : mixed
Return values
array<string|int, mixed>|string

requestRaw()

Internal logic required to make a request to the EasyPost API.

private static requestRaw(EasyPostClient $client, string $method, string $url, mixed $params[, bool $beta = false ]) : array<string|int, mixed>
Parameters
$client : EasyPostClient
$method : string
$url : string
$params : mixed
$beta : bool = false
Tags
throws
HttpException
throws
TimeoutException
Return values
array<string|int, mixed>

traverseJsonElement()

Recursively traverses a JSON element to extract error messages and returns them as a comma-separated string.

private static traverseJsonElement(mixed $errorMessage, array<string|int, string> &$messagesList) : string
Parameters
$errorMessage : mixed
$messagesList : array<string|int, string>
Return values
string

Search results