Documentation

ShipEngineClient
in package

A wrapped `JSON-RPC 2.0` HTTP client to send HTTP requests from the SDK.

Table of Contents

request()  : array<string|int, mixed>|mixed
Create and send a `JSON-RPC 2.0` request over HTTP messages.
deriveUserAgent()  : string
Derive a User-Agent header from the environment. This is the user-agent that will be set on every request via the ShipEngine Client.
handleResponse()  : mixed
sendRequest()  : mixed
Send a `JSON-RPC 2.0` request via HTTP Messages to ShipEngine API. If the response is successful, the result is returned. Otherwise, an error is thrown.
sendRPCRequest()  : mixed
Send a `JSON-RPC 2.0` request via *ShipEngineClient*.
wrapRequest()  : array<string|int, mixed>
Wrap request per `JSON-RPC 2.0` spec.

Methods

request()

Create and send a `JSON-RPC 2.0` request over HTTP messages.

public request(string $method, ShipEngineConfig $config[, array<string|int, mixed>|null $params = null ]) : array<string|int, mixed>|mixed
Parameters
$method : string

The RPC method to be used in the request.

$config : ShipEngineConfig

A ShipEngineConfig object.

$params : array<string|int, mixed>|null = null

An array of params to be sent in the JSON-RPC request.

Tags
throws
ClientExceptionInterface
Return values
array<string|int, mixed>|mixed

deriveUserAgent()

Derive a User-Agent header from the environment. This is the user-agent that will be set on every request via the ShipEngine Client.

private deriveUserAgent() : string
Tags
returns

string

Return values
string

handleResponse()

private handleResponse(array<string|int, mixed> $response) : mixed
Parameters
$response : array<string|int, mixed>
Return values
mixed

sendRequest()

Send a `JSON-RPC 2.0` request via HTTP Messages to ShipEngine API. If the response is successful, the result is returned. Otherwise, an error is thrown.

private sendRequest(string $method, array<string|int, mixed>|null $params, int $retry, ShipEngineConfig $config) : mixed
Parameters
$method : string
$params : array<string|int, mixed>|null
$retry : int
$config : ShipEngineConfig
Tags
throws
GuzzleException
Return values
mixed

sendRPCRequest()

Send a `JSON-RPC 2.0` request via *ShipEngineClient*.

private sendRPCRequest(string $method, array<string|int, mixed>|null $params, ShipEngineConfig $config) : mixed
Parameters
$method : string
$params : array<string|int, mixed>|null
$config : ShipEngineConfig
Tags
throws
GuzzleException
Return values
mixed

wrapRequest()

Wrap request per `JSON-RPC 2.0` spec.

private wrapRequest(string $method, array<string|int, mixed>|null $params) : array<string|int, mixed>
Parameters
$method : string
$params : array<string|int, mixed>|null
Return values
array<string|int, mixed>

Search results