infrastructure

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2020 License: OSL-3.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CartStorage

type CartStorage interface {
	GetCart(id string) (*domaincart.Cart, error)
	HasCart(id string) bool
	StoreCart(cart *domaincart.Cart) error
}

CartStorage Interface - might be implemented by other persistence types later as well

type InMemoryBehaviour

type InMemoryBehaviour struct {
	// contains filtered or unexported fields
}

InMemoryBehaviour defines the in memory cart order behaviour

func (*InMemoryBehaviour) AddToCart

func (cob *InMemoryBehaviour) AddToCart(ctx context.Context, cart *domaincart.Cart, deliveryCode string, addRequest domaincart.AddRequest) (*domaincart.Cart, domaincart.DeferEvents, error)

AddToCart add an item to the cart

func (*InMemoryBehaviour) ApplyAny

ApplyAny applies a voucher or giftcard to the cart

func (*InMemoryBehaviour) ApplyGiftCard

func (cob *InMemoryBehaviour) ApplyGiftCard(ctx context.Context, cart *domaincart.Cart, giftCardCode string) (*domaincart.Cart, domaincart.DeferEvents, error)

ApplyGiftCard applies a gift card to the cart if a GiftCard is applied, it will be added to the array AppliedGiftCards on the cart

func (*InMemoryBehaviour) ApplyVoucher

func (cob *InMemoryBehaviour) ApplyVoucher(ctx context.Context, cart *domaincart.Cart, couponCode string) (*domaincart.Cart, domaincart.DeferEvents, error)

ApplyVoucher applies a voucher to the cart

func (*InMemoryBehaviour) CleanCart

CleanCart removes all deliveries and their items from the cart

func (*InMemoryBehaviour) CleanDelivery

func (cob *InMemoryBehaviour) CleanDelivery(ctx context.Context, cart *domaincart.Cart, deliveryCode string) (*domaincart.Cart, domaincart.DeferEvents, error)

CleanDelivery removes a complete delivery with its items from the cart

func (*InMemoryBehaviour) DeleteItem

func (cob *InMemoryBehaviour) DeleteItem(ctx context.Context, cart *domaincart.Cart, itemID string, deliveryCode string) (*domaincart.Cart, domaincart.DeferEvents, error)

DeleteItem removes an item from the cart

func (*InMemoryBehaviour) GetCart

func (cob *InMemoryBehaviour) GetCart(ctx context.Context, cartID string) (*domaincart.Cart, error)

GetCart returns the current cart from storage

func (*InMemoryBehaviour) Inject

func (cob *InMemoryBehaviour) Inject(
	CartStorage CartStorage,
	ProductService domain.ProductService,
	Logger flamingo.Logger,
	itemBuilderProvider domaincart.ItemBuilderProvider,
	deliveryBuilderProvider domaincart.DeliveryBuilderProvider,
	cartBuilderProvider domaincart.BuilderProvider,
	eventPublisher events.EventPublisher,
	config *struct {
		DefaultTaxRate float64 `inject:"config:commerce.cart.inMemoryCartServiceAdapter.defaultTaxRate,optional"`
	},
)

Inject dependencies

func (*InMemoryBehaviour) RemoveGiftCard

func (cob *InMemoryBehaviour) RemoveGiftCard(ctx context.Context, cart *domaincart.Cart, giftCardCode string) (*domaincart.Cart, domaincart.DeferEvents, error)

RemoveGiftCard removes a gift card from the cart if a GiftCard is removed, it will be removed from the array AppliedGiftCards on the cart

func (*InMemoryBehaviour) RemoveVoucher

func (cob *InMemoryBehaviour) RemoveVoucher(ctx context.Context, cart *domaincart.Cart, couponCode string) (*domaincart.Cart, domaincart.DeferEvents, error)

RemoveVoucher removes a voucher from the cart

func (*InMemoryBehaviour) UpdateAdditionalData

func (cob *InMemoryBehaviour) UpdateAdditionalData(ctx context.Context, cart *domaincart.Cart, additionalData *domaincart.AdditionalData) (*domaincart.Cart, domaincart.DeferEvents, error)

UpdateAdditionalData updates additional data

func (*InMemoryBehaviour) UpdateBillingAddress

func (cob *InMemoryBehaviour) UpdateBillingAddress(ctx context.Context, cart *domaincart.Cart, billingAddress domaincart.Address) (*domaincart.Cart, domaincart.DeferEvents, error)

UpdateBillingAddress - updates address

func (*InMemoryBehaviour) UpdateDeliveryInfo

func (cob *InMemoryBehaviour) UpdateDeliveryInfo(ctx context.Context, cart *domaincart.Cart, deliveryCode string, deliveryInfoUpdateCommand domaincart.DeliveryInfoUpdateCommand) (*domaincart.Cart, domaincart.DeferEvents, error)

