class Response extends AbstractResponse implements ResponseInterface (View source)

IBS Response

Extends the shared AbstractResponse and supplies only what differs for the IBS platform: the JSON-shaped response parsing (the translate() and populate() hooks), the code/description accessors and the flat (single-page) pagination model. The constructor, column/record bookkeeping, record-cursor navigation and derived pagination are inherited from AbstractResponse.

IBS does NOT provide the CNR-only telemetry/transient-status/list-hash capabilities, so those methods are simply absent here rather than present and throwing. They live on CNR\Response via CNIC\ExtendedResponseInterface; consumers narrow to that interface before using them.

Properties

protected array<string, string> $command

The API Command used within this request

from  AbstractResponse
protected string[] $sensitiveFields

IBS carries sensitive data under lower-/camel-case command keys.

protected string $raw

plain API response

from  AbstractResponse
protected array<string, mixed> $hash

hash representation of plain API response.

from  AbstractResponse
protected non-empty-string $paginationKeys

Regex for the count/metadata column keys IBS emits alongside a list.

protected string[] $columnKeys

Column names available in this response

from  AbstractResponse
protected ColumnInterface[] $columns

Container of Column Instances

from  AbstractResponse
protected array<string, int> $columnIndex

Map of column name to its index in the column/columnKeys lists.

from  AbstractResponse
protected int $recordIndex

Record Index we currently point to in record list

from  AbstractResponse
protected RecordInterface[] $records

Record List (List of rows)

from  AbstractResponse
protected array<string, mixed> $context

Context data for the response

from  AbstractResponse
protected string $requestUrl

API request url

from  AbstractResponse
protected ResponseParserInterface $parser

The parser turning the translated raw response into {$hash}.

from  AbstractResponse

Methods

__construct(string $raw, array $cmd = [], array $placeholders = [], array $context = [], ResponseParserInterface|null $parser = null)

Constructor

string
translate(string $raw, array $cmd, array $placeholders)

Translate the raw API response using the IBS translator.

void
populate()

Parse the translated response with the IBS parser and build the columns from it. The IBS parser needs the sanitized command (kept on $this->command by the shared constructor). IBS responses are flat key => value maps; each hash entry becomes a column, list values kept as-is and anything else wrapped into a single-cell list so the shared record assembly can iterate them.

newResponseParser()

Instantiate the response parser for this brand (Moniker inherits it).

newRecord(array $row)

Instantiate the record type for this brand.

array
sanitizeCommand(array $cmd)

Mask the brand's sensitive command keys (see $sensitiveFields) so their values can never be read back from the response (e.g. by custom loggers).

void
assembleRecords()

Assemble the record (row) list from the columns already added via addColumn(). Shared by all brands: each subclass populates the columns with its own Column type beforehand, while the row assembly is identical.

array
getContext()

Get context data for the response

string
getRequestURL()

Get Request URL

string
getPlain()

Get Plain API response

array
getHash()

Get API response as Hash

registerColumn(ColumnInterface $col)

Register an already-constructed column into the list bookkeeping.

addRecord(array $row)

Add a record to the record list

getColumn(string $columnName)

Get column by column name

mixed
getColumnIndex(string $columnName, int $recordIndex)

Get Data by Column Name and Index

array
getColumnKeys(bool $filterPaginationKeys = false)

Get Column Names

array
getColumns()

Get List of Columns

array
getCommand()

Get Command used in this request

string
getCommandPlain()

Get Command used in this request in plain text format

getCurrentRecord()

Get Record of current record index

getNextRecord()

Get next record in record list

int|null
getNextPageNumber()

Get Page Number of next list query

int
getNumberOfPages()

Get the number of pages available for this list query

array
getPagination()

Get object containing all paging data

int|null
getPreviousPageNumber()

Get Page Number of previous list query

getPreviousRecord()

Get previous record in record list

getRecord(int $recordIndex)

Get Record at given index

array
getRecords()

Get all Records

int
getRecordsCount()

Get count of rows in this response

rewindRecordList()

Reset index in record list back to zero

bool
hasCurrentRecord()

Check if the record list contains a record for the current record index in use

bool
hasNextRecord()

Check if the record list contains a next record for the current record index in use

bool
hasPreviousRecord()

Check if the record list contains a previous record for the current record index in use

