Documentation ¶
Index ¶
- Constants
- Variables
- type CustomerRepository
- type Item
- type MockCustomerRepository
- type MockOrderRepository
- type MockPaymentRepository
- type MockShoppingRepository
- type Order
- func (o *Order) ApplyEvent(event ddd.Event) error
- func (o *Order) ApplySnapshot(snapshot es.Snapshot) error
- func (o *Order) Approve(shoppingID string) (ddd.Event, error)
- func (o *Order) Cancel() (ddd.Event, error)
- func (o *Order) Complete(invoiceID string) (ddd.Event, error)
- func (o *Order) CreateOrder(id, customerID, paymentID string, items []Item) (ddd.Event, error)
- func (o Order) GetTotal() float64
- func (Order) Key() string
- func (o *Order) Ready() (ddd.Event, error)
- func (o *Order) Reject() (ddd.Event, error)
- func (o *Order) ToSnapshot() es.Snapshot
- type OrderApproved
- type OrderCanceled
- type OrderCompleted
- type OrderCreated
- type OrderReadied
- type OrderRejected
- type OrderRepository
- type OrderStatus
- type OrderV1
- type PaymentRepository
- type ShoppingRepository
Constants ¶
const ( OrderCreatedEvent = "ordering.OrderCreated" OrderRejectedEvent = "ordering.OrderRejected" OrderApprovedEvent = "ordering.OrderApproved" OrderCanceledEvent = "ordering.OrderCanceled" OrderReadiedEvent = "ordering.OrderReadied" OrderCompletedEvent = "ordering.OrderCompleted" )
const OrderAggregate = "ordering.Order"
Variables ¶
var ( ErrOrderAlreadyCreated = errors.Wrap(errors.ErrBadRequest, "the order cannot be recreated") ErrOrderHasNoItems = errors.Wrap(errors.ErrBadRequest, "the order has no items") ErrOrderCannotBeCancelled = errors.Wrap(errors.ErrBadRequest, "the order cannot be cancelled") ErrCustomerIDCannotBeBlank = errors.Wrap(errors.ErrBadRequest, "the customer id cannot be blank") ErrPaymentIDCannotBeBlank = errors.Wrap(errors.ErrBadRequest, "the payment id cannot be blank") )
Functions ¶
This section is empty.
Types ¶
type CustomerRepository ¶
type MockCustomerRepository ¶
MockCustomerRepository is an autogenerated mock type for the CustomerRepository type
func NewMockCustomerRepository ¶
func NewMockCustomerRepository(t mockConstructorTestingTNewMockCustomerRepository) *MockCustomerRepository
NewMockCustomerRepository creates a new instance of MockCustomerRepository. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
type MockOrderRepository ¶
MockOrderRepository is an autogenerated mock type for the OrderRepository type
func NewMockOrderRepository ¶
func NewMockOrderRepository(t mockConstructorTestingTNewMockOrderRepository) *MockOrderRepository
NewMockOrderRepository creates a new instance of MockOrderRepository. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
type MockPaymentRepository ¶
MockPaymentRepository is an autogenerated mock type for the PaymentRepository type
func NewMockPaymentRepository ¶
func NewMockPaymentRepository(t mockConstructorTestingTNewMockPaymentRepository) *MockPaymentRepository
NewMockPaymentRepository creates a new instance of MockPaymentRepository. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
type MockShoppingRepository ¶
MockShoppingRepository is an autogenerated mock type for the ShoppingRepository type
func NewMockShoppingRepository ¶
func NewMockShoppingRepository(t mockConstructorTestingTNewMockShoppingRepository) *MockShoppingRepository
NewMockShoppingRepository creates a new instance of MockShoppingRepository. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
type Order ¶
type Order struct { es.Aggregate CustomerID string PaymentID string InvoiceID string ShoppingID string Items []Item Status OrderStatus }
func (*Order) CreateOrder ¶
func (*Order) ToSnapshot ¶
type OrderApproved ¶
type OrderApproved struct {
ShoppingID string
}
func (OrderApproved) Key ¶
func (OrderApproved) Key() string
type OrderCanceled ¶
func (OrderCanceled) Key ¶
func (OrderCanceled) Key() string
type OrderCompleted ¶
func (OrderCompleted) Key ¶
func (OrderCompleted) Key() string
type OrderCreated ¶
func (OrderCreated) Key ¶
func (OrderCreated) Key() string
type OrderReadied ¶
func (OrderReadied) Key ¶
func (OrderReadied) Key() string
type OrderRejected ¶
type OrderRejected struct{}
func (OrderRejected) Key ¶
func (OrderRejected) Key() string
type OrderRepository ¶
type OrderStatus ¶
type OrderStatus string
const ( OrderUnknown OrderStatus = "" OrderIsPending OrderStatus = "pending" OrderIsRejected OrderStatus = "rejected" OrderIsApproved OrderStatus = "approved" OrderIsInProcess OrderStatus = "in-progress" OrderIsReady OrderStatus = "ready" OrderIsCompleted OrderStatus = "completed" OrderIsCancelled OrderStatus = "cancelled" )
func ToOrderStatus ¶
func ToOrderStatus(status string) OrderStatus
func (OrderStatus) String ¶
func (s OrderStatus) String() string
type OrderV1 ¶
type OrderV1 struct { CustomerID string PaymentID string InvoiceID string ShoppingID string Items []Item Status OrderStatus }