customerrepository

package
v0.0.0-...-9b4a7b0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 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 ByCompanyName

type ByCompanyName []Customer

ByCompanyName is used for sorting customers by company name

func (ByCompanyName) Len

func (c ByCompanyName) Len() int

func (ByCompanyName) Less

func (c ByCompanyName) Less(i, j int) bool

func (ByCompanyName) Swap

func (c ByCompanyName) Swap(i, j int)

type Customer

type Customer struct {
	CustomerID  uuid.UUID       `json:"customerID,omitempty"`
	CompanyName string          `json:"customerName"`
	ContactName string          `json:"contactName"`
	Country     string          `json:"country"`
	HourlyRate  decimal.Decimal `json:"hourlyRate"`
}

Customer holds data of a customer record

type CustomerRepository

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

CustomerRepository is an in-memory repository of customers

func NewCustomerRepository

func NewCustomerRepository() CustomerRepository

NewCustomerRepository creates a customer repository

func (CustomerRepository) AddCustomer

func (cr CustomerRepository) AddCustomer(c Customer)

AddCustomer adds a customer to the repository

func (CustomerRepository) DeleteCustomerByID

func (cr CustomerRepository) DeleteCustomerByID(cid uuid.UUID) bool

DeleteCustomerByID removes a customer with a given ID

func (CustomerRepository) GetCustomerByID

func (cr CustomerRepository) GetCustomerByID(cid uuid.UUID) (*Customer, bool)

GetCustomerByID looks for a customer with a given ID

func (CustomerRepository) GetCustomersArray

func (cr CustomerRepository) GetCustomersArray() []Customer

GetCustomersArray returns all stored customers as an array

func (CustomerRepository) PatchCustomer

func (cr CustomerRepository) PatchCustomer(cid uuid.UUID, c Customer) (*Customer, bool)

PatchCustomer patches a customer with the given values

Jump to

Keyboard shortcuts

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