string
getHashString(string $key, string $default = "")

Get a string value from the hash by key, returning a default if not found or not a string

array
getHashArray(string $key)

Get an array value from the hash by key, returning an empty array if not found or not an array. The twin of {getHashString()} for the nested blocks a brand's populate() reads (e.g. CNR's PROPERTY).

int
getCode()

Get API response code.

string
getDescription()

Get API response description

bool
isError()

Check if current API response represents an error case.

bool
isSuccess()

Check if current API response represents a success case.

addColumn(string $columnName, array $data)

Add a column to the column list

int|null
getCurrentPageNumber()

Get Page Number of current List Query

int|null
getFirstRecordIndex()

Get Index of first row in this response

int|null
getLastRecordIndex()

Get last record index of the current list query

int
getRecordsTotalCount()

Get total count of records available for the list query

int
getRecordsLimitation()

Get limit(ation) setting of the current list query This is the count of requested rows

bool
hasNextPage()

Check if this list query has a next page

bool
hasPreviousPage()

Check if this list query has a previous page

Details

__construct(string $raw, array $cmd = [], array $placeholders = [], array $context = [], ResponseParserInterface|null $parser = null)

Constructor

Parameters

string $raw

API plain response

array $cmd

API command used within this request

array $placeholders

vars the response description has dynamically replaced

array $context

context data for the response (for use in custom loggers etc., optional, has no impact on SDK behaviour)

ResponseParserInterface|null $parser

parser to use instead of the brand default (see newResponseParser())

protected string translate(string $raw, array $cmd, array $placeholders)

Translate the raw API response using the IBS translator.

Parameters

string $raw
array $cmd

API command used within this request

array $placeholders

Return Value

string

protected void populate()

Parse the translated response with the IBS parser and build the columns from it. The IBS parser needs the sanitized command (kept on $this->command by the shared constructor). IBS responses are flat key => value maps; each hash entry becomes a column, list values kept as-is and anything else wrapped into a single-cell list so the shared record assembly can iterate them.

Return Value

void

protected ResponseParserInterface newResponseParser()

Instantiate the response parser for this brand (Moniker inherits it).

protected RecordInterface newRecord(array $row)

Instantiate the record type for this brand.

Parameters

array $row

Return Value

RecordInterface

protected array sanitizeCommand(array $cmd)

Mask the brand's sensitive command keys (see $sensitiveFields) so their values can never be read back from the response (e.g. by custom loggers).

Matching is case-insensitive to stay robust against casing differences between what a brand documents and what it actually sends.

Parameters

array $cmd

API command used within this request

Return Value

array

protected void assembleRecords()

Assemble the record (row) list from the columns already added via addColumn(). Shared by all brands: each subclass populates the columns with its own Column type beforehand, while the row assembly is identical.

Return Value

void

array getContext()

Get context data for the response

Return Value

array

context data

string getRequestURL()

Get Request URL

Return Value

string

string getPlain()

Get Plain API response

Return Value

string

array getHash()

Get API response as Hash

Return Value

array

API response hash

protected AbstractResponse registerColumn(ColumnInterface $col)

Register an already-constructed column into the list bookkeeping.

The bookkeeping ($columns/$columnKeys/$columnIndex) is identical for every brand; what differs is the column's value type. Rather than a param-typed newColumn() factory — which cannot stay type-clean under PHPStan L9 / Psalm L1, because CNR columns take string[] while IBS columns take mixed[] and a shared factory would have to narrow one into the other — each brand's addColumn() builds its own correctly-typed Column locally and hands the finished instance here, so this shared helper never sees the brand types.

Parameters

ColumnInterface $col

Return Value

AbstractResponse

ResponseInterface addRecord(array $row)

Add a record to the record list

Parameters

array $row

Return Value

ResponseInterface

ColumnInterface|null getColumn(string $columnName)

Get column by column name

Parameters

string $columnName

Return Value

ColumnInterface|null

mixed getColumnIndex(string $columnName, int $recordIndex)

Get Data by Column Name and Index

Parameters

string $columnName
int $recordIndex

Return Value

mixed

array getColumnKeys(bool $filterPaginationKeys = false)

Get Column Names

Parameters

bool $filterPaginationKeys

Return Value

array

Array of Column Names

array getColumns()

