domain

package
v0.0.0-...-3a9fddd Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrShoppingCannotBeCancelled = errors.Wrap(errors.ErrBadRequest, "the shopping list cannot be cancelled")
)

Functions

This section is empty.

Types

type Bot

type Bot struct {
	ID     string
	Name   string
	Status BotStatus
}

type BotStatus

type BotStatus string
const (
	BotUnknown BotStatus = ""
	BotIdle    BotStatus = "idle"
	BotActive  BotStatus = "active"
)

func ToBotStatus

func ToBotStatus(status string) BotStatus

func (BotStatus) String

func (s BotStatus) String() string

type Item

type Item struct {
	ProductName string
	Quantity    int
}

type Items

type Items map[string]*Item

type OrderRepository

type OrderRepository interface {
	Ready(ctx context.Context, orderID string) error
}

type Product

type Product struct {
	ID      string
	StoreID string
	Name    string
}

type ProductRepository

type ProductRepository interface {
	Find(ctx context.Context, productID string) (*Product, error)
}

type ShoppingList

type ShoppingList struct {
	ID            string
	OrderID       string
	Stops         Stops
	AssignedBotID string
	Status        ShoppingListStatus
}

func CreateShopping

func CreateShopping(id, orderID string) *ShoppingList

func (*ShoppingList) AddItem

func (sl *ShoppingList) AddItem(store *Store, product *Product, quantity int) error

func (*ShoppingList) Assign

func (sl *ShoppingList) Assign(id string) error

func (*ShoppingList) Cancel

func (sl *ShoppingList) Cancel() error

func (*ShoppingList) Complete

func (sl *ShoppingList) Complete() error

type ShoppingListRepository

type ShoppingListRepository interface {
	Find(ctx context.Context, shoppingListID string) (*ShoppingList, error)
	FindByOrderID(ctx context.Context, orderID string) (*ShoppingList, error)
	Save(ctx context.Context, list *ShoppingList) error
	Update(ctx context.Context, list *ShoppingList) error
}

type ShoppingListStatus

type ShoppingListStatus string
const (
	ShoppingListUnknown   ShoppingListStatus = ""
	ShoppingListAvailable ShoppingListStatus = "available"
	ShoppingListAssigned  ShoppingListStatus = "assigned"
	ShoppingListActive    ShoppingListStatus = "active"
	ShoppingListCompleted ShoppingListStatus = "completed"
	ShoppingListCancelled ShoppingListStatus = "cancelled"
)

func ToShoppingListStatus

func ToShoppingListStatus(status string) ShoppingListStatus

func (ShoppingListStatus) String

func (s ShoppingListStatus) String() string

type Stop

type Stop struct {
	StoreName     string
	StoreLocation string
	Items         Items
}

func (*Stop) AddItem

func (s *Stop) AddItem(product *Product, quantity int) error

type Stops

type Stops map[string]*Stop

type Store

type Store struct {
	ID       string
	Name     string
	Location string
}

type StoreRepository

type StoreRepository interface {
	Find(ctx context.Context, id string) (*Store, error)
}

Jump to

Keyboard shortcuts

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