abstract class AbstractClient (View source)

Shared foundation for all registrar API clients.

Concrete subclasses provide the request() implementation, the default logger, and the appropriate SocketConfig subtype.

Constants

private VERSION

Current module version.

Kept in sync automatically by semantic-release — see .releaserc.json.

Properties

protected array<string, mixed> $context

context data for the client

protected string $socketURL

API connection url

protected AbstractSocketConfig $socketConfig

Object covering API connection data

protected bool $debugMode

activity flag for debug mode

protected string $ua

user agent

protected array<int, mixed> $curlopts

additional curl options to use

protected LoggerInterface $logger

logger instance for debug mode

protected bool $isOTE

is connected to OT&E

protected HttpTransport $transport

HTTP transport layer

Methods

__construct()

Constructor

request(array $cmd = [])

Perform API request using the given command.

newSocketConfig()

Instantiate the SocketConfig for this client.

setDefaultLogger()

Set the default logger for this client.

setCustomLogger(LoggerInterface $customLogger)

Set custom logger to use instead of the default one.

enableDebugMode()

Enable debug output to STDOUT

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

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

setProxy(string $proxy = "")

Set proxy to use for API communication

string|null
getProxy()

Get proxy configuration for API communication

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

setURL(string $value)

Set another connection url to be used for API communication

setSession(string $value = "")

Set an API session id to be used for API communication

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

Set Credentials to be used for API communication

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

Set Role Credentials to be used for API communication

useHighPerformanceConnectionSetup()

Activate High Performance Setup

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.

array
executeCurl(string $data, array $cfg, array $extraCurlOpts = [])

Delegate cURL execution to the transport layer.

void
close()

Close all cURL connections

string
getLiveUrl()

Get LIVE system URL

bool
isOTE()

Check whether the client is connected to the OT&E system

useOTESystem()

Set OT&E System for API communication

useLIVESystem()

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

setContext(array $context)

Set context data for the client

Details

__construct()

Constructor

abstract ResponseInterface request(array $cmd = [])

Perform API request using the given command.

Each client implements its own command serialisation and response type.

Parameters

array $cmd

API command

Return Value

ResponseInterface

abstract protected AbstractSocketConfig newSocketConfig()

Instantiate the SocketConfig for this client.

Subclasses return their own SocketConfig subtype.

Return Value

AbstractSocketConfig

abstract AbstractClient setDefaultLogger()

Set the default logger for this client.

Subclasses instantiate the appropriate Logger implementation.

Return Value

AbstractClient

AbstractClient setCustomLogger(LoggerInterface $customLogger)

Set custom logger to use instead of the default one.

Create your own class implementing \CNIC\LoggerInterface.

Parameters

LoggerInterface $customLogger

Return Value

AbstractClient

AbstractClient enableDebugMode()

Enable debug output to STDOUT

Return Value

AbstractClient

AbstractClient disableDebugMode()

Disable debug output

Return Value

AbstractClient

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

AbstractClient 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

Return Value

AbstractClient

string getUserAgent()

Get the user agent string

Return Value

string

AbstractClient setProxy(string $proxy = "")

Set proxy to use for API communication

Parameters

string $proxy

proxy to use (optional, for reset)

Return Value

AbstractClient

string|null getProxy()

Get proxy configuration for API communication

Return Value

string|null

AbstractClient setReferer(string $referer = "")

Set Referer to use for API communication

Parameters

string $referer

Referer (optional, for reset)

Return Value

AbstractClient

string|null getReferer()

Get Referer configuration for API communication

Return Value

string|null

string getVersion()

Get the current module version

Return Value

string

AbstractClient setURL(string $value)

Set another connection url to be used for API communication

Parameters

string $value

API connection url to set

Return Value

AbstractClient

AbstractClient 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

AbstractClient

AbstractClient 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

AbstractClient

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

Set Role 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

AbstractClient

AbstractClient useHighPerformanceConnectionSetup()

Activate High Performance Setup

Return Value

AbstractClient

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

protected array executeCurl(string $data, array $cfg, array $extraCurlOpts = [])

Delegate cURL execution to the transport layer.

Parameters

string $data

serialized POST payload

array $cfg

connection config

array $extraCurlOpts

additional cURL options merged over the defaults

Return Value

array

[rawResponse, errorMessage|null]

void close()

Close all cURL connections

Return Value

void

string getLiveUrl()

Get LIVE system URL

Return Value

string

bool isOTE()

Check whether the client is connected to the OT&E system

Return Value

bool

AbstractClient useOTESystem()

Set OT&E System for API communication

Return Value

AbstractClient

AbstractClient useLIVESystem()

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

Return Value

AbstractClient

AbstractClient setContext(array $context)

Set context data for the client

Parameters

array $context

Return Value

AbstractClient