Documentation
¶
Index ¶
- Variables
- func FromJSON(i interface{}, r io.Reader) error
- func ToJSON(i interface{}, w io.Writer) error
- type Product
- type Products
- type ProductsDB
- func (pdb *ProductsDB) AddProduct(product Product)
- func (pdb *ProductsDB) DeleteProduct(id int) error
- func (pdb *ProductsDB) GetProductByID(id int, currency string) (*Product, error)
- func (pdb *ProductsDB) GetProductList(currency string) (Products, error)
- func (pdb *ProductsDB) UpdateProduct(p Product) error
- type Validation
- type ValidationError
- type ValidationErrors
Constants ¶
This section is empty.
Variables ¶
var ErrProductNotFound = fmt.Errorf("Product not found")
ErrProductNotFound is an error message when client requesting a product that can not be found or doesn't exist
Functions ¶
Types ¶
type Product ¶
type Product struct { // the id for the product // // required: false // min: 1 ID int `json:"id"` // the name for this poduct // // required: true // max length: 255 Name string `json:"name" validate:"required"` // the description for this poduct // // required: false // max length: 10000 Description string `json:"description"` // the price for the product // // required: true // min: 0.01 Price float64 `json:"price" validate:"gt=0,required"` // the SKU for the product // // required: true // pattern: [a-z]+-[0-9]+-[a-z]+ SKU string `json:"sku" validate:"sku,required"` }
Product defines the structure for an API product swagger:model
type ProductsDB ¶
type ProductsDB struct {
// contains filtered or unexported fields
}
ProductsDB is used to query data with
func NewProductsDB ¶
func NewProductsDB(log hclog.Logger, cc currency.CurrencyClient) *ProductsDB
NewProductsDB do something
func (*ProductsDB) AddProduct ¶
func (pdb *ProductsDB) AddProduct(product Product)
AddProduct is a function to add the requested product
func (*ProductsDB) DeleteProduct ¶
func (pdb *ProductsDB) DeleteProduct(id int) error
DeleteProduct is a function to delete the requested product
func (*ProductsDB) GetProductByID ¶
func (pdb *ProductsDB) GetProductByID(id int, currency string) (*Product, error)
GetProductByID return a product
func (*ProductsDB) GetProductList ¶
func (pdb *ProductsDB) GetProductList(currency string) (Products, error)
GetProductList do something
func (*ProductsDB) UpdateProduct ¶
func (pdb *ProductsDB) UpdateProduct(p Product) error
UpdateProduct is a function to update the requested product
type Validation ¶
type Validation struct {
// contains filtered or unexported fields
}
Validation is a struct for validation
func (*Validation) Validate ¶
func (v *Validation) Validate(i interface{}) ValidationErrors
Validate used for struct validation
type ValidationError ¶
type ValidationError struct {
validator.FieldError
}
ValidationError wraps the validators FieldError so we do not expose this to out code
func (ValidationError) Error ¶
func (ve ValidationError) Error() string
type ValidationErrors ¶
type ValidationErrors []ValidationError
ValidationErrors is an error collection of ValidationError
func (ValidationErrors) Errors ¶
func (ves ValidationErrors) Errors() []string
Errors converts the slice into a string slice