resources

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Key
	Attributes AddressAttributes `json:"attributes"`
}

type AddressAttributes

type AddressAttributes struct {
	Building   int64  `json:"building"`
	City       string `json:"city"`
	District   string `json:"district"`
	PostalCode string `json:"postal_code"`
	Region     string `json:"region"`
	Street     string `json:"street"`
}

type AddressListResponse

type AddressListResponse struct {
	Data     []Address `json:"data"`
	Included Included  `json:"included"`
	Links    *Links    `json:"links"`
}

type AddressResponse

type AddressResponse struct {
	Data     Address  `json:"data"`
	Included Included `json:"included"`
}

type Delivery

type Delivery struct {
	Key
	Attributes    DeliveryAttributes    `json:"attributes"`
	Relationships DeliveryRelationships `json:"relationships"`
}

type DeliveryAttributes

type DeliveryAttributes struct {
	Date  time.Time `json:"date"`
	Price float64   `json:"price"`
}

type DeliveryListResponse

type DeliveryListResponse struct {
	Data     []Delivery `json:"data"`
	Included Included   `json:"included"`
	Links    *Links     `json:"links"`
}

type DeliveryRelationships

type DeliveryRelationships struct {
	Destination Relation `json:"destination"`
	Source      Relation `json:"source"`
}

type DeliveryResponse

type DeliveryResponse struct {
	Data     Delivery `json:"data"`
	Included Included `json:"included"`
}

type Details

type Details json.RawMessage

func (Details) MarshalJSON

func (d Details) MarshalJSON() ([]byte, error)

MarshalJSON - casts Details to []byte

func (*Details) Scan

func (r *Details) Scan(src interface{}) error

Scan - implements db driver method for auto unmarshal

func (Details) String

func (d Details) String() string

func (*Details) UnmarshalJSON

func (d *Details) UnmarshalJSON(data []byte) error

UnmarshalJSON - casts data to Details

func (Details) Value

func (r Details) Value() (driver.Value, error)

Value - implements db driver method for auto marshal

type Flag

type Flag struct {
	Name  string `json:"name"`
	Value int32  `json:"value"`
}

type Flagger

type Flagger interface {
	IsFlag() bool
}

type Flags

type Flags struct {
	Mask   int32  `json:"mask"`
	Values []Flag `json:"flags"`
}

func FlagsFromMask

func FlagsFromMask(mask int32, allFlags map[int32]string) Flags

type Included

type Included struct {
	// contains filtered or unexported fields
}

Included - an array of Resource objects that are related to the primary data and/or each other (“included resources”).

func (*Included) Add

func (c *Included) Add(includes ...Resource)

Add - adds new include into collection. If one already present - skips it

func (Included) MarshalJSON

func (c Included) MarshalJSON() ([]byte, error)

MarshalJSON - marshals include collection as array of json objects

func (*Included) MustAddress

func (c *Included) MustAddress(key Key) *Address

MustAddress - returns Address from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustDelivery

func (c *Included) MustDelivery(key Key) *Delivery

MustDelivery - returns Delivery from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustIngredient

func (c *Included) MustIngredient(key Key) *Ingredient

MustIngredient - returns Ingredient from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustUsedIngredient

func (c *Included) MustUsedIngredient(key Key) *UsedIngredient

MustUsedIngredient - returns UsedIngredient from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustWarehouse

func (c *Included) MustWarehouse(key Key) *Warehouse

MustWarehouse - returns Warehouse from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) MustWarehouseIngredient

func (c *Included) MustWarehouseIngredient(key Key) *WarehouseIngredient

MustWarehouseIngredient - returns WarehouseIngredient from include collection. if entry with specified key does not exist - returns nil if entry with specified key exists but type or ID mismatches - panics

func (*Included) UnmarshalJSON

func (c *Included) UnmarshalJSON(data []byte) error

UmarshalJSON - unmarshal array of json objects into include collection

type Ingredient

type Ingredient struct {
	Key
	Attributes IngredientAttributes `json:"attributes"`
}

type IngredientAttributes

type IngredientAttributes struct {
	Name string `json:"name"`
}

type IngredientListResponse

type IngredientListResponse struct {
	Data     []Ingredient `json:"data"`
	Included Included     `json:"included"`
	Links    *Links       `json:"links"`
}

type IngredientResponse

