domain

package
v0.0.0-...-3a9fddd Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	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 InvoiceID

type InvoiceID string

func (InvoiceID) String

func (i InvoiceID) String() string

type InvoiceRepository

type InvoiceRepository interface {
	Save(ctx context.Context, orderID, paymentID string, amount float64) error
	Delete(ctx context.Context, invoiceID string) error
}

type Item

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

type NotificationRepository

type NotificationRepository interface {
	NotifyOrderCreated(ctx context.Context, orderID, customerID string) error
	NotifyOrderCanceled(ctx context.Context, orderID, customerID string) error
	NotifyOrderReady(ctx context.Context, orderID, customerID string) error
}

type Order

type Order struct {
	ID         string
	CustomerID string
	PaymentID  string
	InvoiceID  string
	ShoppingID string
	Items      []*Item
	Status     OrderStatus
}

func CreateOrder

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

func (*Order) Cancel

func (o *Order) Cancel() error

func (*Order) Complete

func (o *Order) Complete(invoiceID string) error

func (Order) GetTotal

func (o Order) GetTotal() float64

func (*Order) Ready

func (o *Order) Ready() error

type OrderRepository

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

type OrderStatus

type OrderStatus string
const (
	OrderUnknown   OrderStatus = ""
	OrderPending   OrderStatus = "pending"
	OrderInProcess OrderStatus = "in-progress"
	OrderReady     OrderStatus = "ready"
	OrderCompleted OrderStatus = "completed"
	OrderCancelled OrderStatus = "cancelled"
)

func ToOrderStatus

func ToOrderStatus(status string) OrderStatus

func (OrderStatus) String

func (s OrderStatus) String() string

type PaymentRepository

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

type ShoppingRepository

type ShoppingRepository interface {
	Create(ctx context.Context, order *Order) (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