Get List of Columns

Return Value

array

Array of Columns

array getCommand()

Get Command used in this request

Return Value

array command

string getCommandPlain()

Get Command used in this request in plain text format

Return Value

string

RecordInterface|null getCurrentRecord()

Get Record of current record index

Return Value

RecordInterface|null

RecordInterface|null getNextRecord()

Get next record in record list

Return Value

RecordInterface|null

int|null getNextPageNumber()

Get Page Number of next list query

Return Value

int|null

int getNumberOfPages()

Get the number of pages available for this list query

Return Value

int

array getPagination()

Get object containing all paging data

Return Value

array

paginator data

int|null getPreviousPageNumber()

Get Page Number of previous list query

Return Value

int|null

RecordInterface|null getPreviousRecord()

Get previous record in record list

Return Value

RecordInterface|null

RecordInterface|null getRecord(int $recordIndex)

Get Record at given index

Parameters

int $recordIndex

Return Value

RecordInterface|null

array getRecords()

Get all Records

Return Value

array

array of records

int getRecordsCount()

Get count of rows in this response

Return Value

int

ResponseInterface rewindRecordList()

Reset index in record list back to zero

Return Value

ResponseInterface

protected bool hasCurrentRecord()

Check if the record list contains a record for the current record index in use

Return Value

bool

protected bool hasNextRecord()

Check if the record list contains a next record for the current record index in use

Return Value

bool

protected bool hasPreviousRecord()

Check if the record list contains a previous record for the current record index in use

Return Value

bool

protected string getHashString(string $key, string $default = "")

Get a string value from the hash by key, returning a default if not found or not a string

Parameters

string $key
string $default

Return Value

string

protected array getHashArray(string $key)

Get an array value from the hash by key, returning an empty array if not found or not an array. The twin of {getHashString()} for the nested blocks a brand's populate() reads (e.g. CNR's PROPERTY).

Parameters

string $key

Return Value

array

int getCode()

Get API response code.

IBS returns a numeric "code" on some responses even though it is not part of the public API documentation, e.g. for these requests:

  • /Domain/Info?domain=noexistingdomain.com&...
  • /unknown/path?... Two shapes occur: a top-level "code", and — since the switch to ResponseFormat=JSON — a per-product code nested under product[0].code (earlier "product_0_code", RTLDEV-16781). When present the code is returned as-is; otherwise it is derived from the status: 200 for a success, 500 for an error (see isError()).

Return Value

int

string getDescription()

Get API response description

Return Value

string

bool isError()

Check if current API response represents an error case.

FAILURE is the only IBS status that signals an error. Every other status means the command itself succeeded — "SUCCESS" for ordinary commands, and for Domain/Check specifically "AVAILABLE"/"UNAVAILABLE", which report the domain's registrability rather than a failure. Missing/empty statuses are normalised to FAILURE upstream by ResponseTranslator's fallback templates.

Return Value

bool

bool isSuccess()

Check if current API response represents a success case.

The complement of isError(): any non-FAILURE status (SUCCESS, AVAILABLE, UNAVAILABLE, ...) is a success. See isError() for why FAILURE is the sole error signal.

Return Value

bool

ResponseInterface addColumn(string $columnName, array $data)

Add a column to the column list

IBS responses are JSON, so column values are arbitrary (nested arrays and objects included) and the shared CNIC\Column is used as-is. CNR narrows the same class to string values; that divergence in the constructor value type is why a param-typed newColumn() factory would not stay type-clean, and why this builds its column locally and hands the finished instance to the shared registerColumn() bookkeeping — see registerColumn().

Parameters

string $columnName
array $data

array of column data

Return Value

ResponseInterface

int|null getCurrentPageNumber()

Get Page Number of current List Query

Return Value

int|null

int|null getFirstRecordIndex()

Get Index of first row in this response

Return Value

int|null

int|null getLastRecordIndex()

Get last record index of the current list query

Return Value

int|null

int getRecordsTotalCount()

Get total count of records available for the list query

Return Value

int

int getRecordsLimitation()

Get limit(ation) setting of the current list query This is the count of requested rows

Return Value

int

bool hasNextPage()

Check if this list query has a next page

Return Value

bool

bool hasPreviousPage()

Check if this list query has a previous page

Return Value

bool