Documentation
¶
Overview ¶
Package hashresponse covers all functionality to handle an API response in hash format and provides access to a response template manager to cover http error cases etc. with API response format.
Index ¶
- type HashResponse
- func (hr *HashResponse) Code() int
- func (hr *HashResponse) Count() int
- func (hr *HashResponse) Description() string
- func (hr *HashResponse) DisableColumnFilter()
- func (hr *HashResponse) EnableColumnFilter(pattern string)
- func (hr *HashResponse) First() int
- func (hr *HashResponse) GetColumn(columnid string) []string
- func (hr *HashResponse) GetColumnIndex(columnid string, index int) (string, error)
- func (hr *HashResponse) GetColumnKeys() []string
- func (hr *HashResponse) GetHash() map[string]interface{}
- func (hr *HashResponse) GetPagination() map[string]int
- func (hr *HashResponse) GetRaw() string
- func (hr *HashResponse) GetRawByFilter(noColumnFilter bool) string
- func (hr *HashResponse) IsError() bool
- func (hr *HashResponse) IsSuccess() bool
- func (hr *HashResponse) IsTmpError() bool
- func (hr *HashResponse) Last() int
- func (hr *HashResponse) Limit() int
- func (hr *HashResponse) Nextpage() int
- func (hr *HashResponse) Page() int
- func (hr *HashResponse) Pages() int
- func (hr *HashResponse) Parse(r string) map[string]interface{}
- func (hr *HashResponse) Prevpage() int
- func (hr *HashResponse) Queuetime() float64
- func (hr *HashResponse) Runtime() float64
- func (hr *HashResponse) Serialize(hash map[string]interface{}) string
- func (hr *HashResponse) Total() int
- type Templates
- func (dr *Templates) Get(templateid string) string
- func (dr *Templates) GetAll() map[string]string
- func (dr *Templates) GetParsed(templateid string) map[string]interface{}
- func (dr *Templates) Match(r string, templateid string) bool
- func (dr *Templates) MatchParsed(r map[string]interface{}, templateid string) bool
- func (dr *Templates) Set(templateid string, templatecontent string)
- func (dr *Templates) SetParsed(templateid string, templatecontent map[string]interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashResponse ¶
type HashResponse struct {
// contains filtered or unexported fields
}
HashResponse class provides basic functionality to work with API responses.
func NewHashResponse ¶
func NewHashResponse(r string) *HashResponse
NewHashResponse represents the constructor for struct HashResponse. Provide the raw api response string as parameter.
func (*HashResponse) Code ¶
func (hr *HashResponse) Code() int
Code method to access the api response code
func (*HashResponse) Count ¶
func (hr *HashResponse) Count() int
Count method to access the pagination data "count" Represents the count of rows returned in the current response
func (*HashResponse) Description ¶
func (hr *HashResponse) Description() string
Description method to access the api response description
func (*HashResponse) DisableColumnFilter ¶
func (hr *HashResponse) DisableColumnFilter()
DisableColumnFilter method to turn of column filter
func (*HashResponse) EnableColumnFilter ¶
func (hr *HashResponse) EnableColumnFilter(pattern string)
EnableColumnFilter method to set a column filter
func (*HashResponse) First ¶
func (hr *HashResponse) First() int
First method to access the pagination data "first". Represents the row index of 1st row of the current response of the whole result set
func (*HashResponse) GetColumn ¶
func (hr *HashResponse) GetColumn(columnid string) []string
GetColumn method to get the full column data for the given column id
func (*HashResponse) GetColumnIndex ¶
func (hr *HashResponse) GetColumnIndex(columnid string, index int) (string, error)
GetColumnIndex method to get a response data field by column id and index
func (*HashResponse) GetColumnKeys ¶
func (hr *HashResponse) GetColumnKeys() []string
GetColumnKeys method to get a full list available columns in api response
func (*HashResponse) GetHash ¶
func (hr *HashResponse) GetHash() map[string]interface{}
GetHash method to return the parsed api response
func (*HashResponse) GetPagination ¶
func (hr *HashResponse) GetPagination() map[string]int
GetPagination method to return all pagination data at once
func (*HashResponse) GetRaw ¶
func (hr *HashResponse) GetRaw() string
GetRaw method to return the api raw (but filtered - in case of useColRegexp) response data
func (*HashResponse) GetRawByFilter ¶
func (hr *HashResponse) GetRawByFilter(noColumnFilter bool) string
GetRawByFilter method to return the api raw response data. Use noColumnFilter parameter to explicitly suppress a current active column filter.
func (*HashResponse) IsError ¶
func (hr *HashResponse) IsError() bool
IsError method to check if the api response represents an error case
func (*HashResponse) IsSuccess ¶
func (hr *HashResponse) IsSuccess() bool
IsSuccess method to check if the api response represents a success case
func (*HashResponse) IsTmpError ¶
func (hr *HashResponse) IsTmpError() bool
IsTmpError method to check if the api response represents a temporary error case
func (*HashResponse) Last ¶
func (hr *HashResponse) Last() int
Last method to access the pagination data "last" Represents the row index of last row of the current response of the whole result set
func (*HashResponse) Limit ¶
func (hr *HashResponse) Limit() int
Limit method to access the pagination data "limit" represents the limited amount of rows requested to be returned
func (*HashResponse) Nextpage ¶
func (hr *HashResponse) Nextpage() int
Nextpage method to get the next page number
func (*HashResponse) Page ¶
func (hr *HashResponse) Page() int
Page method to return the number of the current page
func (*HashResponse) Pages ¶
func (hr *HashResponse) Pages() int
Pages method to return the amount of pages of the current result set
func (*HashResponse) Parse ¶
func (hr *HashResponse) Parse(r string) map[string]interface{}
Parse method to parse the given raw api response
func (*HashResponse) Prevpage ¶
func (hr *HashResponse) Prevpage() int
Prevpage method to get the previous page number
func (*HashResponse) Queuetime ¶
func (hr *HashResponse) Queuetime() float64
Queuetime method to access the api response queuetime
func (*HashResponse) Runtime ¶
func (hr *HashResponse) Runtime() float64
Runtime method to access the api response runtime
func (*HashResponse) Serialize ¶
func (hr *HashResponse) Serialize(hash map[string]interface{}) string
Serialize method to stringify a parsed api response
func (*HashResponse) Total ¶
func (hr *HashResponse) Total() int
Total method to access the pagination data "total" represents the total amount of rows available in the whole result set
type Templates ¶
type Templates struct {
// contains filtered or unexported fields
}
Templates class manages default api response templates to be used for different reasons. It also provides functionality to compare a response against a template.
Basically used to provide custom response templates that are used in error cases to have a useful way to responds to the client.
func NewTemplates ¶
func NewTemplates() *Templates
NewTemplates represents the constructor for struct Templates.
func (*Templates) GetParsed ¶
GetParsed method to get a parsed response template by given template id.
func (*Templates) Match ¶
Match method to compare a given raw api response with a response template identfied by id. It compares CODE and DESCRIPTION.
func (*Templates) MatchParsed ¶
MatchParsed method to compare a given parsed api response with a response template identified by id. It compares CODE and DESCRIPTION.