models

package module
v0.0.0-...-676a9f9 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 License: GPL-3.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorProductNotFound = fmt.Errorf("Product Not Found")

Functions

func AddCategory

func AddCategory(c *Category)

func AddProduct

func AddProduct(p *Product)

func DeleteProduct

func DeleteProduct(id int) error

func UpdateProduct

func UpdateProduct(id int, p *Product) error

Types

type Categories

type Categories []*Category

func GetCategories

func GetCategories() Categories

func (*Categories) ToJSON

func (c *Categories) ToJSON(w io.Writer) error

type Category

type Category struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	ImageURL    string `json:"image_url"`
}

func (*Category) FromJSON

func (c *Category) FromJSON(r io.Reader) error

func (*Category) ToJSON

func (c *Category) ToJSON(w io.Writer) error

type Product

type Product struct {
	ID          int     `json:"id"`
	Name        string  `json:"name"`
	Description string  `json:"description"`
	PriceGBP    float32 `json:"price"`
	SKU         string  `json:"sku"`
	ImageURL    string  `json:"image_url"`
}

func (*Product) FromJSON

func (p *Product) FromJSON(r io.Reader) error

func (*Product) ToJSON

func (p *Product) ToJSON(w io.Writer) error

type Products

type Products []*Product

func GetProducts

func GetProducts() Products

func (*Products) ToJSON

func (p *Products) ToJSON(w io.Writer) error

Jump to

Keyboard shortcuts

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