Documentation ¶
Overview ¶
Package response provides extended functionality to handle API response data
Index ¶
- type Response
- func (r *Response) AddColumn(key string, data []string) *Response
- func (r *Response) AddRecord(h map[string]string) *Response
- func (r *Response) GetCode() int
- func (r *Response) GetColumn(key string) *column.Column
- func (r *Response) GetColumnIndex(key string, index int) (string, error)
- func (r *Response) GetColumnKeys() []string
- func (r *Response) GetColumns() []column.Column
- func (r *Response) GetCommand() map[string]string
- func (r *Response) GetCommandPlain() string
- func (r *Response) GetCurrentPageNumber() (int, error)
- func (r *Response) GetCurrentRecord() *record.Record
- func (r *Response) GetDescription() string
- func (r *Response) GetFirstRecordIndex() (int, error)
- func (r *Response) GetHash() map[string]interface{}
- func (r *Response) GetLastRecordIndex() (int, error)
- func (r *Response) GetListHash() map[string]interface{}
- func (r *Response) GetNextPageNumber() (int, error)
- func (r *Response) GetNextRecord() *record.Record
- func (r *Response) GetNumberOfPages() int
- func (r *Response) GetPagination() map[string]interface{}
- func (r *Response) GetPlain() string
- func (r *Response) GetPreviousPageNumber() (int, error)
- func (r *Response) GetPreviousRecord() *record.Record
- func (r *Response) GetQueuetime() float64
- func (r *Response) GetRecord(idx int) *record.Record
- func (r *Response) GetRecords() []record.Record
- func (r *Response) GetRecordsCount() int
- func (r *Response) GetRecordsLimitation() int
- func (r *Response) GetRecordsTotalCount() int
- func (r *Response) GetRuntime() float64
- func (r *Response) HasNextPage() bool
- func (r *Response) HasPreviousPage() bool
- func (r *Response) IsError() bool
- func (r *Response) IsPending() bool
- func (r *Response) IsSuccess() bool
- func (r *Response) IsTmpError() bool
- func (r *Response) RewindRecordList() *Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Response ¶
type Response struct { Raw string Hash map[string]interface{} // contains filtered or unexported fields }
Response is a struct used to cover basic functionality to work with API response data (or hardcoded API response data).
func NewResponse ¶
NewResponse creates a new Response object. It takes a raw string, a command map, and optional placeholder maps as parameters. The function replaces the "PASSWORD" value in the command map with "***" if it exists. It then translates the raw string using the command and placeholder maps. The function initializes a new Response object with the translated raw string, a hash value, the command map, empty column keys and columns, a record index of 0, and an empty records slice. If the hash value contains a "PROPERTY" key, the function adds columns and records to the Response object based on the values in the "PROPERTY" map. The function returns the newly created Response object.
func (*Response) GetCode ¶
GetCode returns the code associated with the response. If the response does not have a code or if the code is not a valid integer, it returns the default code.
The code is retrieved from the response's hash, which is a map[string]interface{}. The code value is expected to be stored under the key "CODE" as a string. If the code value is not found or is not a string, the default code is returned.
If an error occurs while converting the code string to an integer, the default code is returned and the error is logged or handled appropriately.
Returns: - int: The code associated with the response.
func (*Response) GetColumnIndex ¶
GetColumnIndex method to get data by column name and index
func (*Response) GetColumnKeys ¶
GetColumnKeys method to get the list of column names
func (*Response) GetColumns ¶
GetColumns method to get the list of columns
func (*Response) GetCommand ¶
GetCommand method to get the underlying API command
func (*Response) GetCommandPlain ¶
GetCommandPlain method to get the underlying API command in plain text
func (*Response) GetCurrentPageNumber ¶
GetCurrentPageNumber method to get the page number of current list query
func (*Response) GetCurrentRecord ¶
GetCurrentRecord method to get record of current record index
func (*Response) GetDescription ¶
GetDescription method to return the API response description
func (*Response) GetFirstRecordIndex ¶
GetFirstRecordIndex method to get index of first row
func (*Response) GetLastRecordIndex ¶
GetLastRecordIndex method to get last record index of the current list query
func (*Response) GetListHash ¶
GetListHash method to get Response as List Hash including useful meta data for tables
func (*Response) GetNextPageNumber ¶
GetNextPageNumber method to get Page Number of next list query
func (*Response) GetNextRecord ¶
GetNextRecord method to get next record in record list
func (*Response) GetNumberOfPages ¶
GetNumberOfPages method to get the number of pages available for this list query
func (*Response) GetPagination ¶
GetPagination method to get pagination data; useful for table pagination
func (*Response) GetPreviousPageNumber ¶
GetPreviousPageNumber method to get Page Number of previous list query
func (*Response) GetPreviousRecord ¶
GetPreviousRecord method to get previous record in record list
func (*Response) GetQueuetime ¶
GetQueuetime method to return API response queuetime
func (*Response) GetRecords ¶
GetRecords method to get all records
func (*Response) GetRecordsCount ¶
GetRecordsCount method to get count of rows in this response
func (*Response) GetRecordsLimitation ¶
GetRecordsLimitation method to get limit(ation) setting of the current list query
func (*Response) GetRecordsTotalCount ¶
GetRecordsTotalCount method to get total count of records available for the list query
func (*Response) GetRuntime ¶
GetRuntime method to return API response runtime
func (*Response) HasNextPage ¶
HasNextPage method to check if this list query has a next page
func (*Response) HasPreviousPage ¶
HasPreviousPage method to check if this list query has a previous page
func (*Response) IsTmpError ¶
IsTmpError method to check if current API response represents a temporary error case
func (*Response) RewindRecordList ¶
RewindRecordList method to reset index in record list back to zero