resources

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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) MustModule

func (c *Included) MustModule(key Key) *Module

MustModule - returns Module 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) MustUser

func (c *Included) MustUser(key Key) *User

MustUser - returns User 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 Module

type Module struct {
	Key
	Attributes ModuleAttributes `json:"attributes"`
}

type ModuleAttributes

type ModuleAttributes struct {
	// indicates whether module (gitlab, telegram etc.) or service (unverified, role etc.)
	IsModule bool `json:"is_module"`
	// Module url
	Link string `json:"link"`
	// Module name
	Name string `json:"name"`
	// Module prefix to use in FE
	Prefix string `json:"prefix"`
	// Module name to use in FE
	Title string `json:"title"`
	// Module topic for sender and others
	Topic string `json:"topic"`
}

type ModuleListResponse

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

type ModuleResponse

type ModuleResponse struct {
	Data     Module   `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 (
	MODULES ResourceType = "modules"
	USER    ResourceType = "user"
)

List of ResourceType

type User

type User struct {
	Key
	Attributes UserAttributes `json:"attributes"`
}

type UserAttributes

type UserAttributes struct {
	// timestamp without timezone when user was created
	CreatedAt time.Time `json:"created_at"`
	// email from module
	Email *string `json:"email,omitempty"`
	// module name
	Module []string `json:"module"`
	// user id from module
	ModuleId string `json:"module_id"`
	// name from module
	Name *string `json:"name,omitempty"`
	// phone from module
	Phone *string `json:"phone,omitempty"`
	// submodule where user 'comes from'
	Submodule []string `json:"submodule"`
	// username from module
	Username *string `json:"username,omitempty"`
}

type UserListResponse

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

type UserResponse

type UserResponse struct {
	Data     User     `json:"data"`
	Included Included `json:"included"`
}

Jump to

Keyboard shortcuts

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