models

package
v0.0.0-...-103f8c7 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAddressNotFound = errors.New("Address not found")
	ErrAddressInvalid  = errors.New("The informed zip code is invalid")
)

ErrAddressNotFound returns if address was not found ErrAddressInvalid returns if zip code sent is invalid

Functions

This section is empty.

Types

type Address

type Address struct {
	ID             bson.ObjectID `json:"-" bson:"_id,omitempty"`
	FederativeUnit string        `json:"federative_unit" bson:"federative_unit" xml:"uf"`
	City           string        `json:"city" bson:"city" xml:"cidade"`
	Neighborhood   string        `json:"neighborhood" bson:"neighborhood" xml:"bairro"`
	AddressName    string        `json:"address_name" bson:"address_name" xml:"end"`
	Complement     string        `json:"complement" bson:"complement" xml:"complemento2"`
	Zipcode        string        `json:"zipcode" bson:"zipcode" xml:"cep"`
	CreatedAt      time.Time     `json:"created_at" bson:"created_at"`
	UpdatedAt      time.Time     `json:"updated_at" bson:"updated_at"`
}

Address struct has information from brazilian addresses

func (*Address) Create

func (a *Address) Create(zipcode string) error

Create this function create address if doesn't exists

func (*Address) IsUpdated

func (a *Address) IsUpdated() bool

IsUpdated returns if the address is older than 7 days

func (*Address) Update

func (a *Address) Update() error

Update this function update address if outdated

type AddressInterface

type AddressInterface interface {
	Create(zipcode string) error
	IsUpdated() bool
	Update(zipcode string) error
}

AddressInterface interface that exports the model methods

Jump to

Keyboard shortcuts

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