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

__construct()

__construct(  $URL,   $Headers = false) 

Constructor.

Parameters

$URL
$Headers

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.

get_session_id()

get_session_id() 

Returning session.

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_all()

get_all(array  $Filter = false, array  $Order = false) : array

Method returns records of the user's domain.

Parameters

array $Filter
  • Filtering settings.
array $Order
  • Sorting settings.

Returns

array —

List of records.

get_list()

get_list(integer  $From, integer  $Limit = 1000000000, integer  $CrossDomain, array  $Filter = false, array  $Order = false) : array

Method returns some records of the user's domain.

Parameters

integer $From
  • The beginnig of the fetching sequence.
integer $Limit
  • Size of the fetching sequence.
integer $CrossDomain
  • Cross domain security settings.
array $Filter
  • Filtering settings.
array $Order
  • Sorting settings.

Returns

array —

List of records.

get_records_by()

get_records_by(array  $Filter, integer  $CrossDomain) : array

Method returns all records by filter.

Parameters

array $Filter
  • Filtering settings.
integer $CrossDomain
  • Cross domain security settings.

Returns

array —

List of records.

get_by_id()

get_by_id(integer  $id, \number  $CrossDomain) : object

Method returns record by it's id.

Parameters

integer $id
  • Id of the fetching record.
\number $CrossDomain
  • Domain id.

Returns

object —

fetched record.

get_by_ids_array()

get_by_ids_array(array  $ids, \number  $CrossDomain) : array

Method returns records by their ids.

Parameters

array $ids
  • List of ids.
\number $CrossDomain
  • Domain id.

Returns

array —

Fetched records.

create()

create(array  $Data) : integer

Method creates new record.

Parameters

array $Data
  • data for creating record.

Returns

integer —

id of the created record.

update()

update(  $id,   $Data,   $CrossDomain) 

Method updates new record.

Parameters

$id
$Data
$CrossDomain

lock()

lock() 

Method locks table.

unlock()

unlock() 

Method unlocks table.

get_remote_creation_form()

get_remote_creation_form(  $Options) 

Method returns creation form's fields.

Parameters

$Options

get_remote_creation_form_fields()

get_remote_creation_form_fields() 

Method returns creation form's fields.

get_remote_creation_form_fields_json()

get_remote_creation_form_fields_json() 

Method returns creation form's fields in JSON format.

new_records_since()

new_records_since(\datetime  $Date) : array

Method returns all records created since $Date.

Parameters

\datetime $Date
  • Start of the period.

Returns

array —

List of records created since $Date.

records_count()

records_count() : array

Method returns count off records.

Returns

array —

List of records created since $Date.

last_records()

last_records(integer  $Count, array  $Filter) : array

Method returns last $Count records.

Parameters

integer $Count
  • Amount of records to be fetched.
array $Filter
  • Filter data.

Returns

array —

$Count of last created records.

delete()

delete(integer  $id, integer  $CrossDomain) : string

Method deletes record with $id.

Parameters

integer $id
  • Id of the deleting record.
integer $CrossDomain
  • Break domain's bounds or not.

Returns

string —

Result of the deletion.

records_count_by_field()

records_count_by_field(string  $Field, array  $Filter = false) : array

Method returns count off records.

Parameters

string $Field
  • Field for grouping.
array $Filter
  • Filtering settings.

Returns

array —

List of records created since $Date.

delete_filtered()

delete_filtered(integer  $CrossDomain, array  $Filter = false) 

Method deletes records by filter.

Parameters

integer $CrossDomain
  • Cross domain security settings.
array $Filter
  • Filtering settings.

instance()

instance(string  $Service, string  $Token) : \CRUDServiceClient

Method creates instance if the CRUDServiceClient class.

Parameters

string $Service
  • Service to be connected to.
string $Token
  • Connection token.

Returns

\CRUDServiceClient

Instance of the CRUDServiceClient class.

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.

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.

urlencode_arr()

urlencode_arr(  $Arr) 

Url encoding all values of array.

Parameters

$Arr

get_compiled_filter()

get_compiled_filter(array  $Filter, boolean  $Amp = true) : string

Method returns compiled filter string.

Parameters

array $Filter
  • Filter.
boolean $Amp
  • Do we need &.

Returns

string —

Compiled filter.

get_compiled_order()

get_compiled_order(array  $Order) : string

Method compiles sorting settings.

Parameters

array $Order
  • Sorting settings. For example [ 'field' => 'id' , 'order' => 'ASC' ].

Returns

string —

Compiled sorting settings.