Documentation

EasyPostClient extends BaseService
in package

Client used to send requests to the EasyPost API.

Table of Contents

$address  : AddressService
$apiKeys  : ApiKeyService
$batch  : BatchService
$betaRate  : BetaRateService
$betaReferralCustomer  : BetaReferralCustomerService
$billing  : BillingService
$carrierAccount  : CarrierAccountService
$carrierMetadata  : CarrierMetadataService
$claim  : ClaimService
$customerPortal  : CustomerPortalService
$customsInfo  : CustomsInfoService
$customsItem  : CustomsItemService
$embeddable  : EmbeddableService
$endShipper  : EndShipperService
$event  : EventService
$fedexRegistration  : FedExRegistrationService
$httpClient  : Client
$insurance  : InsuranceService
$luma  : LumaService
$order  : OrderService
$parcel  : ParcelService
$pickup  : PickupService
$rate  : RateService
$referralCustomer  : ReferralCustomerService
$refund  : RefundService
$report  : ReportService
$requestEvent  : RequestHook
$responseEvent  : ResponseHook
$scanForm  : ScanFormService
$shipment  : ShipmentService
$smartRate  : SmartRateService
$tracker  : TrackerService
$user  : UserService
$webhook  : WebhookService
$client  : EasyPostClient
$apiBase  : string
$apiKey  : string
$mockingUtility  : object|null
$timeout  : float
__construct()  : mixed
Constructor for an EasyPostClient.
__get()  : mixed
Get a Service when calling a property of an EasyPostClient.
getApiBase()  : string
Get the API Base URL of an EasyPostClient.
getApiKey()  : string
Get the API key of an EasyPostClient.
getMockingUtility()  : object|null
Get the mock requests of an EasyPostClient.
getTimeout()  : float
Get the timeout of an EasyPostClient.
makeApiCall()  : mixed
Make an API call to the EasyPost API.
mock()  : bool
Get whether this client is configured to mock requests
subscribeToRequestHook()  : void
Subscribe functions to run when a request event occurs.
subscribeToResponseHook()  : void
Subscribe functions to run when a response event occurs.
unsubscribeFromRequestHook()  : void
Unsubscribe functions from running when a request even occurs.
unsubscribeFromResponseHook()  : void
Unsubscribe functions from running when a response even occurs.
allResources()  : mixed
Internal retrieve all method.
className()  : string
The class name of an object.
classUrl()  : string
The class URL of an object.
createResource()  : mixed
Internal create method.
deleteResource()  : void
Internal delete method.
getNextPageResources()  : mixed
Internal retrieve next page method.
instanceUrl()  : string
The instance URL of an object.
retrieveResource()  : mixed
Internal retrieve method.
serviceModelClassName()  : string
Gets the class name of a Service's model.
updateResource()  : mixed
Internal update method.
validate()  : void
Validate library usage.

Properties

Methods

__construct()

Constructor for an EasyPostClient.

public __construct(string $apiKey[, float $timeout = Constants::TIMEOUT ][, string $apiBase = Constants::API_BASE ][, object|null $mockingUtility = null ]) : mixed
Parameters
$apiKey : string
$timeout : float = Constants::TIMEOUT
$apiBase : string = Constants::API_BASE
$mockingUtility : object|null = null
Return values
mixed

__get()

Get a Service when calling a property of an EasyPostClient.

public __get(string $serviceName) : mixed
Parameters
$serviceName : string
Tags
throws
EasyPostException
Return values
mixed

getApiBase()

Get the API Base URL of an EasyPostClient.

public getApiBase() : string
Return values
string

getApiKey()

Get the API key of an EasyPostClient.

public getApiKey() : string
Return values
string

getMockingUtility()

Get the mock requests of an EasyPostClient.

public getMockingUtility() : object|null
Return values
object|null

getTimeout()

Get the timeout of an EasyPostClient.

public getTimeout() : float
Return values
float

makeApiCall()

Make an API call to the EasyPost API.

public makeApiCall(string $method, string $endpoint[, mixed $params = null ]) : mixed

This public, generic interface is useful for making arbitrary API calls to the EasyPost API that are not yet supported by the client library's services. When possible, the service for your use case should be used instead as it provides a more convenient and higher-level interface depending on the endpoint.

Parameters
$method : string
$endpoint : string
$params : mixed = null
Return values
mixed

mock()

Get whether this client is configured to mock requests

public mock() : bool
Return values
bool

subscribeToRequestHook()

Subscribe functions to run when a request event occurs.

public subscribeToRequestHook(callable $function) : void
Parameters
$function : callable
Return values
void

subscribeToResponseHook()

Subscribe functions to run when a response event occurs.

public subscribeToResponseHook(callable $function) : void
Parameters
$function : callable
Return values
void

unsubscribeFromRequestHook()

Unsubscribe functions from running when a request even occurs.

public unsubscribeFromRequestHook(callable $function) : void
Parameters
$function : callable
Return values
void

unsubscribeFromResponseHook()

Unsubscribe functions from running when a response even occurs.

public unsubscribeFromResponseHook(callable $function) : void
Parameters
$function : callable
Return values
void

allResources()

Internal retrieve all method.

protected allResources(string $class[, mixed $params = null ][, bool $beta = false ]) : mixed
Parameters
$class : string
$params : mixed = null
$beta : bool = false
Return values
mixed

className()

The class name of an object.

protected static className(string $class) : string
Parameters
$class : string
Return values
string

classUrl()

The class URL of an object.

protected static classUrl(string $class) : string
Parameters
$class : string
Return values
string

createResource()

Internal create method.

protected createResource(string $class[, mixed $params = null ][, bool $beta = false ]) : mixed
Parameters
$class : string
$params : mixed = null
$beta : bool = false
Return values
mixed

deleteResource()

Internal delete method.

protected deleteResource(string $class, string $id[, mixed $params = null ][, bool $beta = false ]) : void
Parameters
$class : string
$id : string
$params : mixed = null
$beta : bool = false
Return values
void

getNextPageResources()

Internal retrieve next page method.

protected getNextPageResources(string $class, mixed $collection[, int|null $pageSize = null ]) : mixed

TODO: Use this method in EndShipper and Batch once the API fully support it.

Parameters
$class : string
$collection : mixed
$pageSize : int|null = null
Return values
mixed

instanceUrl()

The instance URL of an object.

protected instanceUrl(string $class, string $id) : string
Parameters
$class : string
$id : string
Tags
throws
InvalidObjectException
Return values
string

retrieveResource()

Internal retrieve method.

protected retrieveResource(string $class, string $id[, bool $beta = false ]) : mixed
Parameters
$class : string
$id : string
$beta : bool = false
Return values
mixed

serviceModelClassName()

Gets the class name of a Service's model.

protected static serviceModelClassName(string $serviceClassName) : string
Parameters
$serviceClassName : string
Return values
string

updateResource()

Internal update method.

protected updateResource(string $class, string $id[, mixed $params = null ][, string $method = 'patch' ][, bool $beta = false ]) : mixed
Parameters
$class : string
$id : string
$params : mixed = null
$method : string = 'patch'
$beta : bool = false
Return values
mixed

validate()

Validate library usage.

protected static validate([mixed $params = null ]) : void
Parameters
$params : mixed = null
Tags
throws
InvalidParameterException
Return values
void

Search results