Response
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
Constructor
Translate the raw API response using the IBS translator.
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.
Instantiate the response parser for this brand (Moniker inherits it).
Instantiate the record type for this brand.
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).
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.
Register an already-constructed column into the list bookkeeping.
Get Data by Column Name and Index
Get Command used in this request in plain text format
Check if the record list contains a record for the current record index in use
Check if the record list contains a next record for the current record index in use
Check if the record list contains a previous record for the current record index in use
Get a string value from the hash by key, returning a default if not found or not a string
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).
Get API response code.
Get API response description
Check if current API response represents an error case.
Check if current API response represents a success case.
Add a column to the column list
Get Page Number of current List Query
Get Index of first row in this response
Get last record index of the current list query
Get total count of records available for the list query
Get limit(ation) setting of the current list query This is the count of requested rows
Check if this list query has a next page
Check if this list query has a previous page
Details
__construct(string $raw, array $cmd = [], array $placeholders = [], array $context = [], ResponseParserInterface|null $parser = null)
Constructor
protected string
translate(string $raw, array $cmd, array $placeholders)
Translate the raw API response using the IBS translator.
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.
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.
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.
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.
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
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.
ResponseInterface
addRecord(array $row)
Add a record to the record list
ColumnInterface|null
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
RecordInterface|null
getCurrentRecord()
Get Record of current record index
RecordInterface|null
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
RecordInterface|null
getPreviousRecord()
Get previous record in record list
RecordInterface|null
getRecord(int $recordIndex)
Get Record at given index
array
getRecords()
Get all Records
int
getRecordsCount()
Get count of rows in this response
ResponseInterface
rewindRecordList()
Reset index in record list back to zero
protected bool
hasCurrentRecord()
Check if the record list contains a record for the current record index in use
protected bool
hasNextRecord()
Check if the record list contains a next record for the current record index in use
protected bool
hasPreviousRecord()
Check if the record list contains a previous record for the current record index in use
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
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).
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()).
string
getDescription()
Get API response description
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.
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.
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().
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