Documentation

tenants
in package

Class tenants

Tags
author

Lutz Boldt boldt@bitstore-online.de

Table of Contents

Properties

$host  : string
$pass  : string
Variable declaration for password.
$sla  : slarray
Variable declaration for slarray class.
$tid  : string
$token  : string
$user  : string

Methods

__construct()  : mixed
__destruct()  : void
Destructs the object and removes the token and host properties.
getarticles()  : array<string|int, mixed>|null
getcustomersorprospects()  : array<string|int, mixed>|null
Retrieves an array of customers or prospects based on the specified type.
writedelivery()  : bool
Writes a delivery for a specified tenant ID and duties.
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.
createjournalforinvoice()  : string|bool
Creates a journal for an delivery document.
createnewdelivery()  : string|bool
Creates a new delivery.
createnewposition()  : bool
Creates a new position in the document.
extractJSONValue()  : mixed
Extracts the value from a JSON object and optionally prints it.
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.
send_attachment()  : mixed
Sends an attachment using cURL.
sendattachment()  : bool
Sends an attachment for a journal entry.

Properties

$host

private string $host = ''

The hostname or IP address of the server.

$pass

Variable declaration for password.

private string $pass = ''

$tid

private string $tid = ''

The tenant ID.

$token

private string $token = ''

The authentication token used for API requests.

$user

private string $user = ''

The username for authentication.

Methods

__construct()

public __construct([string $ten = '' ]) : mixed
Parameters
$ten : string = ''

__destruct()

Destructs the object and removes the token and host properties.

public __destruct() : void

getarticles()

public getarticles() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

getcustomersorprospects()

Retrieves an array of customers or prospects based on the specified type.

public getcustomersorprospects([string $type = '2' ][, string $debug = '0' ]) : array<string|int, mixed>|null
Parameters
$type : string = '2'

The type of data to retrieve. Default is '1'. Acceptable values are '1' for prospects and '2' for customers.

$debug : string = '0'
Return values
array<string|int, mixed>|null

Returns an array of customer or prospect data if the retrieval was successful, otherwise null is returned.

writedelivery()

Writes a delivery for a specified tenant ID and duties.

public writedelivery(string $tid, array<string|int, mixed> $duties) : bool
Parameters
$tid : string

The ID of the tenant.

$duties : array<string|int, mixed>

The duties for the delivery.

Tags
throws
Exception
Return values
bool

Returns true if the delivery was written successfully, false otherwise.

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.

createjournalforinvoice()

Creates a journal for an delivery document.

private createjournalforinvoice(string $docnum, string $label, string $text) : string|bool
Parameters
$docnum : string

The document number for the invoice

$label : string

The label for the journal

$text : string

The text for the journal

Return values
string|bool

Returns the identifier of the created journal or false if the token check and connection failed

createnewdelivery()

Creates a new delivery.

private createnewdelivery(string $custno) : string|bool
Parameters
$custno : string

The Customer number

Return values
string|bool

The document number if a new delivery is created, otherwise false

createnewposition()

Creates a new position in the document.

private createnewposition(string $docnum, string $artnum, string $qty, string $name, string $additional, string $employee, string $memo) : bool
Parameters
$docnum : string

The document number to add the position to

$artnum : string

The article number for the position

$qty : string

The quantity of the position

$name : string

The name of the position

$additional : string

The additional description for the position

$employee : string

The employee number associated with the position

$memo : string

Any additional memo for the position

Return values
bool

Whether the position was successfully created or not

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.

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.

send_attachment()

Sends an attachment using cURL.

private send_attachment(string $uri, string $fp, string $fname) : mixed
Parameters
$uri : string

The URI to send the attachment to.

$fp : string

The file path of the attachment.

$fname : string

The file name of the attachment.

Return values
mixed

The response from the server, decoded as JSON.

sendattachment()

Sends an attachment for a journal entry.

private sendattachment(string $ji, string $filename) : bool
Parameters
$ji : string

The ID of the journal entry.

$filename : string

The file name of the attachment.

Return values
bool

Returns true if the attachment was sent successfully, false otherwise.


        
On this page

Search results