master
in package
Class master
Table of Contents
Properties
Methods
- __destruct() : void
- Destructs the object and removes the token and host properties.
- get_tenants() : false|array<string|int, mixed>
- Retrieves the list of tenants from the API.
- build_data_files() : string
- Builds the data files for a multipart form request.
- checktokenandconnect() : bool
- Checks if the token is empty and connects if necessary.
- connect() : bool
- Connect to the specified host using the provided credentials and retrieve an access token.
- extractJSONValue() : mixed
- Extracts the value from a JSON object and optionally prints it.
- generate_tenantsarray() : array<string|int, mixed>
- Generates an array with the tenant information.
- isjson() : bool
- Determines whether the given value is a valid JSON string.
- send() : mixed
- Sends a request to the specified URI using the given method and data.
Properties
$host
private
string
$host
= ''
The hostname or IP address of the server.
$token
private
string
$token
= ''
The authentication token used for API requests.
Methods
__destruct()
Destructs the object and removes the token and host properties.
public
__destruct() : void
get_tenants()
Retrieves the list of tenants from the API.
public
get_tenants() : false|array<string|int, mixed>
Return values
false|array<string|int, mixed> —Returns an array containing the tenants' information if the token is not empty and the connection was successful, otherwise false.
build_data_files()
Builds the data files for a multipart form request.
private
build_data_files(string $bounds, string $fp, string $fname) : string
Parameters
- $bounds : string
-
The boundary string for the multipart form data
- $fp : string
-
The file path of the file to include in the form data
- $fname : string
-
The name of the file to include in the form data
Return values
string —The built data files as a string
checktokenandconnect()
Checks if the token is empty and connects if necessary.
private
checktokenandconnect() : bool
Return values
bool —Returns true if the token is not empty or if the connection was successful, otherwise false.
connect()
Connect to the specified host using the provided credentials and retrieve an access token.
private
connect() : bool
Return values
bool —True if the connection is successful and an access token is retrieved, false otherwise.
extractJSONValue()
Extracts the value from a JSON object and optionally prints it.
private
extractJSONValue(mixed $value[, bool $print = false ][, string $label = "" ]) : mixed
Parameters
- $value : mixed
-
The value to be extracted from the JSON object.
- $print : bool = false
-
Whether to print the extracted value or not. Default is false.
- $label : string = ""
-
The label to be displayed before the extracted value when printing. Default is an empty string.
Return values
mixed —The extracted value from the JSON object. If the value is not set, returns an empty string.
generate_tenantsarray()
Generates an array with the tenant information.
private
generate_tenantsarray(object $tn) : array<string|int, mixed>
Parameters
- $tn : object
-
The tenant object containing the information.
Return values
array<string|int, mixed> —An array containing the tenant information with the following keys:
- db: The name of the database.
- company: The name of the company.
- street: The street and house number of the address.
- zip: The zip code of the address.
- city: The city of the address.
- phone: The telephone number of the contact.
- fax: The fax number of the contact.
- homepage: The homepage URL of the contact.
- email: The email address of the contact.
isjson()
Determines whether the given value is a valid JSON string.
private
isjson(mixed $val) : bool
Parameters
- $val : mixed
-
The value to be checked.
Return values
bool —Returns true if the value is a valid JSON string, false otherwise.
send()
Sends a request to the specified URI using the given method and data.
private
send([string $uri = '' ][, string $method = '' ][, array<string|int, mixed>|string $data = array() ]) : mixed
Parameters
- $uri : string = ''
-
The URI to send the request to.
- $method : string = ''
-
The HTTP method to use (default is empty).
- $data : array<string|int, mixed>|string = array()
-
The data to send with the request (default is empty array).
Return values
mixed —Returns the response from the request, parsed as JSON, or false if there was an error.