Properties

$URL

$URL : string

Server host.

Type

string

$Headers

$Headers : array

Headers.

Type

array

$IdempotencyKey

$IdempotencyKey : string

Idempotence key.

Type

string

Methods

__construct()

__construct(  $URL,   $Headers = false) 

Constructor.

Parameters

$URL
$Headers

post_request()

post_request(  $Endpoint,   $Data = array()) 

Method sends POST request to REST server.

Parameters

$Endpoint
$Data

get_request()

get_request(string  $Endpoint) : mixed

Method sends GET request to REST server.

Parameters

string $Endpoint
  • Calling endpoint.

Returns

mixed —

Result of the remote call.

set_idempotence_key()

set_idempotence_key(string  $Key) 

Method sets idempotence key. To remove the key just call this method the second time with the '' parameter;

Parameters

string $Key
  • Idempotence key

get_http_code()

get_http_code(\array[string]  $Headers) : \number

Method returns HTTP response code.

Parameters

\array[string] $Headers
  • Response headers;

Returns

\number —

HTTP return code.

send_request()

send_request(array  $Options, string  $URL) : array<mixed,string>|array<mixed,\number>

Method send request to the URL.

Parameters

array $Options
  • Request options.
string $URL
  • Requesting URL.

Returns

array<mixed,string>|array<mixed,\number> —

Request body and request code.

dispatch_result()

dispatch_result(  $Options,   $URL) 

Method gets result and validates it.

Parameters

$Options
$URL

get_common_headers()

get_common_headers() 

Method returns common headers.

compile_post_headers()

compile_post_headers() 

Method compiles post headers.

compile_get_headers()

compile_get_headers() : string

Method compiles get headers.

Returns

string —

Headers for GET request.