UNPKG

@team-internet/apiconnector

Version:
265 lines (264 loc) 7.38 kB
import { Column } from "./column.js"; import { Record } from "./record.js"; /** * Response Class */ export declare class Response { /** * plain API response */ protected raw: string; /** * hash representation of plain API response */ protected hash: any; /** * The API Command used within this request */ private command; /** * Column names available in this responsse * NOTE: this includes also FIRST, LAST, LIMIT, COUNT, TOTAL * and maybe further specific columns in case of a list query */ private columnkeys; /** * Container of Column Instances */ private columns; /** * Record Index we currently point to in record list */ private recordIndex; /** * Record List (List of rows) */ private records; /** * Constructor * @param raw API plain response * @param cmd API command used within this request * @param ph placeholder array to get vars in response description dynamically replaced */ constructor(raw: string, cmd?: any, ph?: any); /** * Get API response code * @returns API response code */ getCode(): number; /** * Get API response description * @returns API response description */ getDescription(): string; /** * Get Plain API response * @returns Plain API response */ getPlain(): string; /** * Get Queuetime of API response * @returns Queuetime of API response */ getQueuetime(): number; /** * Get API response as Hash * @returns API response hash */ getHash(): any; /** * Get Runtime of API response * @returns Runtime of API response */ getRuntime(): number; /** * Check if current API response represents an error case * API response code is an 5xx code * @returns boolean result */ isError(): boolean; /** * Check if current API response represents a success case * API response code is an 2xx code * @returns boolean result */ isSuccess(): boolean; /** * Check if current API response represents a temporary error case * API response code is an 4xx code * @returns boolean result */ isTmpError(): boolean; /** * Check if current operation is returned as pending * @returns boolean result */ isPending(): boolean; /** * Add a column to the column list * @param key column name * @param data array of column data * @returns Current Response Instance for method chaining */ addColumn(key: string, data: string[]): Response; /** * Add a record to the record list * @param h row hash data * @returns Current Response Instance for method chaining */ addRecord(h: any): Response; /** * Get column by column name * @param key column name * @returns column instance or null if column does not exist */ getColumn(key: string): Column | null; /** * Get Data by Column Name and Index * @param colkey column name * @param index column data index * @returns column data at index or null if not found */ getColumnIndex(colkey: string, index: number): string | null; /** * Get Column Names * @returns Array of Column Names */ getColumnKeys(): string[]; /** * Get List of Columns * @returns Array of Columns */ getColumns(): Column[]; /** * Get Command used in this request * @returns command */ getCommand(): any; /** * Get Command used in this request in plain text format * @return command as plain text */ getCommandPlain(): string; /** * Get Page Number of current List Query * @returns page number or null in case of a non-list response */ getCurrentPageNumber(): number | null; /** * Get Record of current record index * @returns Record or null in case of a non-list response */ getCurrentRecord(): Record | null; /** * Get Index of first row in this response * @returns first row index */ getFirstRecordIndex(): number | null; /** * Get last record index of the current list query * @returns record index or null for a non-list response */ getLastRecordIndex(): number | null; /** * Get Response as List Hash including useful meta data for tables * @returns hash including list meta data and array of rows in hash notation */ getListHash(): any; /** * Get next record in record list * @returns Record or null in case there's no further record */ getNextRecord(): Record | null; /** * Get Page Number of next list query * @returns page number or null if there's no next page */ getNextPageNumber(): number | null; /** * Get the number of pages available for this list query * @returns number of pages */ getNumberOfPages(): number; /** * Get object containing all paging data * @returns paginator data */ getPagination(): any; /** * Get Page Number of previous list query * @returns page number or null if there's no previous page */ getPreviousPageNumber(): number | null; /** * Get previous record in record list * @returns Record or null if there's no previous record */ getPreviousRecord(): Record | null; /** * Get Record at given index * @param idx record index * @returns Record or null if index does not exist */ getRecord(idx: number): Record | null; /** * Get all Records * @returns array of records */ getRecords(): Record[]; /** * Get count of rows in this response * @returns count of rows */ getRecordsCount(): number; /** * Get total count of records available for the list query * @returns total count of records or count of records for a non-list response */ getRecordsTotalCount(): number; /** * Get limit(ation) setting of the current list query * This is the count of requested rows * @returns limit setting or count requested rows */ getRecordsLimitation(): number; /** * Check if this list query has a next page * @returns boolean result */ hasNextPage(): boolean; /** * Check if this list query has a previous page * @returns boolean result */ hasPreviousPage(): boolean; /** * Reset index in record list back to zero * @returns Current Response Instance for method chaining */ rewindRecordList(): Response; /** * Check if column exists in response * @param key column name * @returns boolean result */ private hasColumn; /** * Check if the record list contains a record for the * current record index in use * @returns boolean result */ private hasCurrentRecord; /** * Check if the record list contains a next record for the * current record index in use * @returns boolean result */ private hasNextRecord; /** * Check if the record list contains a previous record for the * current record index in use * @returns boolean result */ private hasPreviousRecord; }