pet

package
v0.0.0-...-b8bd235 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver interface {
	FindAllPets() ([]Pet, error)
	FindPetsByName(name string) ([]Pet, error)
	FindPetById(id string) (*Pet, error)
	InsertPet(pet *Pet) (*Pet, error)
	UpdatePet(id string, pet *Pet) (*Pet, error)
	UpdatePetTreatments(pet *Pet) (*Pet, error)
	DeletePetByID(id string) error
	FindPetsByOwnerID(ownerID string, page string, limit string) (PaginatedPetsList, error)
	FindPetByNameAndOwnerID(name string, ownerID string) (*Pet, error)
	FindPetsByVaccineNextDate(date []string) ([]Pet, error)
	FindPetTreatments(petID string) ([]Treatment, error)
	FindPetsWithUpcomingVaccines(userID string, dateRange string) ([]Pet, error)
	FindPetsTreatments(userID string) ([]Pet, error)
}

type Module

type Module struct {
	Handler *handler
	// contains filtered or unexported fields
}

func NewModule

func NewModule(mongoDB *mongodb.MongoDB) *Module

func (*Module) RegisterRoutes

func (m *Module) RegisterRoutes(api *echo.Group)

type PaginatedPetsList

type PaginatedPetsList struct {
	Pets     []Pet  `json:"pets"`
	Next     string `json:"next"`
	Previous string `json:"prev"`
	Page     string `json:"page"`
}

type Pet

type Pet struct {
	ID         string      `json:"id" bson:"_id"`
	Name       string      `validate:"required,max=50" json:"name" bson:"name"`
	Species    string      `validate:"required,max=50" json:"species" bson:"species"`
	Sex        string      `validate:"required,max=50" json:"sex" bson:"sex"`
	Birthdate  string      `validate:"required,date" json:"birthdate" bson:"birthdate"`
	Age        string      `json:"age,omitempty" bson:"age"`
	OwnerID    string      `json:"ownerId" bson:"ownerId"`
	Treatments []Treatment `json:"treatments" bson:"treatments"`
}

type PetDriver

type PetDriver struct {
	// contains filtered or unexported fields
}

func (*PetDriver) DeletePetByID

func (d *PetDriver) DeletePetByID(id string) error

func (*PetDriver) FindAllPets

func (d *PetDriver) FindAllPets() ([]Pet, error)

func (*PetDriver) FindPetById

func (d *PetDriver) FindPetById(id string) (*Pet, error)

func (*PetDriver) FindPetByNameAndOwnerID

func (d *PetDriver) FindPetByNameAndOwnerID(name string, ownerID string) (*Pet, error)

func (*PetDriver) FindPetTreatments

func (d *PetDriver) FindPetTreatments(petID string) ([]Treatment, error)

func (*PetDriver) FindPetsByName

func (d *PetDriver) FindPetsByName(name string) ([]Pet, error)

func (*PetDriver) FindPetsByOwnerID

func (d *PetDriver) FindPetsByOwnerID(ownerID, page, limit string) (PaginatedPetsList, error)

func (*PetDriver) FindPetsByVaccineNextDate

func (d *PetDriver) FindPetsByVaccineNextDate(date []string) ([]Pet, error)

func (*PetDriver) FindPetsTreatments

func (d *PetDriver) FindPetsTreatments(userID string) ([]Pet, error)

func (*PetDriver) FindPetsWithUpcomingVaccines

func (d *PetDriver) FindPetsWithUpcomingVaccines(userID string, dateRange string) ([]Pet, error)

func (*PetDriver) InsertPet

func (d *PetDriver) InsertPet(pet *Pet) (*Pet, error)

func (*PetDriver) UpdatePet

func (d *PetDriver) UpdatePet(id string, pet *Pet) (*Pet, error)

func (*PetDriver) UpdatePetTreatments

func (d *PetDriver) UpdatePetTreatments(pet *Pet) (*Pet, error)

type PetDriverMock

