hashresponse

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2018 License: MIT Imports: 6 Imported by: 0

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

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) Get

func (dr *Templates) Get(templateid string) string

Get method to get a raw response template by given template id.

func (*Templates) GetAll

func (dr *Templates) GetAll() map[string]string

GetAll method to get all available response templates

func (*Templates) GetParsed

func (dr *Templates) GetParsed(templateid string) map[string]interface{}

GetParsed method to get a parsed response template by given template id.

func (*Templates) Match

func (dr *Templates) Match(r string, templateid string) bool

Match method to compare a given raw api response with a response template identfied by id. It compares CODE and DESCRIPTION.

func (*Templates) MatchParsed

func (dr *Templates) MatchParsed(r map[string]interface{}, templateid string) bool

MatchParsed method to compare a given parsed api response with a response template identified by id. It compares CODE and DESCRIPTION.

func (*Templates) Set

func (dr *Templates) Set(templateid string, templatecontent string)

Set method to set a response template by given template id and content

func (*Templates) SetParsed

func (dr *Templates) SetParsed(templateid string, templatecontent map[string]interface{})

SetParsed method to set a response template by given template id and parsed content

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL