Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Stock ¶
type Stock struct { ProductID int `json:"productId"` Units int `json:"units"` TTL int `json:"ttl"` }
Stock represents the stock units of a product
type StockError ¶
StockError model
func InternalError ¶
func InternalError(productID int, err error) *StockError
InternalError returns an internal error object
func OutOfStockError ¶
func OutOfStockError(productID int) *StockError
OutOfStockError is raised when a product has no stock
func (*StockError) Error ¶
func (err *StockError) Error() string
func (*StockError) IsInternalError ¶
func (err *StockError) IsInternalError() bool
IsInternalError checks if an error is an internal error
func (*StockError) IsOutOfStockError ¶
func (err *StockError) IsOutOfStockError() bool
IsOutOfStockError checks if an error is an out of stock error
type StockList ¶
type StockList struct { Stock []Stock `json:"stock"` OutOfStock []int `json:"outOfStock"` Error []StockError `json:"error"` // contains filtered or unexported fields }
StockList represents the stock of a list of products
func (*StockList) HandleError ¶
func (sl *StockList) HandleError(err *StockError)
HandleError handles the error my updating the corresponding field
Click to show internal directories.
Click to hide internal directories.