models

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AcceptLanguageHeaderError         = "ErrorAcceptLanguageHeader"
	AreaDataIdGetError                = "ErrorRetrievingAreaCode"
	MarshallingAreaDataError          = "ErrorMarshallingAreaData"
	MarshallingAreaRelationshipsError = "ErrorMarshallingAreaRelationshipData"
)

API error codes

View Source
const (
	AcceptLanguageHeaderNotFoundDescription = "accept language header not found"
	AcceptLanguageHeaderInvalidDescription  = "accept language header invalid"
	AreaDataGetErrorDescription             = "area code not found"
)

API error descriptions

Variables

View Source
var (
	AcceptLanguageHeaderName = "Accept-Language"
	AcceptLanguageMapping    = map[string]string{
		"en": "English",
		"cy": "Cymraeg",
	}
)

Functions

This section is empty.

Types

type Area

type Area struct {
	ID                string        `bson:"id,omitempty"                  json:"id,omitempty"`
	Version           int           `bson:"version,omitempty"             json:"version,omitempty"`
	Name              string        `bson:"name,omitempty"                json:"name,omitempty"`
	ReleaseDate       string        `bson:"release_date,omitempty"        json:"release_date,omitempty"`
	LastUpdated       time.Time     `bson:"last_updated,omitempty"        json:"last_updated,omitempty"`
	Type              string        `bson:"type,omitempty"                json:"type,omitempty"`
	ParentAreas       []LinkedAreas `bson:"parent_areas,omitempty"        json:"parent_areas,omitempty"`
	ChildAreas        []LinkedAreas `bson:"child_areas,omitempty"         json:"child_areas,omitempty"`
	NeighbouringAreas []LinkedAreas `bson:"neighbouring_areas,omitempty"  json:"neighbouring_areas,omitempty"`
}

Area represents the structure for an area

type AreaRelationShips added in v0.7.0

type AreaRelationShips struct {
	AreaCode string `json:"area_code"`
	AreaName string `json:"area_name"`
	Href     string `json:"href"`
}

type AreaType

type AreaType int

AreaType defines possible area types

const (
	Country AreaType = iota
	Region
	UnitaryAuthorities
	CombinedAuthorities
	MetropolitanCounties
	Counties
	LondonBoroughs
	MetropolitanDistricts
	NonMetropolitanDistricts
	ElectoralWards
	Invalid
)

possible area types

type AreasDataResults added in v0.6.0

type AreasDataResults struct {
	Code          string                 `json:"code"`
	Name          string                 `json:"name"`
	ValidFrom     string                 `json:"date_start"`
	ValidTo       string                 `json:"date_end"`
	WelshName     string                 `json:"name_welsh"`
	GeometricData map[string]interface{} `json:"geometry"`
	Visible       bool                   `json:"visible"`
	AreaType      string                 `json:"area_type"`
}

AreasDataResults

type AreasResults

type AreasResults struct {
	Items      *[]Area `json:"items"`
	Count      int     `json:"count"`
	Offset     int     `json:"offset"`
	Limit      int     `json:"limit"`
	TotalCount int     `json:"total_count"`
}

AreasResults represents a structure for a list of areas

type Error added in v0.6.0

type Error struct {
	Cause       error  `json:"-"`
	Code        string `json:"code"`
	Description string `json:"description"`
}

func NewError added in v0.6.0

func NewError(ctx context.Context, cause error, code string, description string) *Error

func NewValidationError added in v0.6.0

func NewValidationError(ctx context.Context, code string, description string) *Error

func (*Error) Error added in v0.6.0

func (e *Error) Error() string

type ErrorResponse added in v0.6.0

type ErrorResponse struct {
	Errors  []error           `json:"errors"`
	Status  int               `json:"-"`
	Headers map[string]string `json:"-"`
}

func NewErrorResponse added in v0.6.0

func NewErrorResponse(statusCode int, headers map[string]string, errors ...error) *ErrorResponse

type LinkedAreas

type LinkedAreas struct {
	ID   string `bson:"id,omitempty"         json:"id,omitempty"`
	Type string `bson:"type,omitempty"       json:"type,omitempty"`
	Name string `bson:"name,omitempty"       json:"name,omitempty"`
}

type SuccessResponse added in v0.6.0

type SuccessResponse struct {
	Body    []byte            `json:"-"`
	Status  int               `json:"-"`
	Headers map[string]string `json:"-"`
}

func NewSuccessResponse added in v0.6.0

func NewSuccessResponse(jsonBody []byte, statusCode int, headers map[string]string) *SuccessResponse

Jump to

Keyboard shortcuts

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