resources

package
v1.0.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category struct {
	Key
	Attributes CategoryAttributes `json:"attributes"`
}

type CategoryAttributes

type CategoryAttributes struct {
	CategoryName string `json:"category_name"`
	Unit         string `json:"unit"`
}

type CategoryListResponse

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

type CategoryResponse

type CategoryResponse struct {
	Data     Category `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) MustCategory

func (c *Included) MustCategory(key Key) *Category

MustCategory - returns Category 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) MustMeal

func (c *Included) MustMeal(key Key) *Meal

MustMeal - returns Meal 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) MustMealMenu

func (c *Included) MustMealMenu(key Key) *MealMenu

MustMealMenu - returns MealMenu 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) MustMenu

func (c *Included) MustMenu(key Key) *Menu

MustMenu - returns Menu 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) MustReceipt

func (c *Included) MustReceipt(key Key) *Receipt

MustReceipt - returns Receipt 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 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 Meal

type Meal struct {
	Key
	Attributes    MealAttributes    `json:"attributes"`
	Relationships MealRelationships `json:"relationships"`
}

type MealAttributes

type MealAttributes struct {
	Amount   float64 `json:"amount"`
	MealName string  `json:"meal_name"`
	Price    float64 `json:"price"`
}

type MealListResponse

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

type MealMenu

type MealMenu struct {
	Key
	Relationships MealMenuRelationships `json:"relationships"`
}

type MealMenuListResponse

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

type MealMenuRelationships

type MealMenuRelationships struct {
	Meal Relation `json:"meal"`
	Menu Relation `json:"menu"`
}

type MealMenuResponse

type MealMenuResponse struct {
	Data     MealMenu `json:"data"`
	Included Included `json:"included"`
}

type MealRelationships

type MealRelationships struct {
	Category Relation `json:"category"`
}

type MealResponse

type MealResponse struct {
	Data     Meal     `json:"data"`
	Included Included `json:"included"`
}
type Menu struct {
	Key
	Relationships MenuRelationships `json:"relationships"`
}
type MenuListResponse struct {
	Data     []Menu   `json:"data"`
	Included Included `json:"included"`
	Links    *Links   `json:"links"`
}
type MenuRelationships struct {
	Cafe Relation `json:"cafe"`
}
type MenuResponse struct {
	Data     Menu     `json:"data"`
	Included Included `json:"included"`
}

type Receipt

type Receipt struct {
	Key
	Attributes    ReceiptAttributes    `json:"attributes"`
	Relationships ReceiptRelationships `json:"relationships"`
}

type ReceiptAttributes

type ReceiptAttributes struct {
	Quantity int64 `json:"quantity"`
}

type ReceiptListResponse

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

type ReceiptRelationships

type ReceiptRelationships struct {
	Ingredient Relation `json:"ingredient"`
	Meal       Relation `json:"meal"`
}

type ReceiptResponse

type ReceiptResponse struct {
	Data     Receipt  `json:"data"`
	Included Included `json:"included"`
}

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 (
	CAFE_REF       ResourceType = "cafe_ref"
	CATEGORY       ResourceType = "category"
	INGREDIENT_REF ResourceType = "ingredient_ref"
	MEAL           ResourceType = "meal"
	MEAL_MENU      ResourceType = "meal_menu"
	MENU           ResourceType = "menu"
	RECEIPT        ResourceType = "receipt"
)

List of ResourceType

Jump to

Keyboard shortcuts

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