api

package
v0.0.0-...-6e0beb4 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2018 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DateRegex = "" /* 230-byte string literal not displayed */

Regex to validate date formats

Variables

View Source
var (
	//OperatorValues Values that can be used in the operators
	OperatorValues = map[string]bool{"LIKE": true, "=": true, ">=": true, "<=": true, "<>": true, "!=": true, "IN": true, "NOT IN": true}
	//RequestNotFound request not found message
	RequestNotFound = "Request with ID: %d not found"
	//ErrorNotSet field not set message
	ErrorNotSet = "%s not set"
	//ErrorIsEmpty field empty message
	ErrorIsEmpty = "is empty"
	//ErrorValidValues field with invalid values message
	ErrorValidValues = "valid values are: %s"
)

Functions

func Error

func Error(err error, c echo.Context)

Error handler for api errors

Types

type API

type API struct {
	Repo repo.Definition
	Conf *cnf.CorreiosConfig
	Hand *hand.Handler
}

API struct

func New

func New(r repo.Definition, c *cnf.CorreiosConfig) *API

New method to create a new API struct

func (*API) DeleteReverse

func (a *API) DeleteReverse() echo.HandlerFunc

DeleteReverse Handler to DELETE a Correios Reverse request

func (*API) GetReverse

func (a *API) GetReverse() echo.HandlerFunc

GetReverse Handler to GET Reverse information of a request

func (*API) GetReversesBy

func (a *API) GetReversesBy() echo.HandlerFunc

GetReversesBy Handler to GET Reverse information for N Requests

func (*API) GetTracking

func (a *API) GetTracking() echo.HandlerFunc

GetTracking Handler to retrieve Tracking information

func (*API) PostReverse

func (a *API) PostReverse() echo.HandlerFunc

PostReverse Handler to POST a Correios Reverse request

func (*API) PutReverse

func (a *API) PutReverse() echo.HandlerFunc

PutReverse Handler to PUT a Correios Reverse request

func (*API) ValidatePutJSON

func (a *API) ValidatePutJSON(s *strut.Request) map[string]string

ValidatePutJSON Validates the consistency of the Request struct

func (*API) ValidateSearchJSON

func (a *API) ValidateSearchJSON(s *strut.Search) map[string]string

ValidateSearchJSON Validates the consistency of the Search struct

func (*API) ValidateTrackingJSON

func (a *API) ValidateTrackingJSON(s *strut.Tracking) map[string]string

ValidateTrackingJSON Validates the consistency of the Tracking struct

type ErrContent

type ErrContent struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ErrContent contains the code and message of the Error

type ErrResponse

type ErrResponse struct {
	Error ErrContent `json:"error"`
}

ErrResponse main struct for error handling

type ErrResponseValidation

type ErrResponseValidation struct {
	Type   string           `json:"error_type"`
	Errors []*ErrValidation `json:"errors"`
}

ErrResponseValidation contains the type of error found and its fields and correspondent messages

type ErrValidation

type ErrValidation struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

ErrValidation contains the field and correspondent error message

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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