model

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateReference

func GenerateReference() string

GenerateReference generates a random reference using UUID

func IsSKU

func IsSKU(input string) bool

IsSKU checks if the input string is an SKU

Types

type AddItemsRequest

type AddItemsRequest struct {
	Items []*Item `json:"items"`
}

type HealthResponse

type HealthResponse struct {
	Version  string   `json:"version,omitempty"`
	Service  string   `json:"service,omitempty"`
	Failures []string `json:"failures"`
}

HealthResponse contains health probe response fields.

type Item

type Item struct {
	ID                int     `json:"id,omitempty" gorm:"primaryKey;type:integer"`
	SKU               string  `json:"sku" gorm:"column:sku;type:string;unique"`
	Name              string  `json:"name" gorm:"column:name;type:string;unique"`
	Price             float64 `json:"price" gorm:"column:price;type:double"`
	InventoryQuantity int     `json:"inventory_quantity" gorm:"column:inventory_quantity;type:integer"`
}

func (*Item) TableName

func (i *Item) TableName() string

func (*Item) Validate

func (i *Item) Validate() error

type ItemsPriceRequest

type ItemsPriceRequest struct {
	SKUs []string `json:"skus"`
}

type Order

type Order struct {
	ID        int     `json:"id,omitempty" gorm:"primaryKey;type:integer"`
	Reference string  `json:"reference" gorm:"column:reference;type:string;uniqueIndex"` // Unique random reference
	SKUList   string  `json:"sku_list" gorm:"column:sku_list;type:text"`
	Price     float64 `json:"cost" gorm:"column:price;type:double"`
}

func (*Order) GetSKUList

func (o *Order) GetSKUList() ([]string, error)

GetSKUList returns the SKU list as a slice of strings

func (*Order) SetSKUList

func (o *Order) SetSKUList(skuList []string) error

SetSKUList sets the SKU list from a slice of strings

func (*Order) TableName

func (o *Order) TableName() string

type Orders

type Orders []Order

type PriceResponse

type PriceResponse struct {
	Items             []*Item     `json:"items"`
	Promotions        *Promotions `json:"promotions,omitempty"`
	TotalGross        float64     `json:"total_gross"`
	TotalWithDiscount float64     `json:"total_with_discount"`
}

type Promotions

type Promotions struct {
	Deduction  float64 `json:"deduction"`
	AddedItems []*Item `json:"added_items"`
}

type PurchaseItemsRequest

type PurchaseItemsRequest struct {
	SKUs []string `json:"skus"`
}

type PurchaseItemsResponse

type PurchaseItemsResponse struct {
	OrderReference string  `json:"order_reference"`
	Cost           float64 `json:"cost"`
}

type StatusResponse

type StatusResponse struct {
	Message string `json:"message,omitempty"`
	Version string `json:"version,omitempty"`
	Service string `json:"service,omitempty"`
}

StatusResponse contains status response fields.

Jump to

Keyboard shortcuts

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