UpdateDeliveryInfo updates a delivery info

func (*InMemoryBehaviour) UpdateDeliveryInfoAdditionalData

func (cob *InMemoryBehaviour) UpdateDeliveryInfoAdditionalData(ctx context.Context, cart *domaincart.Cart, deliveryCode string, additionalData *domaincart.AdditionalData) (*domaincart.Cart, domaincart.DeferEvents, error)

UpdateDeliveryInfoAdditionalData @todo implement when needed

func (*InMemoryBehaviour) UpdateItem

UpdateItem updates a cart item

func (*InMemoryBehaviour) UpdateItems

func (cob *InMemoryBehaviour) UpdateItems(ctx context.Context, cart *domaincart.Cart, itemUpdateCommands []domaincart.ItemUpdateCommand) (*domaincart.Cart, domaincart.DeferEvents, error)

UpdateItems updates multiple cart items

func (*InMemoryBehaviour) UpdatePaymentSelection

func (cob *InMemoryBehaviour) UpdatePaymentSelection(ctx context.Context, cart *domaincart.Cart, paymentSelection domaincart.PaymentSelection) (*domaincart.Cart, domaincart.DeferEvents, error)

UpdatePaymentSelection updates payment on cart

func (*InMemoryBehaviour) UpdatePurchaser

func (cob *InMemoryBehaviour) UpdatePurchaser(ctx context.Context, cart *domaincart.Cart, purchaser *domaincart.Person, additionalData *domaincart.AdditionalData) (*domaincart.Cart, domaincart.DeferEvents, error)

UpdatePurchaser @todo implement when needed

type InMemoryCartStorage

type InMemoryCartStorage struct {
	// contains filtered or unexported fields
}

InMemoryCartStorage - for now the default implementation of GuestCartStorage

func (*InMemoryCartStorage) GetCart

func (s *InMemoryCartStorage) GetCart(id string) (*domaincart.Cart, error)

GetCart returns a cart with the given id from the cart storage

func (*InMemoryCartStorage) HasCart

func (s *InMemoryCartStorage) HasCart(id string) bool

HasCart checks if the cart storage has a cart with a given id

func (*InMemoryCartStorage) StoreCart

func (s *InMemoryCartStorage) StoreCart(cart *domaincart.Cart) error

StoreCart stores a cart in the storage

type InMemoryCustomerCartService

type InMemoryCustomerCartService struct {
	// contains filtered or unexported fields
}

InMemoryCustomerCartService defines the in memory customer cart service

func (*InMemoryCustomerCartService) GetCart

func (gcs *InMemoryCustomerCartService) GetCart(ctx context.Context, auth domain.Auth, cartID string) (*cart.Cart, error)

GetCart gets a customer cart from the in memory customer cart service

func (*InMemoryCustomerCartService) GetModifyBehaviour

GetModifyBehaviour gets the cart order behaviour of the service

func (*InMemoryCustomerCartService) Inject

func (gcs *InMemoryCustomerCartService) Inject(
	InMemoryBehaviour *InMemoryBehaviour,
)

Inject dependencies

func (*InMemoryCustomerCartService) RestoreCart

func (gcs *InMemoryCustomerCartService) RestoreCart(ctx context.Context, auth domain.Auth, cart cart.Cart) (*cart.Cart, error)

RestoreCart restores a previously used cart

type InMemoryGuestCartService

type InMemoryGuestCartService struct {
	// contains filtered or unexported fields
}

InMemoryGuestCartService defines the in memory guest cart service

func (*InMemoryGuestCartService) GetCart

func (gcs *InMemoryGuestCartService) GetCart(ctx context.Context, cartID string) (*cart.Cart, error)

GetCart fetches a cart from the in memory guest cart service

func (*InMemoryGuestCartService) GetModifyBehaviour

func (gcs *InMemoryGuestCartService) GetModifyBehaviour(context.Context) (cart.ModifyBehaviour, error)

GetModifyBehaviour returns the cart order behaviour of the service

func (*InMemoryGuestCartService) GetNewCart

func (gcs *InMemoryGuestCartService) GetNewCart(ctx context.Context) (*cart.Cart, error)

GetNewCart gets a new cart from the in memory guest cart service

func (*InMemoryGuestCartService) Inject

func (gcs *InMemoryGuestCartService) Inject(
	InMemoryCartOrderBehaviour *InMemoryBehaviour,
)

Inject dependencies

func (*InMemoryGuestCartService) RestoreCart

func (gcs *InMemoryGuestCartService) RestoreCart(ctx context.Context, cart cart.Cart) (*cart.Cart, error)

RestoreCart restores a previously used guest cart

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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