\Finecho\Logistics\TraitsHasHttpRequest

Trait HasHttpRequest.

Summary

Methods
Properties
Constants
No public methods found
No public properties found
No constants found
get()
post()
postJson()
request()
getBaseOptions()
getHttpClient()
unwrapResponse()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

get()

get(string  $endpoint, array  $query = [], array  $headers = []) : array

Make a get request.

Parameters

string $endpoint
array $query
array $headers

Returns

array —

post()

post(string  $endpoint, array  $params = [], array  $headers = []) : array

Make a post request.

Parameters

string $endpoint
array $params
array $headers

Returns

array —

postJson()

postJson( $endpoint, array  $params = [], array  $headers = []) : array

Make a post request with json params.

Parameters

$endpoint
array $params
array $headers

Returns

array —

request()

request(string  $method, string  $endpoint, array  $options = []) : array

Make a http request.

Parameters

string $method
string $endpoint
array $options

http://docs.guzzlephp.org/en/latest/request-options.html

Returns

array —

getBaseOptions()

getBaseOptions() : array

Return base Guzzle options.

Returns

array —

getHttpClient()

getHttpClient(array  $options = []) : \GuzzleHttp\Client

Return http client.

Parameters

array $options

Returns

\GuzzleHttp\Client —

unwrapResponse()

unwrapResponse(\Psr\Http\Message\ResponseInterface  $response) : \Psr\Http\Message\ResponseInterface|array|string

Convert response contents to json.

Parameters

\Psr\Http\Message\ResponseInterface $response

Returns

\Psr\Http\Message\ResponseInterface|array|string —