productcatalog

package
v0.0.0-...-5d322a5 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrProductNotFound = errors.New("product not found")

Functions

func NewInMemory

func NewInMemory() *inMemory

func NewPostgres

func NewPostgres(db *sql.DB) postgres

func NewProductBuilder

func NewProductBuilder() productBuilder

Types

type Price

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

func NewPrice

func NewPrice(amount float64, currency string) Price

func (Price) Amount

func (p Price) Amount() float64

func (Price) Currency

func (p Price) Currency() string

type Product

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

Product is an entity that represents a single product visable in the product catalog

func NewProduct

func NewProduct(id ProductID, name, description string, price Price, thumbnail string) (Product, error)

func (Product) Description

func (p Product) Description() string

func (Product) ID

func (p Product) ID() ProductID

func (Product) Name

func (p Product) Name() string

func (Product) Price

func (p Product) Price() Price

func (Product) Thumbnail

func (p Product) Thumbnail() string

type ProductID

type ProductID string

func NewProductId

func NewProductId(id string) (ProductID, error)

type ProductService

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

func NewProductService

func NewProductService(s ProductStorage) ProductService

func (ProductService) Add

func (ps ProductService) Add(ctx context.Context, id, name, desc string, price float64, currency string) error

func (ProductService) AllProducts

func (ps ProductService) AllProducts(ctx context.Context) ([]Product, error)

func (ProductService) Find

func (ps ProductService) Find(ctx context.Context, id string) (Product, error)

type ProductStorage

type ProductStorage interface {
	All(ctx context.Context) ([]Product, error)
	Add(ctx context.Context, p Product) error
	Find(ctx context.Context, id string) (Product, error)
}

Jump to

Keyboard shortcuts

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