Properties

$Service

$Service : 

Service name.

Type

$Login

$Login : 

Last logged in user.

This is used for performance improvements in ServiceClient::login_as method. For optimisation purposes only! Do not use in the client code.

Type

$SessionId

$SessionId : 

Session id.

Type

$URL

$URL : string

Server host.

Type

string

$Headers

$Headers : array

Headers.

Type

array

$IdempotencyKey

$IdempotencyKey : string

Idempotence key.

Type

string

Methods

get_session_id()

get_session_id() 

Returning session.

__construct()

__construct(string  $Service, string  $Login = false, string  $Password = false, array  $Headers = false) 

Constructor.

Parameters

string $Service
  • Service URL or service name;
string $Login
  • Login;
string $Password
  • Password;
array $Headers
  • 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

connect()

connect(string  $Login, string  $Password) 

Method connects to the REST server via login and password pair.

Parameters

string $Login
  • Login;
string $Password
  • Password;

set_token()

set_token(string  $Token, string  $Login = '') 

Method sets token.

Parameters

string $Token
  • Access token;
string $Login
  • User login.

get_token()

get_token() : string

Method returns token.

Returns

string —

Session id.

get_self_id()

get_self_id() : string

Method returns self id of the session.

Returns

string —

Session user's id.

get_self_login()

get_self_login() : string

Method returns self login of the session.

Returns

string —

Session user's login.

get_self_user()

get_self_user() : array

Method returns self user of the session.

Returns

array —

Session user.

login_as()

login_as(string  $User, string  $Field = 'id') 

Method logins under another user. $Field must be 'id' or 'login'.

Parameters

string $User
  • User credentials.
string $Field
  • Field name for credentials.

get_stored_login()

get_stored_login() : string

Method returns stored login.

Returns

string —

Stored login.

dispatch_result()

dispatch_result(  $Options,   $URL) 

Method gets result and validates it.

Parameters

$Options
$URL

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.

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.

get_common_headers()

get_common_headers() 

Method returns common headers.

create_file_field()

create_file_field(string  $Path, string  $Name) : array

Method compiles file field.

Parameters

string $Path
  • Path to file;
string $Name
  • Field name;

Returns

array —

Field data.

is_file()

is_file(mixed  $Value) : boolean

Checking if we are uploading a file.

Parameters

mixed $Value
  • Uploading data.

Returns

boolean —

True if the $Value is the uploading file. False otherwise.

pretransform_data()

pretransform_data(string  $Data) : string

Transforming data before sending to service.

Parameters

string $Data
  • data to be transformed.

Returns

string —

Transformed data.