domain

package
v0.0.0-...-0ebfa01 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrderCreatedEvent   = "ordering.OrderCreated"
	OrderRejectedEvent  = "ordering.OrderRejected"
	OrderApprovedEvent  = "ordering.OrderApproved"
	OrderCanceledEvent  = "ordering.OrderCanceled"
	OrderReadiedEvent   = "ordering.OrderReadied"
	OrderCompletedEvent = "ordering.OrderCompleted"
)
View Source
const OrderAggregate = "ordering.Order"

Variables

View Source
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 CustomerRepository interface {
	Authorize(ctx context.Context, customerID string) error
}

type Item

type Item struct {
	ProductID   string
	StoreID     string
	StoreName   string
	ProductName string
	Price       float64
	Quantity    int
}

type MockCustomerRepository

type MockCustomerRepository struct {
	mock.Mock
}

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.

func (*MockCustomerRepository) Authorize

func (_m *MockCustomerRepository) Authorize(ctx context.Context, customerID string) error

Authorize provides a mock function with given fields: ctx, customerID

type MockOrderRepository

type MockOrderRepository struct {
	mock.Mock
}

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.

func (*MockOrderRepository) Load

func (_m *MockOrderRepository) Load(ctx context.Context, orderID string) (*Order, error)

Load provides a mock function with given fields: ctx, orderID

func (*MockOrderRepository) Save

func (_m *MockOrderRepository) Save(ctx context.Context, order *Order) error

Save provides a mock function with given fields: ctx, order

type MockPaymentRepository

type MockPaymentRepository struct {
	mock.Mock
}

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.

func (*MockPaymentRepository) Confirm

func (_m *MockPaymentRepository) Confirm(ctx context.Context, paymentID string) error

Confirm provides a mock function with given fields: ctx, paymentID

type MockShoppingRepository

type MockShoppingRepository struct {
	mock.Mock
}

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.

func (*MockShoppingRepository) Cancel

func (_m *MockShoppingRepository) Cancel(ctx context.Context, shoppingID string) error

Cancel provides a mock function with given fields: ctx, shoppingID

func (*MockShoppingRepository) Create

func (_m *MockShoppingRepository) Create(ctx context.Context, orderID string, items []Item) (string, error)

Create provides a mock function with given fields: ctx, orderID, items

type Order

type Order struct {
	es.Aggregate
	CustomerID string
	PaymentID  string
	InvoiceID  string
	ShoppingID string
	Items      []Item
	Status     OrderStatus
}

func NewOrder

func NewOrder(id string) *Order

func (*Order) ApplyEvent

func (o *Order) ApplyEvent(event ddd.Event) error

func (*Order) ApplySnapshot

func (o *Order) ApplySnapshot(snapshot es.Snapshot) error

func (*Order) Approve

func (o *Order) Approve(shoppingID string) (ddd.Event, error)

func (*Order) Cancel

func (o *Order) Cancel() (ddd.Event, error)

func (*Order) Complete

func (o *Order) Complete(invoiceID string) (ddd.Event, error)

func (*Order) CreateOrder

func (o *Order) CreateOrder(id, customerID, paymentID string, items []Item) (ddd.Event, error)

func (Order) GetTotal

func (o Order) GetTotal() float64

func (Order) Key

func (Order) Key() string

func (*Order) Ready

func (o *Order) Ready() (ddd.Event, error)

func (*Order) Reject

func (o *Order) Reject() (ddd.Event, error)

func (*Order) ToSnapshot

func (o *Order) ToSnapshot() es.Snapshot

type OrderApproved

type OrderApproved struct {
	ShoppingID string
}

func (OrderApproved) Key

func (OrderApproved) Key() string

type OrderCanceled

type OrderCanceled struct {
	CustomerID string
	PaymentID  string
}

func (OrderCanceled) Key

func (OrderCanceled) Key() string

type OrderCompleted

type OrderCompleted struct {
	CustomerID string
	InvoiceID  string
}

func (OrderCompleted) Key

func (OrderCompleted) Key() string

type OrderCreated

type OrderCreated struct {
	CustomerID string
	PaymentID  string
	ShoppingID string
	Items      []Item
}

func (OrderCreated) Key

func (OrderCreated) Key() string

type OrderReadied

type OrderReadied struct {
	CustomerID string
	PaymentID  string
	Total      float64
}

func (OrderReadied) Key

func (OrderReadied) Key() string

type OrderRejected

type OrderRejected struct{}

func (OrderRejected) Key

func (OrderRejected) Key() string

type OrderRepository

type OrderRepository interface {
	Load(ctx context.Context, orderID string) (*Order, error)
	Save(ctx context.Context, order *Order) error
}

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
}

func (OrderV1) SnapshotName

func (OrderV1) SnapshotName() string

type PaymentRepository

type PaymentRepository interface {
	Confirm(ctx context.Context, paymentID string) error
}

type ShoppingRepository

type ShoppingRepository interface {
	Create(ctx context.Context, orderID string, items []Item) (string, error)
	Cancel(ctx context.Context, shoppingID string) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL