envelope

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Envelope

type Envelope struct {
	XMLName    xml.Name    `json:"-" xml:"envelope"`
	StatusCode int         `json:"-" xml:"-"`
	Status     Status      `json:"status" xml:"status"`
	Data       interface{} `json:"data,omitempty" xml:"data,omitempty"`
}

Envelope identifies the structure used to define a normalized endpoint response

func NewEnvelope

func NewEnvelope(statusCode int, data interface{}) Envelope

NewEnvelope instantiates a new response data envelope structure

func (Envelope) AddError

func (s Envelope) AddError(err Error) Envelope

AddError add a new error to the response envelope instance

func (Envelope) SetEndpoint

func (s Envelope) SetEndpoint(val int) Envelope

SetEndpoint assign the endpoint identifier to all stored error codes

func (Envelope) SetService

func (s Envelope) SetService(val int) Envelope

SetService assign the service identifier to all stored error codes

type Error

type Error struct {
	Service  int    `json:"-" xml:"-"`
	Endpoint int    `json:"-" xml:"-"`
	Param    int    `json:"-" xml:"-"`
	Error    int    `json:"-" xml:"-"`
	Code     string `json:"code" xml:"code"`
	Message  string `json:"message" xml:"message"`
}

Error defines a structure that hold the application error information.

func NewError

func NewError(err int, msg string) Error

NewError instantiates a new error instance.

func (Error) SetEndpoint

func (e Error) SetEndpoint(val int) Error

SetEndpoint assigns an endpoint code value to the error.

func (Error) SetError

func (e Error) SetError(err int) Error

SetError assigns a error code value to the error.

func (Error) SetMessage

func (e Error) SetMessage(msg string) Error

SetMessage assigns a message to the error.

func (Error) SetParam

func (e Error) SetParam(param int) Error

SetParam assigns a parameter code value to the error.

func (Error) SetService

func (e Error) SetService(val int) Error

SetService assigns a service code value to the error.

type ErrorList added in v1.6.3

type ErrorList []Error

ErrorList defines a type of data that holds a list of error structures.

func (ErrorList) MarshalXML added in v1.6.3

func (s ErrorList) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML serialize the error list into a xml string

type Status

type Status struct {
	Status bool      `json:"status" xml:"status"`
	Errors ErrorList `json:"errors" xml:"errors"`
}

Status defines a structure that holds the result status of the request.

func NewStatus

func NewStatus() Status

NewStatus instantiates a new request result status structure.

func (Status) AddError

func (s Status) AddError(err Error) Status

AddError append a new error to the status error list

func (Status) SetEndpoint

func (s Status) SetEndpoint(val int) Status

SetEndpoint assign an endpoint code to all stored errors.

func (Status) SetService

func (s Status) SetService(val int) Status

SetService assign a service code to all stored errors.

Jump to

Keyboard shortcuts

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