type IngredientResponse struct {
	Data     Ingredient `json:"data"`
	Included Included   `json:"included"`
}

type Key

type Key struct {
	ID   string       `json:"id"`
	Type ResourceType `json:"type"`
}

func NewKeyInt64

func NewKeyInt64(id int64, resourceType ResourceType) Key

func (Key) AsRelation

func (r Key) AsRelation() *Relation

func (*Key) GetKey

func (r *Key) GetKey() Key

func (Key) GetKeyP

func (r Key) GetKeyP() *Key
type Links struct {
	First string `json:"first"`
	Last  string `json:"last"`
	Next  string `json:"next"`
	Prev  string `json:"prev"`
	Self  string `json:"self"`
}

type Relation

type Relation struct {
	Data  *Key   `json:"data,omitempty"`
	Links *Links `json:"links,omitempty"`
}

type RelationCollection

type RelationCollection struct {
	Data  []Key  `json:"data"`
	Links *Links `json:"links,omitempty"`
}

func (RelationCollection) MarshalJSON

func (r RelationCollection) MarshalJSON() ([]byte, error)

type Resource

type Resource interface {
	//GetKey - returns key of the Resource
	GetKey() Key
}

type ResourceType

type ResourceType string
const (
	ADDRESS              ResourceType = "address"
	DELIVERY             ResourceType = "delivery"
	INGREDIENT           ResourceType = "ingredient"
	USED_INGREDIENT      ResourceType = "used_ingredient"
	WAREHOUSE_INGREDIENT ResourceType = "warehouse_ingredient"
	WAREHOUSE            ResourceType = "warehouse"
)

List of ResourceType

type UsedIngredient

type UsedIngredient struct {
	Key
	Attributes UsedIngredientAttributes `json:"attributes"`
}

type UsedIngredientAttributes

type UsedIngredientAttributes struct {
	DeletionDate time.Time `json:"deletion_date"`
	Name         string    `json:"name"`
	Origin       string    `json:"origin"`
	Price        float64   `json:"price"`
	Quantity     int64     `json:"quantity"`
	Reason       string    `json:"reason"`
}

type UsedIngredientListResponse

type UsedIngredientListResponse struct {
	Data     []UsedIngredient `json:"data"`
	Included Included         `json:"included"`
	Links    *Links           `json:"links"`
}

type UsedIngredientResponse

type UsedIngredientResponse struct {
	Data     UsedIngredient `json:"data"`
	Included Included       `json:"included"`
}

type Warehouse

type Warehouse struct {
	Key
	Attributes    WarehouseAttributes    `json:"attributes"`
	Relationships WarehouseRelationships `json:"relationships"`
}

type WarehouseAttributes

type WarehouseAttributes struct {
	CafeId   int64 `json:"cafe_id"`
	Capacity int64 `json:"capacity"`
}

type WarehouseIngredient

type WarehouseIngredient struct {
	Key
	Attributes    WarehouseIngredientAttributes    `json:"attributes"`
	Relationships WarehouseIngredientRelationships `json:"relationships"`
}

type WarehouseIngredientAttributes

type WarehouseIngredientAttributes struct {
	ExpirationDate time.Time `json:"expiration_date"`
	Origin         string    `json:"origin"`
	Price          float64   `json:"price"`
	Quantity       int64     `json:"quantity"`
}

type WarehouseIngredientListResponse

type WarehouseIngredientListResponse struct {
	Data     []WarehouseIngredient `json:"data"`
	Included Included              `json:"included"`
	Links    *Links                `json:"links"`
}

type WarehouseIngredientRelationships

type WarehouseIngredientRelationships struct {
	Delivery   Relation `json:"delivery"`
	Ingredient Relation `json:"ingredient"`
	Warehouse  Relation `json:"warehouse"`
}

type WarehouseIngredientResponse

type WarehouseIngredientResponse struct {
	Data     WarehouseIngredient `json:"data"`
	Included Included            `json:"included"`
}

type WarehouseListResponse

type WarehouseListResponse struct {
	Data     []Warehouse `json:"data"`
	Included Included    `json:"included"`
	Links    *Links      `json:"links"`
}

type WarehouseRelationships

type WarehouseRelationships struct {
	Address Relation `json:"address"`
}

type WarehouseResponse

type WarehouseResponse struct {
	Data     Warehouse `json:"data"`
	Included Included  `json:"included"`
}

Jump to

Keyboard shortcuts

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