Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cart ¶
type Cart struct {
// contains filtered or unexported fields
}
Cart represents the actions that you can perform on a cart
func New ¶
func New(inventory InventoryAPI, payments PaymentsAPI, cartContents shoppingCart.CartStore) *Cart
New starts a new cart
func (*Cart) AddProductToCart ¶
AddProductToCart adds a bew product to the cart (or updates the existing item quantity if some already present)
type Contents ¶
type Contents struct {
Products []*Product `json:"products"`
}
Contents represents the contents of the cart
type InventoryAPI ¶
type InventoryAPI interface { // Check if product is in sufficient stock HasInStock(productID uint, quantity uint) (bool, error) // GetPrice returns the price of an item GetPrice(productID uint) (uint, error) // Renove from stock removes items from stock, but restores the previous values of False is sent over the commitChan RemoveFromStock(items map[uint]uint, commitChan <-chan bool, errorChan chan<- error) error }
InventoryAPI represents the methods that need to be implemented by the inventory API
type PaymentsAPI ¶
type PaymentsAPI interface { // MakePayment tries to call the payment API MakePayment(client string, money uint) error }
PaymentsAPI represents the methods that need to be implemented by the payments API
Click to show internal directories.
Click to hide internal directories.