class Client (View source)

CNR API Client

Properties

protected array<string, mixed> $context

context data for the client

mixed[] $settings

registrar api settings

protected string $socketURL

API connection url

protected SocketConfig $socketConfig

Object covering API connection data

protected bool $debugMode

activity flag for debug mode

protected string $ua

user agent

protected string[] $curlopts

additional curl options to use

protected LoggerInterface $logger

logger function name for debug mode

bool $isOTE

is connected to OT&E

protected CurlHandle|null $chandle

curl handle cache

Methods

__construct(string $path = "")

Constructor

$this
setCustomLogger(LoggerInterface $customLogger)

set custom logger to use instead of default one create your own class implementing \CNIC\LoggerInterface

$this
setDefaultLogger()

set default logger to use

$this
enableDebugMode()

Enable Debug Output to STDOUT

$this
disableDebugMode()

Disable Debug Output

string
getPOSTData(array $cmd, bool $secured = false)

Serialize given command for POST request including connection configuration data

string|null
getSession()

Get the API Session ID that is currently set

string
getURL()

Get the API connection url that is currently set

$this
setUserAgent(string $str, string $rv, array $modules = [])

Set a custom user agent (for platforms that use this SDK)

string
getUserAgent()

Get the user agent string

$this
setProxy(string $proxy = "")

Set proxy to use for API communication

string|null
getProxy()

Get proxy configuration for API communication

$this
setReferer(string $referer = "")

Set Referer to use for API communication

string|null
getReferer()

Get Referer configuration for API communication

string
getVersion()

Get the current module version

$this
setURL(string $value)

Set another connection url to be used for API communication

$this
setSession(string $value = "")

Set an API session id to be used for API communication

$this
setRemoteIPAddress(string $value = "")

Set an Remote IP Address to be used for API communication To be used in case you have an active ip filter setting.

$this
setCredentials(string $uid = "", string $pw = "")

Set Credentials to be used for API communication

$this
setRoleCredentials(string $uid = "", string $role = "", string $pw = "")

Set Credentials to be used for API communication

array
IDNConvert(array $domains)

Convert domain names to idn + punycode if necessary

array
autoIDNConvert(array $cmd)

Auto convert API command parameters to punycode, if necessary.

request(array $cmd = [])

Perform API request using the given command

Response|null
requestNextResponsePage(Response $rr)

Request the next page of list entries for the current list query Useful for tables

array
requestAllResponsePages(array $cmd)

Request all pages/entries for the given query command

void
close()

Close all curl handles

$this
setUserView(string $uid = "")

Set a data view to a given subuser

$this
useHighPerformanceConnectionSetup()

Activate High Performance Setup

$this
useOTESystem()

Set OT&E System for API communication

$this
useLIVESystem()

Set LIVE System for API communication (this is the default setting)

$this
setContext(array $context)

Set context data for the client (to be used in a custom logger to access additional data at logging time again) The use of this context data is optional and has no impact on the SDK behaviour itself.

Details

__construct(string $path = "")

Constructor

Parameters

string $path

Path to the configuration file

$this setCustomLogger(LoggerInterface $customLogger)

set custom logger to use instead of default one create your own class implementing \CNIC\LoggerInterface

Parameters

LoggerInterface $customLogger

Return Value

$this

$this setDefaultLogger()

set default logger to use

Return Value

$this

$this enableDebugMode()

Enable Debug Output to STDOUT

Return Value

$this

$this disableDebugMode()

Disable Debug Output

Return Value

$this

string getPOSTData(array $cmd, bool $secured = false)

Serialize given command for POST request including connection configuration data

Parameters

array $cmd

API command to encode

bool $secured

secure password (when used for output)

Return Value

string

string|null getSession()

Get the API Session ID that is currently set

Return Value

string|null

string getURL()

Get the API connection url that is currently set

Return Value

string

$this setUserAgent(string $str, string $rv, array $modules = [])

Set a custom user agent (for platforms that use this SDK)

Parameters

string $str

user agent label

string $rv

user agent revision

array $modules

further modules to add to user agent string, format: ["/", "/", ... ]

Return Value

$this

string getUserAgent()

Get the user agent string

Return Value

string

$this setProxy(string $proxy = "")

Set proxy to use for API communication

Parameters

string $proxy

proxy to use (optional, for reset)

Return Value

$this

string|null getProxy()

Get proxy configuration for API communication

Return Value

string|null

$this setReferer(string $referer = "")

Set Referer to use for API communication

Parameters

string $referer

Referer (optional, for reset)

Return Value

$this

string|null getReferer()

Get Referer configuration for API communication

Return Value

string|null

string getVersion()

Get the current module version

Return Value

string

$this setURL(string $value)

Set another connection url to be used for API communication

Parameters

string $value

API connection url to set

Return Value

$this

$this setSession(string $value = "")

Set an API session id to be used for API communication

Parameters

string $value

API session id (optional, for reset)

Return Value

$this

$this setRemoteIPAddress(string $value = "")

Set an Remote IP Address to be used for API communication To be used in case you have an active ip filter setting.

Parameters

string $value

Remote IP Address (optional, for reset)

Return Value

$this

Exceptions

Exception

$this setCredentials(string $uid = "", string $pw = "")

Set Credentials to be used for API communication

Parameters

string $uid

account name (optional, for reset)

string $pw

account password (optional, for reset)

Return Value

$this

$this setRoleCredentials(string $uid = "", string $role = "", string $pw = "")

Set Credentials to be used for API communication

Parameters

string $uid

account name (optional, for reset)

string $role

role user id (optional, for reset)

string $pw

role user password (optional, for reset)

Return Value

$this

array IDNConvert(array $domains)

Convert domain names to idn + punycode if necessary

Parameters

array $domains

list of domain names (or tlds)

Return Value

array

protected array autoIDNConvert(array $cmd)

Auto convert API command parameters to punycode, if necessary.

Parameters

array $cmd

API command

Return Value

array

Response request(array $cmd = [])

Perform API request using the given command

Parameters

array $cmd

API command to request (optional for session login)

Return Value

Response

Response|null requestNextResponsePage(Response $rr)

Request the next page of list entries for the current list query Useful for tables

Parameters

Response $rr

API Response of current page

Return Value

Response|null

Exceptions

Exception

array requestAllResponsePages(array $cmd)

Request all pages/entries for the given query command

Parameters

array $cmd

API list command to use

Return Value

array

void close()

Close all curl handles

Return Value

void

$this setUserView(string $uid = "")

Set a data view to a given subuser

Parameters

string $uid

subuser account name

Return Value

$this

$this useHighPerformanceConnectionSetup()

Activate High Performance Setup

Return Value

$this

$this useOTESystem()

Set OT&E System for API communication

Return Value

$this

$this useLIVESystem()

Set LIVE System for API communication (this is the default setting)

Return Value

$this

$this setContext(array $context)

Set context data for the client (to be used in a custom logger to access additional data at logging time again) The use of this context data is optional and has no impact on the SDK behaviour itself.

Will be forwarded either to the logger or to the Response object

Parameters

array $context

Return Value

$this