domain

package
v0.0.0-...-76fafce Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CustomerRegisteredEvent = "customers.CustomerRegistered"
	CustomerSmsChangedEvent = "customers.CustomerSmsChanged"
	CustomerAuthorizedEvent = "customers.CustomerAuthorized"
	CustomerEnabledEvent    = "customers.CustomerEnabled"
	CustomerDisabledEvent   = "customers.CustomerDisabled"
)
View Source
const CustomerAggregate = "customers.CustomerAggregate"

Variables

View Source
var (
	ErrNameCannotBeBlank       = errors.Wrap(errors.ErrBadRequest, "the customer name cannot be blank")
	ErrCustomerIDCannotBeBlank = errors.Wrap(errors.ErrBadRequest, "the customer id cannot be blank")
	ErrSmsNumberCannotBeBlank  = errors.Wrap(errors.ErrBadRequest, "the SMS number cannot be blank")
	ErrCustomerAlreadyEnabled  = errors.Wrap(errors.ErrBadRequest, "the customer is already enabled")
	ErrCustomerAlreadyDisabled = errors.Wrap(errors.ErrBadRequest, "the customer is already disabled")
	ErrCustomerNotAuthorized   = errors.Wrap(errors.ErrUnauthorized, "customer is not authorized")
)

Functions

This section is empty.

Types

type Customer

type Customer struct {
	ddd.Aggregate
	Name      string
	SmsNumber string
	Enabled   bool
}

func NewCustomer

func NewCustomer(id string) *Customer

func RegisterCustomer

func RegisterCustomer(id, name, smsNumber string) (*Customer, error)

func (*Customer) Authorize

func (c *Customer) Authorize() error

func (*Customer) Disable

func (c *Customer) Disable() error

func (*Customer) Enable

func (c *Customer) Enable() error

func (Customer) Key

func (Customer) Key() string

type CustomerAuthorized

type CustomerAuthorized struct {
	Customer *Customer
}

func (CustomerAuthorized) Key

func (CustomerAuthorized) Key() string

type CustomerDisabled

type CustomerDisabled struct {
	Customer *Customer
}

func (CustomerDisabled) Key

func (CustomerDisabled) Key() string

type CustomerEnabled

type CustomerEnabled struct {
	Customer *Customer
}

func (CustomerEnabled) Key

func (CustomerEnabled) Key() string

type CustomerRegistered

type CustomerRegistered struct {
	Customer *Customer
}

func (CustomerRegistered) Key

func (CustomerRegistered) Key() string

type CustomerRepository

type CustomerRepository interface {
	Save(ctx context.Context, customer *Customer) error
	Find(ctx context.Context, customerID string) (*Customer, error)
	Update(ctx context.Context, customer *Customer) error
}

type CustomerSmsChanged

type CustomerSmsChanged struct {
	Customer *Customer
}

func (CustomerSmsChanged) Key

func (CustomerSmsChanged) Key() string

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) Find

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

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

func (*MockCustomerRepository) Save

func (_m *MockCustomerRepository) Save(ctx context.Context, customer *Customer) error

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

func (*MockCustomerRepository) Update

func (_m *MockCustomerRepository) Update(ctx context.Context, customer *Customer) error

Update provides a mock function with given fields: ctx, customer

Jump to

Keyboard shortcuts

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