model

package
v0.0.0-...-55babe7 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(lc fx.Lifecycle, db *database.Database)

Types

type Envelope

type Envelope struct {
	Provider string `json:"provider"`
	Version  string `json:"version"`
	Result   any    `json:"result"`
}

type Method

type Method struct {
	gorm.Model      `json:"-"`
	Name            string          `gorm:"not null;index" json:"name" validate:"camelCase,required" example:"MethodName"`
	Params          Params          `gorm:"not null" validate:"required" json:"params" example:"string, string, int"`
	Description     string          `gorm:"not null" validate:"required" json:"description" example:"This method does an operation"`
	ResultStructure ResultStructure `gorm:"not null" validate:"required" json:"result_structure" example:"{ \"key\": \"value\" }"`
	Kind            MethodKind      `gorm:"not null;default:concurrent" validate:"required" json:"kind" example:"concurrent"`
}

type MethodKind

type MethodKind byte
const (
	Broadcast MethodKind = iota
	Concurrent
	Indepotent
	Exchange
)

func (*MethodKind) GormDataType

func (m *MethodKind) GormDataType() string

func (MethodKind) MarshalJSON

func (m MethodKind) MarshalJSON() ([]byte, error)

func (*MethodKind) Scan

func (m *MethodKind) Scan(src any) error

func (MethodKind) String

func (m MethodKind) String() string

func (*MethodKind) UnmarshalJSON

func (m *MethodKind) UnmarshalJSON(b []byte) error

func (MethodKind) Value

func (m MethodKind) Value() (driver.Value, error)

type MethodProvider

type MethodProvider struct {
	MethodID   uint `gorm:"not null;index" json:"method_id"`
	Method     Method
	ProviderID uint `gorm:"not null;index" json:"provider_id"`
	Provider   Provider
}

type Params

type Params []string

func (*Params) GormDataType

func (p *Params) GormDataType() string

func (*Params) Scan

func (p *Params) Scan(src any) error

func (Params) Value

func (p Params) Value() (driver.Value, error)

type Provider

type Provider struct {
	gorm.Model `json:"-"`
	Name       string `gorm:"not null" validate:"required" json:"name" example:"Example LTDA"`
	Contact    string `json:"contact,omitempty" example:"some@email.com"`
	Slug       string `gorm:"not null;uniqueIndex" validate:"required,lowercase" json:"slug" example:"provider-slug"`
	Webhook    string `gorm:"not null" validate:"required,url" json:"webhook" example:"https://provider.com/webhook"`
	Secret     string `gorm:"not null" validate:"required" json:"secret"`
}

func (Provider) CallProviderMethod

func (p Provider) CallProviderMethod(ctx context.Context, hashSecret, userRef, methodName string, params []any) (result *req.Response, err error)

type ReqPayload

type ReqPayload struct {
	UserRef string `json:"user_ref" example:"user-ref"`
	Method  string `json:"method" example:"method-name"`
	Params  []any  `json:"params" example:"[\"param1\", \"param2\"]"`
}

type ResultStructure

type ResultStructure map[string]any

func (*ResultStructure) GormDBDataType

func (r *ResultStructure) GormDBDataType(db *gorm.DB, field *schema.Field) string

func (*ResultStructure) GormDataType

func (r *ResultStructure) GormDataType() string

Jump to

Keyboard shortcuts

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