PHP SDK by CNIC

ResponseTemplateManager
in package

FinalYes

IBS ResponseTemplateManager

Tags
final

Table of Contents

Properties

$templates  : array<string|int, string>
template container

Methods

addTemplate()  : self
Add response template to template container
generateTemplate()  : string
Generate API response template string for given status and description
getTemplate()  : Response
Get response template instance from template container
getTemplates()  : array<string|int, mixed>
Return all available response templates
hasTemplate()  : bool
Check if given template exists in template container
isTemplateMatchHash()  : bool
Check if given API response hash matches a given template by code and description
isTemplateMatchPlain()  : bool
Check if given API plain response matches a given template by code and description

Properties

$templates

template container

public static array<string|int, string> $templates = ["403" => "status=FAILURE\r\nmessage=403 Forbidden\r\n", "404" => "status=FAILURE\r\nmessage=421 Page not found\r\n", "500" => "status=FAILURE\r\nmessage=500 Internal server error\r\n", "empty" => "status=FAILURE\r\nmessage=423 Empty API response. Probably unreachable API end point {CONNECTION_URL}\r\n", "error" => "status=FAILURE\r\nmessage=421 Command failed due to server error. Please retry.\r\n", "httperror" => "status=FAILURE\r\nmessage=421 Command failed due to HTTP communication error{HTTPERROR}.\r\n", "invalid" => "status=FAILURE\r\nmessage=423 Invalid API response. Contact Support\r\n", "nocurl" => "status=FAILURE\r\nmessage=423 API access error: curl_init failed\r\n", "notfound" => "status=FAILURE\r\nmessage=500 Response Template not found\r\n", "unauthorized" => "status=FAILURE\r\nmessage=530 Unauthorized\r\n"]

Methods

addTemplate()

Add response template to template container

public static addTemplate(string $id, string $plain[, string|null $descr = null ]) : self
Parameters
$id : string

template id

$plain : string

API plain response or API response code (when providing $descr)

$descr : string|null = null

API response description

Return values
self

generateTemplate()

Generate API response template string for given status and description

public static generateTemplate(string $status, string $description) : string
Parameters
$status : string

API response code

$description : string

API response description

Return values
string

getTemplates()

Return all available response templates

public static getTemplates() : array<string|int, mixed>
Return values
array<string|int, mixed>

hasTemplate()

Check if given template exists in template container

public static hasTemplate(string $id) : bool
Parameters
$id : string

template id

Return values
bool

isTemplateMatchHash()

Check if given API response hash matches a given template by code and description

public static isTemplateMatchHash(array<string|int, string> $tpl, string $id) : bool
Parameters
$tpl : array<string|int, string>

api response hash

$id : string

template id

Return values
bool

isTemplateMatchPlain()

Check if given API plain response matches a given template by code and description

public static isTemplateMatchPlain(string $plain, string $id) : bool
Parameters
$plain : string

API plain response

$id : string

template id

Return values
bool

        
On this page

Search results