entities

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const ContentTypeHTML = "HTML"
View Source
const ContentTypeSimple = "SIMPLE"
View Source
const ProductStatusArchived = "ARCHIVED"
View Source
const ProductStatusAvailable = "AVAILABLE"

Variables

View Source
var ErrInvalidEntity = errors.New("invalid entity")

ErrInvalidEntity indicates the provided entity is invalid

View Source
var ErrInvalidID = errors.New("invalid id")

ErrInvalidID indicates the provided id is malformed

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

ErrNotFound indicates the requested entity is not found

Functions

func NewError

func NewError(status int, code openapi.GocomErrorCode, instance string, err error) error

NewError returns a new GoComError

Types

type Category

type Category struct {
	ID          ID
	Name        string
	Description string

	// ID of the parent.
	// uuid.Nil means it's a root category
	ParentID ID

	// Order (priority) of the category.
	// 1 = highest, inf = lowest
	Order int

	ProductIDs []ID

	Image *Image
}

Category data

func (*Category) Validate

func (c *Category) Validate() error

Validate validates the category data

type Content added in v0.3.0

type Content struct {
	Name        string
	ContentType ContentType
	Body        string
}

Content data

func (*Content) Validate added in v0.3.0

func (c *Content) Validate() error

Validate validates the content data

type ContentType added in v0.3.0

type ContentType string

func (ContentType) IsValid added in v0.3.0

func (contentType ContentType) IsValid() bool

func (ContentType) String added in v0.3.0

func (contentType ContentType) String() string

type Event added in v0.3.0

type Event struct {
	ID          ID
	Name        string
	Description string
	EventType   string
	Start       time.Time
	End         time.Time
	WholeDay    bool
}

Event data

func (*Event) Validate added in v0.3.0

func (e *Event) Validate() error

Validate validates the event data

type GoComError

type GoComError struct {
	// HTTP status code
	Status int `json:"status"`

	// Original error
	Err error `json:"-"`

	// Error code
	Code string `json:"code"`

	// Human-readable description of the error
	Message string `json:"message"`

	// Optional - On which object to error occurred
	Instance string `json:"instance"`
}

GoComError allows to bundle a status with the original error. This allows to fine-grained response codes at the API level.

func (*GoComError) Error

func (e *GoComError) Error() string

type ID

type ID = uuid.UUID

ID entity ID

func NewID

func NewID() ID

NewID create a new entity ID

func StringToID

func StringToID(s string) (ID, error)

StringToID convert a string to an entity ID

type Image

type Image struct {
	ID        ID
	Extension string // File extension
	URLs      map[string]string
	Order     int
}

func (*Image) SetURLsFromConfigs

func (img *Image) SetURLsFromConfigs(service imageproxy.Service, configs map[string]imageproxy.ImageConfig) error

SetURLsFromConfigs generates and sets an URL from the provided config

func (*Image) Validate

func (img *Image) Validate() error

Validate validates the product data

type Manufacturer

type Manufacturer struct {
	ID         ID
	Name       string
	WebsiteURL string
	Image      *Image
}

Manufacturer data

func (*Manufacturer) Validate

func (m *Manufacturer) Validate() error

Validate validates the manufacturer data

type Product

type Product struct {
	ID               ID
	CreatedAt        time.Time
	UpdatedAt        time.Time
	Name             string
	DescriptionShort string
	DescriptionLong  string

	// Price of a single product in cents (1/100)
	Price int

	CategoryIDs    []ID
	ManufacturerID ID
	Status         ProductStatus
	StockCount     int
	Images         []*Image
}

Product data

func (*Product) Validate

func (c *Product) Validate() error

Validate validates the product data

type ProductStatus

type ProductStatus string

func (ProductStatus) String

func (status ProductStatus) String() string

type ResolvedProduct

type ResolvedProduct struct {
	Product
	Manufacturer *Manufacturer
	Categories   []*Category
}

ResolvedProduct is a product for which related entities are included. This way all information is immediately at hand.

Jump to

Keyboard shortcuts

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