Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InventoryService ¶
type InventoryService struct {
// contains filtered or unexported fields
}
InventoryService is our database type.
func NewInventoryService ¶
func NewInventoryService(s map[string]MenuItem) *InventoryService
NewInventoryService creates a new service, given an map of items to initialise from.
func (*InventoryService) GetStock ¶
func (s *InventoryService) GetStock() []MenuItem
GetStock returns the current stock available.
func (*InventoryService) PlaceOrder ¶
func (s *InventoryService) PlaceOrder(items []LineItem) (float64, error)
PlaceOrder verifies quantities and place an order for the given slice of LineItem.
type MenuItem ¶
type MenuItem struct { Name string `json:"name"` Quantity int `json:"quantity"` Price float64 `json:"price"` }
MenuItem is the type of items available.
type Order ¶
type Order struct { ID string `json:"id"` Items []LineItem `json:"items"` Status string `json:"status"` Total string `json:"total,omitempty"` }
Order contains the fields of our orders.
type OrderService ¶
type OrderService struct {
// contains filtered or unexported fields
}
OrderService is our database type.
func NewOrders ¶
func NewOrders(inventory *InventoryService) *OrderService
NewOrders initialises the Orders service given an InventoryService.
func (*OrderService) Get ¶
func (os *OrderService) Get(id string) (*Order, error)
Get returns a given order or error if none exists.
func (*OrderService) GetSales ¶
func (os *OrderService) GetSales() *Sales
GetSales returns the sales stats of the order service This is a costly/long running operation.
type OrderStatus ¶
type OrderStatus int
OrderStatus contains the different types of Order status.
const ( New OrderStatus = iota InProgress Completed Rejected )
func (OrderStatus) String ¶
func (o OrderStatus) String() string