models

package
v0.0.0-...-eab4cf6 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFieldNotFound = fmt.Errorf("field not found")

Functions

func FieldSlice

func FieldSlice(t Model) []string

FieldSlice returns a slice of the fields in the Model.

func StringOf

func StringOf(t Model) (string, error)

StringOf returns a string representation of the Model.

func ValueContains

func ValueContains(val any, query string) bool

Types

type ContainedModel

type ContainedModel struct {
	Model Model
	Field string
}

type Model

type Model interface {
	// StringID is the unique identifier of the Model as a string.
	StringID() string

	// DocumentType returns a string representation of the type of the Model.
	DocumentType() string

	// Fields returns a the fields in the Model mapped to an index.
	Fields() *orderedmap.OrderedMap[string, int]

	// ValueAtIdx returns the value of the field in the Model at i.
	ValueAtIdx(i int) any

	// ValueAt returns the value of the field in the Model.
	// It returns ErrFieldNotFound if the field does not exist.
	ValueAt(field string) (any, error)

	// Contains returns a slice of ContainedModels that the Model contains.
	Contains() []ContainedModel
}

func OrganizationSliceToModelsSlice

func OrganizationSliceToModelsSlice(in []Organization) []Model

OrganizationSliceToModelsSlice converts a slice of Organization to a slice of Model.

func TicketSliceToModelsSlice

func TicketSliceToModelsSlice(in []Ticket) []Model

TicketSliceToModelsSlice converts a slice of Ticket to a slice of Model.

func UserSliceToModelsSlice

func UserSliceToModelsSlice(in []User) []Model

UserSliceToModelsSlice converts a slice of User to a slice of Model.

type Organization

type Organization struct {
	ID            int       `json:"_id"`
	URL           string    `json:"url"`
	ExternalID    uuid.UUID `json:"external_id"`
	Name          string    `json:"name"`
	DomainNames   []string  `json:"domain_names"`
	CreatedAt     string    `json:"created_at"`
	Details       string    `json:"details"`
	SharedTickets bool      `json:"shared_tickets"`
	Tags          []string  `json:"tags"`
}

func (*Organization) Contains

func (*Organization) Contains() []ContainedModel

func (*Organization) DocumentType

func (*Organization) DocumentType() string

func (*Organization) Fields

func (o *Organization) Fields() *orderedmap.OrderedMap[string, int]

func (*Organization) String

func (o *Organization) String() (string, error)

func (*Organization) StringID

func (o *Organization) StringID() string

func (*Organization) ValueAt

func (o *Organization) ValueAt(field string) (any, error)

func (*Organization) ValueAtIdx

func (o *Organization) ValueAtIdx(i int) any

type Ticket

type Ticket struct {
	ID             uuid.UUID `json:"_id"`
	URL            string    `json:"url"`
	ExternalID     uuid.UUID `json:"external_id"`
	CreatedAt      string    `json:"created_at"`
	Type           string    `json:"type"`
	Subject        string    `json:"subject"`
	Description    string    `json:"description"`
	Priority       string    `json:"priority"`
	Status         string    `json:"status"`
	SubmitterID    int       `json:"submitter_id"`
	AssigneeID     int       `json:"assignee_id"`
	OrganizationID int       `json:"organization_id"`
	Tags           []string  `json:"tags"`
	HasIncidents   bool      `json:"has_incidents"`
	DueAt          string    `json:"due_at"`
	Via            string    `json:"via"`
}

func (*Ticket) Contains

func (*Ticket) Contains() []ContainedModel

func (*Ticket) DocumentType

func (*Ticket) DocumentType() string

func (*Ticket) Fields

func (t *Ticket) Fields() *orderedmap.OrderedMap[string, int]

func (*Ticket) String

func (t *Ticket) String() (string, error)

func (*Ticket) StringID

func (t *Ticket) StringID() string

func (*Ticket) ValueAt

func (t *Ticket) ValueAt(field string) (any, error)

func (*Ticket) ValueAtIdx

func (t *Ticket) ValueAtIdx(i int) any

type User

type User struct {
	ID             int       `json:"_id"`
	URL            string    `json:"url"`
	ExternalID     uuid.UUID `json:"external_id"`
	Name           string    `json:"name"`
	Alias          string    `json:"alias"`
	CreatedAt      string    `json:"created_at"`
	Active         bool      `json:"active"`
	Verified       bool      `json:"verified"`
	Shared         bool      `json:"shared"`
	Locale         string    `json:"locale"`
	Timezone       string    `json:"timezone"`
	LastLoginAt    string    `json:"last_login_at"`
	Email          string    `json:"email"`
	Phone          string    `json:"phone"`
	Signature      string    `json:"signature"`
	OrganizationID int       `json:"organization_id"`
	Tags           []string  `json:"tags"`
	Suspended      bool      `json:"suspended"`
	Role           string    `json:"role"`
}

func (*User) Contains

func (*User) Contains() []ContainedModel

func (*User) DocumentType

func (*User) DocumentType() string

func (*User) Fields

func (u *User) Fields() *orderedmap.OrderedMap[string, int]

func (*User) String

func (u *User) String() (string, error)

func (*User) StringID

func (u *User) StringID() string

func (*User) ValueAt

func (u *User) ValueAt(field string) (any, error)

func (*User) ValueAtIdx

func (u *User) ValueAtIdx(i int) any

Jump to

Keyboard shortcuts

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