type PetDriverMock struct {
	UpdatePetTreatmentsCalled bool
	UpdatePetTreatmentsPet    *Pet
	UpdatePetTreatmentsErr    error

	FindPetByIdCalled bool
	FindPetByIdPet    *Pet
	FindPetByIdErr    error
	FindPetByIdPetId  string

	FindPetByNameAndOwnerIDCalled  bool
	FindPetByNameAndOwnerIDPet     *Pet
	FindPetByNameAndOwnerIDErr     error
	FindPetByNameAndOwnerIDName    string
	FindPetByNameAndOwnerIDOwnerId string

	FindPetsByOwnerIDCalled  bool
	FindPetsByOwnerIDLimit   string
	FindPetsByOwnerIDPage    string
	FindPetsByOwnerIDPets    []Pet
	FindPetsByOwnerIDErr     error
	FindPetsByOwnerIDOwnerId string

	DeletePetByIDCalled bool
	DeletePetByIDErr    error
	DeletePetByIDPetId  string

	InsertPetCalled bool
	InsertPetErr    error
	InsertPetPet    *Pet

	UpdatePetCalled bool
	UpdatePetErr    error
	UpdatePetPet    *Pet
}

func (*PetDriverMock) DeletePetByID

func (d *PetDriverMock) DeletePetByID(id string) error

func (*PetDriverMock) FindAllPets

func (d *PetDriverMock) FindAllPets() ([]Pet, error)

func (*PetDriverMock) FindPetById

func (d *PetDriverMock) FindPetById(id string) (*Pet, error)

func (*PetDriverMock) FindPetByNameAndOwnerID

func (d *PetDriverMock) FindPetByNameAndOwnerID(name string, ownerID string) (*Pet, error)

func (*PetDriverMock) FindPetTreatments

func (d *PetDriverMock) FindPetTreatments(petID string) ([]Treatment, error)

func (*PetDriverMock) FindPetsByName

func (d *PetDriverMock) FindPetsByName(name string) ([]Pet, error)

func (*PetDriverMock) FindPetsByOwnerID

func (d *PetDriverMock) FindPetsByOwnerID(ownerID, page, limit string) (PaginatedPetsList, error)

func (*PetDriverMock) FindPetsByVaccineNextDate

func (d *PetDriverMock) FindPetsByVaccineNextDate(date []string) ([]Pet, error)

func (*PetDriverMock) FindPetsTreatments

func (d *PetDriverMock) FindPetsTreatments(userID string) ([]Pet, error)

func (*PetDriverMock) FindPetsWithUpcomingVaccines

func (d *PetDriverMock) FindPetsWithUpcomingVaccines(userID string, dateRange string) ([]Pet, error)

func (*PetDriverMock) InsertPet

func (d *PetDriverMock) InsertPet(pet *Pet) (*Pet, error)

func (*PetDriverMock) UpdatePet

func (d *PetDriverMock) UpdatePet(id string, pet *Pet) (*Pet, error)

func (*PetDriverMock) UpdatePetTreatments

func (d *PetDriverMock) UpdatePetTreatments(pet *Pet) (*Pet, error)

type State

type State string
const (
	Expiring State = "expiring"
	Expired  State = "expired"
	Valid    State = "valid"
)

type Treatment

type Treatment struct {
	ID                    string        `json:"id" bson:"_id"`
	Name                  string        `validate:"required,max=50" json:"name" bson:"name"`
	AdditionalInformation string        `validate:"max=100" json:"additionalInfo,omitempty" bson:"additionalInfo"`
	Date                  string        `validate:"required,date" json:"date" bson:"date"`
	Next                  string        `validate:"required,date" json:"next" bson:"next"`
	Veterinary            string        `validate:"max=100" json:"veterinary,omitempty" bson:"veterinary"`
	TypeTreatment         TypeTreatment `json:"type" bson:"type"`
	State                 State         `json:"state,omitempty" bson:"state"`
}

type TypeTreatment

type TypeTreatment string
const (
	Vaccine  TypeTreatment = "vaccine"
	Medicine TypeTreatment = "medicine"
)

Jump to

Keyboard shortcuts

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