Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrMismatchingUnit when the unit of the 2 prices do not match when using Add ErrMismatchingUnit = errors.New("the unit is not the same") // ErrMismatchingCurrency when the currency of the 2 prices do not match when using Add ErrMismatchingCurrency = errors.New("the currency is not the same") )
Functions ¶
This section is empty.
Types ¶
type AttributeFilter ¶
AttributeFilter is used for filtering of prices by attribute.
type Filter ¶
type Filter struct { Unit *string Currency *string AttributeFilters []*AttributeFilter }
Filter is used to filter prices.
type Price ¶
type Price struct { ID ID Unit string Currency string Value decimal.Decimal Attributes map[string]string }
Price is a single pricing entry for a product.
func (*Price) Add ¶ added in v0.5.0
Add checks that the 2 prices can be added together (unit/currency) and then performs an addition and also joins the attributes and replacing repeated ones for the new ones (pr)
func (*Price) GenerateHash ¶
GenerateHash generates the Hash field of the Price, equal to the MD5 sum of its unique values.
type Repository ¶
type Repository interface { // Filter returns Prices with attributes matching the product.ID and Filter. Filter(ctx context.Context, productID product.ID, filter *Filter) ([]*Price, error) // Upsert updates a Price or creates a new one if it doesn't already exist. Upsert(ctx context.Context, p *WithProduct) (ID, error) // DeleteByProductWithKeep deletes all Prices of the specified product.ID except the ones with ID in the keep slice. DeleteByProductWithKeep(ctx context.Context, productID product.ID, keep []ID) error }
Repository describes interactions with a storage system to deal with Price entries.
type WithProduct ¶
WithProduct is an aggregation of a Price with a product.Product.
Click to show internal directories.
Click to hide internal directories.