 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
- Variables
- type Basket
- func (b *Basket) AddItem(store *Store, product *Product, quantity int) error
- func (b *Basket) ApplyEvent(event ddd.Event) error
- func (b *Basket) ApplySnapshot(snapshot es.Snapshot) error
- func (b *Basket) Cancel() error
- func (b *Basket) Checkout(paymentID string) error
- func (b Basket) IsCancellable() bool
- func (b Basket) IsOpen() bool
- func (Basket) Key() string
- func (b *Basket) RemoveItem(product *Product, quantity int) error
- func (b *Basket) ToSnapshot() es.Snapshot
 
- type BasketCanceled
- type BasketCheckedOut
- type BasketItemAdded
- type BasketItemRemoved
- type BasketRepository
- type BasketStarted
- type BasketStatus
- type BasketV1
- type Item
- type OrderRepository
- type Product
- type ProductCacheRepository
- type ProductRepository
- type Store
- type StoreCacheRepository
- type StoreRepository
Constants ¶
      View Source
      
  
    const ( BasketStartedEvent = "baskets.BasketStarted" BasketItemAddedEvent = "baskets.BasketItemAdded" BasketItemRemovedEvent = "baskets.BasketItemRemoved" BasketCanceledEvent = "baskets.BasketCanceled" BasketCheckedOutEvent = "baskets.BasketCheckedOut" )
      View Source
      
  
const BasketAggregate = "baskets.Basket"
    Variables ¶
      View Source
      
  
var ( ErrBasketHasNoItems = errors.Wrap(errors.ErrBadRequest, "the basket has no items") ErrBasketCannotBeModified = errors.Wrap(errors.ErrBadRequest, "the basket cannot be modified") ErrBasketCannotBeCancelled = errors.Wrap(errors.ErrBadRequest, "the basket cannot be cancelled") ErrQuantityCannotBeNegative = errors.Wrap(errors.ErrBadRequest, "the item quantity cannot be negative") ErrBasketIDCannotBeBlank = errors.Wrap(errors.ErrBadRequest, "the basket id cannot be blank") ErrPaymentIDCannotBeBlank = errors.Wrap(errors.ErrBadRequest, "the payment id cannot be blank") ErrCustomerIDCannotBeBlank = errors.Wrap(errors.ErrBadRequest, "the customer id cannot be blank") )
Functions ¶
This section is empty.
Types ¶
type Basket ¶
type Basket struct {
	es.Aggregate
	CustomerID string
	PaymentID  string
	Items      map[string]Item
	Status     BasketStatus
}
    func StartBasket ¶
func (Basket) IsCancellable ¶
func (*Basket) ToSnapshot ¶
type BasketCanceled ¶
type BasketCanceled struct{}
    type BasketCheckedOut ¶
func (BasketCheckedOut) Key ¶
func (BasketCheckedOut) Key() string
Key implements registry.Registerable
type BasketItemAdded ¶
type BasketItemAdded struct {
	Item Item
}
    func (BasketItemAdded) Key ¶
func (BasketItemAdded) Key() string
Key implements registry.Registerable
type BasketItemRemoved ¶
func (BasketItemRemoved) Key ¶
func (BasketItemRemoved) Key() string
Key implements registry.Registerable
type BasketRepository ¶
type BasketStarted ¶
type BasketStarted struct {
	CustomerID string
}
    type BasketStatus ¶
type BasketStatus string
const ( BasketUnknown BasketStatus = "" BasketIsOpen BasketStatus = "open" BasketIsCanceled BasketStatus = "canceled" BasketIsCheckedOut BasketStatus = "checked_out" )
func ToBasketStatus ¶
func ToBasketStatus(status string) BasketStatus
func (BasketStatus) String ¶
func (s BasketStatus) String() string
type BasketV1 ¶
type BasketV1 struct {
	CustomerID string
	PaymentID  string
	Items      map[string]Item
	Status     BasketStatus
}
    func (BasketV1) SnapshotName ¶
type OrderRepository ¶
type ProductCacheRepository ¶
type ProductCacheRepository interface {
	Add(ctx context.Context, productID, storeID, name string, price float64) error
	Rebrand(ctx context.Context, productID, name string) error
	UpdatePrice(ctx context.Context, productID string, delta float64) error
	Remove(ctx context.Context, productID string) error
	ProductRepository
}
    type ProductRepository ¶
type StoreCacheRepository ¶
 Click to show internal directories. 
   Click to hide internal directories.