catalog

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMerchantNotSpecified no merchant given
	ErrMerchantNotSpecified = errors.New("merchant not specified")
	// ErrCatalogNotSpecified no catalog id given
	ErrCatalogNotSpecified = errors.New("Catalog ID was not specified")
	// ErrCategoryNotSpecified no categiry id given
	ErrCategoryNotSpecified = errors.New("Category ID was not specified")
	// ErrSizesNotSpecified no pizza size
	ErrSizesNotSpecified = errors.New("Pizza sizes were not specified")

	// ErrCrustsNotSpecified no pizza crust
	ErrCrustsNotSpecified = errors.New("Pizza crusts were not specified")
	// ErrCrustNameNotSpecified no pizza crust name
	ErrCrustNameNotSpecified = errors.New("Pizza crust name was not specified")

	// ErrEdgeNameNotSpecified no pizza edge name
	ErrEdgeNameNotSpecified = errors.New("Pizza edge name was not specified")
	// ErrEdgesNotSpecified no pizza edge
	ErrEdgesNotSpecified = errors.New("Pizza edges were not specified")

	// ErrToppingNameNotSpecified no pizza topping name
	ErrToppingNameNotSpecified = errors.New("Pizza Topping name was not specified")
	// ErrToppingsNotSpecified no pizza topping
	ErrToppingsNotSpecified = errors.New("Pizza Toppings were not specified")

	// ErrShiftsNotSpecified no shift
	ErrShiftsNotSpecified = errors.New("Pizza Shifts were not specified")

	// ErrSizeNameNotSpecified no pizza size
	ErrSizeNameNotSpecified = errors.New("Pizza size name was not specified")

	// ErrInvalidPizzaStatus no pizza status
	ErrInvalidPizzaStatus = errors.New("INVALID Pizza size status, it should be 'AVAILABLE' or 'UNAVAILABLE'")
	// ErrInvalidPizzaStartEndTime no pizza start/end time
	ErrInvalidPizzaStartEndTime = errors.New("INVALID Pizza start or end time, should be between 00:00 and 23:59")
	// ErrInvalidPizzaCrustStatus no pizza crust status
	ErrInvalidPizzaCrustStatus = errors.New("INVALID Pizza crust status, it should be 'AVAILABLE' or 'UNAVAILABLE'")
	// ErrInvalidPizzaEdgeStatus no pizza edge status
	ErrInvalidPizzaEdgeStatus = errors.New("INVALID Pizza edge status, it should be 'AVAILABLE' or 'UNAVAILABLE'")
	// ErrInvalidPizzaToppingStatus no pizza topping status
	ErrInvalidPizzaToppingStatus = errors.New("INVALID Pizza topping status, it should be 'AVAILABLE' or 'UNAVAILABLE'")

	// ErrNoAcceptedFractions no pizza fractions
	ErrNoAcceptedFractions = errors.New("Pizza needs at least one accepted fraction")

	// ErrNoProductName no product name
	ErrNoProductName = errors.New("Product needs a name")
	// ErrNoProductID no product id
	ErrNoProductID = errors.New("productID not specified")
	// ErrNoItemPrice no item price
	ErrNoItemPrice = errors.New("item needs the price value to be specified")
	// ErrNoPrice no price
	ErrNoPrice = errors.New("item needs the price struct filled")
	// ErrInvalidStatus invalid status
	ErrInvalidStatus = errors.New("INVALID status, it should be 'AVAILABLE' or 'UNAVAILABLE'")
	// ErrNoShifts no shift
	ErrNoShifts = errors.New("Item needs at least one shift")
)

Functions

func New

func New(adapter adapters.Http, authService auth.Service) *catalogService

New returns an implementation of the catalog service

Types

type Catalog

type Catalog struct {
	ID         string   `json:"catalogId"`
	Context    []string `json:"context"`
	Status     string   `json:"status"`
	ModifiedAt string   `json:"modifiedAt"`
}

Catalog API response

type Catalogs

type Catalogs []Catalog

Catalogs group of Catalog

type Category

type Category struct {
	ID                   string           `json:"id"`
	Status               string           `json:"status"`
	Template             string           `json:"template"`
	Restrictions         []string         `json:"restrictions"`
	UnsellableItems      []UnsellableItem `json:"unsellableItems"`
	UnsellablePizzaItems Pizza            `json:"unsellablePizzaItems"`
}

Category struct

type CategoryCreateResponse

type CategoryCreateResponse struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	ExternalCode string `json:"externalCode"`
	Status       string `json:"status"`
	Sequence     int    `json:"sequence"`
	Template     string `json:"template"`
}

CategoryCreateResponse create API response

type CategoryItem

type CategoryItem struct {
	ID                  string    `json:"id"`
	Name                string    `json:"name"`
	Status              string    `json:"status"`
	ExternalCode        string    `json:"externalCode"`
	Template            string    `json:"template"`
	AcceptedFractions   []float64 `json:"acceptedFractions"`
	DietaryRestrictions []string  `json:"dietaryRestrictions"`
	Sequence            int       `json:"sequence"`
	Price               Price     `json:"price"`
	Shifts              []Shift   `json:"shifts"`
}

CategoryItem linked product to a category

type CategoryResponse

type CategoryResponse struct {
	ID           string `json:"id"`
	Sequence     int    `json:"sequence"`
	Name         string `json:"name"`
	ExternalCode string `json:"externalCode"`
	Status       string `json:"status"`
	Items        []Item `json:"items"`
	Template     string `json:"template"`
	Pizza        Pizza  `json:"pizza"`
}

CategoryResponse from API when creating

type Item

