Constants

OPTION_BASE_URI

OPTION_BASE_URI

The base URI to prepend to each request

Type: string Default: null

OPTION_DEFAULT_HEADERS

OPTION_DEFAULT_HEADERS

An array of key => value pairs to include in the headers with each request.

Type: array Default: []

OPTION_DEFAULT_QUERY_PARAMS

OPTION_DEFAULT_QUERY_PARAMS

An array of key => value pairs to include in the query params with each request.

Type: array Default: []

OPTION_REQUEST_BODY_FORMAT

OPTION_REQUEST_BODY_FORMAT

Request body format - either 'json', 'form', or null for pass-through

Type: string Options: 'json', 'form', null Default: 'json'

OPTION_ERROR_CLASS

OPTION_ERROR_CLASS

Error class name

Type: string Default: null

OPTION_RESPONSE_CLASS

OPTION_RESPONSE_CLASS

Response class name

Type: string Default: null

OPTION_UPDATE_METHOD

OPTION_UPDATE_METHOD

HTTP method to use for updates

Type: string Default: 'put'

OPTION_UPDATE_DIFF

OPTION_UPDATE_DIFF

If the API allows you to send *just* the modified fields on update, you can set this to true to help speed things up by making the request body smaller.

Type: boolean Default: false

OPTION_MIDDLEWARE

OPTION_MIDDLEWARE

Array of class names to apply before each request is sent.

Type: array Default: []

OPTION_LOG

OPTION_LOG

Keep a log of all calls made

Type: boolean Default: false

Properties

$httpClient

$httpClient : \GuzzleHttp\Client

Type

\GuzzleHttp\Client

$middlewareManager

$middlewareManager : \Optimus\Onion\Onion

Type

\Optimus\Onion\Onion

$log

$log : array

Type

array

$options

$options : array

Type

array

Methods

__construct()

__construct(array  $options = array(), \GuzzleHttp\Client  $httpClient = null) 

Connection constructor.

Parameters

array $options
\GuzzleHttp\Client $httpClient

setHttpClient()

setHttpClient(\GuzzleHttp\Client  $httpClient) 

Set the HTTP client for this connection

Parameters

\GuzzleHttp\Client $httpClient

getOption()

getOption(  $name) : mixed|null

Get an option

Parameters

$name

Returns

mixed|null

getResponseClass()

getResponseClass() : string

Returns

string

getErrorClass()

getErrorClass() : string

Returns

string

getUpdateMethod()

getUpdateMethod() : string

Returns

string

buildRequest()

buildRequest(string  $method, string  $url, array  $queryParams = array(), mixed|null  $body = null, array  $headers = array()) : \VivialConnect\Common\Request

Build a Request object.

This Request object will be passed through the middleware layers.

Parameters

string $method
string $url
array $queryParams
mixed|null $body
array $headers

Returns

\VivialConnect\Common\Request

send()

send(\VivialConnect\Common\Request  $request) : mixed|\Psr\Http\Message\ResponseInterface

Send a request.

Converts request to a PSR7 request to send to Guzzle.

Parameters

\VivialConnect\Common\Request $request

Returns

mixed|\Psr\Http\Message\ResponseInterface

get()

get(  $url, array  $queryParams = array(), array  $headers = array()) : \VivialConnect\Common\Response

Parameters

$url
array $queryParams
array $headers

Throws

\GuzzleHttp\Exception\ConnectException

Returns

\VivialConnect\Common\Response

post()

post(  $url, array  $queryParams = array(), null  $body = null, array  $headers = array()) : \VivialConnect\Common\Response

Parameters

$url
array $queryParams
null $body
array $headers

Throws

\GuzzleHttp\Exception\ConnectException

Returns

\VivialConnect\Common\Response

put()

put(  $url, array  $queryParams = array(), null  $body = null, array  $headers = array()) : \VivialConnect\Common\Response

Parameters

$url
array $queryParams
null $body
array $headers

Throws

\GuzzleHttp\Exception\ConnectException

Returns

\VivialConnect\Common\Response

patch()

patch(  $url, array  $queryParams = array(), null  $body = null, array  $headers = array()) : \VivialConnect\Common\Response

Parameters

$url
array $queryParams
null $body
array $headers

Throws

\GuzzleHttp\Exception\ConnectException

Returns

\VivialConnect\Common\Response

delete()

delete(  $url, array  $queryParams = array(),   $body = null, array  $headers = array()) : \VivialConnect\Common\Response

Parameters

$url
array $queryParams
$body
array $headers

Throws

\GuzzleHttp\Exception\ConnectException

Returns

\VivialConnect\Common\Response

head()

head(  $url, array  $queryParams = array(), array  $headers = array()) : \VivialConnect\Common\Response

Parameters

$url
array $queryParams
array $headers

Throws

\GuzzleHttp\Exception\ConnectException

Returns

\VivialConnect\Common\Response

getLog()

getLog() : array

Returns

array

initializeMiddlewareManager()

initializeMiddlewareManager() : void

Initialize middleware manager by instantiating all middlware classes and creating Onion instance.