type Item struct {
	ID                  string   `json:"id"`
	Name                string   `json:"name"`
	Description         string   `json:"description"`
	ExternalCode        string   `json:"externalCode"`
	Status              string   `json:"status"`
	ProductID           string   `json:"productId"`
	Sequence            int      `json:"sequence"`
	MagePath            string   `json:"magePath"`
	Price               Price    `json:"price"`
	Shifts              []Shift  `json:"shifts"`
	Serving             string   `json:"serving"`
	DietaryRestrictions []string `json:"dietaryRestrictions"`
	Ean                 string   `json:"ean"`
	OptionGroups        []struct {
		ID           string `json:"id"`
		Name         string `json:"name"`
		ExternalCode string `json:"externalCode"`
		Status       string `json:"status"`
		Sequence     int    `json:"sequence"`
		Min          int    `json:"min"`
		Max          int    `json:"max"`
		Options      struct {
			ID           string `json:"id"`
			Status       string `json:"status"`
			Sequence     int    `json:"sequence"`
			ProductID    string `json:"productId"`
			Name         string `json:"name"`
			Description  string `json:"description"`
			ExternalCode string `json:"externalCode"`
			ImagePath    string `json:"imagePath"`
			Price        Price  `json:"price"`
		} `json:"options"`
	} `json:"optionGroups"`
}

Item product description

type Pizza

type Pizza struct {
	ID       string         `json:"id"`
	Sizes    []CategoryItem `json:"sizes"`
	Crusts   []CategoryItem `json:"crusts"`
	Edges    []CategoryItem `json:"edges"`
	Toppings []CategoryItem `json:"toppings"`
	Shifts   []Shift        `json:"shifts"`
}

Pizza type requested by the API

type Pizzas

type Pizzas []Pizza

Pizzas is a group of pizza

type Price

type Price struct {
	Value         float64 `json:"value"`
	OriginalValue float64 `json:"originalValue"`
}

Price of a product object

type Product

type Product struct {
	ID                  string   `json:"id"`
	Name                string   `json:"name"`
	Description         string   `json:"description"`
	ExternalCode        string   `json:"externalCode"`
	Image               string   `json:"image"`
	Shifts              []Shift  `json:"shifts"`
	Serving             string   `json:"serving"`
	DietaryRestrictions []string `json:"dietaryRestrictions"`
	Ean                 string   `json:"ean"`
}

Product API response

type ProductLink struct {
	Status              string   `json:"status"`
	ID                  string   `json:"id"`
	Name                string   `json:"name"`
	Description         string   `json:"description"`
	ExternalCode        string   `json:"externalCode"`
	Image               string   `json:"image"`
	Price               Price    `json:"price"`
	Shifts              []Shift  `json:"shifts"`
	Serving             string   `json:"serving"`
	Sequence            int      `json:"sequence"`
	DietaryRestrictions []string `json:"dietaryRestrictions"`
	Ean                 string   `json:"ean"`
}

ProductLink API response

type Products

type Products []Product

Products are many product

type Service

type Service interface {
	ListAllV2(merchantID string) (Catalogs, error)
	ListUnsellableItems(merchantUUID, catalogID string) (UnsellableResponse, error)
	ListAllCategoriesInCatalog(merchantUUID, catalogID string) (CategoryResponse, error)
	CreateCategoryInCatalog(merchantUUID, catalogID, name, resourceStatus, template, externalCode string) (CategoryCreateResponse, error)
	GetCategoryInCatalog(merchantUUID, catalogID, categoryID string) (CategoryResponse, error)
	EditCategoryInCatalog(merchantUUID, catalogID, categoryID, name, resourceStatus, externalCode string, sequence int) (CategoryCreateResponse, error)
	DeleteCategoryInCatalog(merchantUUID, catalogID, categoryID string) error
	ListProducts(merchantUUID string) (Products, error)
	CreateProduct(merchantUUID string, product Product) (Product, error)
	EditProduct(merchantUUID string, product Product) (Product, error)
	DeleteProduct(merchantUUID, productID string) error
	UpdateProductStatus(merchantUUID, productID, productStatus string) error
	LinkProductToCategory(merchantUUID, categoryID string, product ProductLink) error
	CreatePizza(merchantUUID string, pizza Pizza) (Pizza, error)
	ListPizzas(merchantUUID string) (Pizzas, error)
	UpdatePizza(merchantUUID string, pizza Pizza) error
	UpdatePizzaStatus(merchantUUID, pizzaStatus, pizzaID string) error
	UnlinkPizzaCategory(merchantUUID, pizzaID, categoryID string) error
	LinkPizzaToCategory(merchantUUID, categoryID string, pizza Pizza) error
	UnlinkProductToCategory(merchantUUID, categoryID, productID string) error
}

Service describes the catalog abstraction

type Shift

type Shift struct {
	StartTime string `json:"startTime"`
	EndTime   string `json:"endTime"`
	Monday    bool   `json:"monday"`
	Tuesday   bool   `json:"tuesday"`
	Wednesday bool   `json:"wednesday"`
	Thursday  bool   `json:"thursday"`
	Friday    bool   `json:"friday"`
	Saturday  bool   `json:"saturday"`
	Sunday    bool   `json:"sunday"`
}

Shift of a Item or CategoryItem

type UnsellableItem

type UnsellableItem struct {
	ID           string   `json:"id"`
	ProductID    string   `json:"productId"`
	Restrictions []string `json:"restrictions"`
}

UnsellableItem part of Category struct

type UnsellableResponse

type UnsellableResponse struct {
	Categories []Category `json:"categories"`
}

UnsellableResponse API response

Jump to

Keyboard shortcuts

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