models

package
v0.0.0-...-8f9f3ed Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("not found")
	ErrMultipleItems = errors.New("unexpected multiple items retrieved")
	ErrUnimplemented = errors.New("not yet implemented")
)

Functions

This section is empty.

Types

type BaseDatabaseTenant

type BaseDatabaseTenant struct {
	*BaseTenant
	Dao *daos.Dao
}

BaseDatabaseTenant is a base tenant, with default implementations directly connected to the database.

func (*BaseDatabaseTenant) CollectAllItems

func (c *BaseDatabaseTenant) CollectAllItems() ([]*Item, error)

func (*BaseDatabaseTenant) CredentialsManager

func (c *BaseDatabaseTenant) CredentialsManager() oauth2.CredentialsManager

func (*BaseDatabaseTenant) Daemon

func (c *BaseDatabaseTenant) Daemon() Daemon

func (*BaseDatabaseTenant) LoadItem

func (c *BaseDatabaseTenant) LoadItem(sellerSKU string) (*Item, error)

func (*BaseDatabaseTenant) SaveItem

func (c *BaseDatabaseTenant) SaveItem(item *Item) error

type BaseTenant

type BaseTenant struct {
	ID          string
	Name        string
	Vendor      string
	Config      json.RawMessage
	TenantGroup string
}

func TenantFrom

func TenantFrom(record *pbm.Record) *BaseTenant

func (*BaseTenant) Tenant

func (b *BaseTenant) Tenant() *BaseTenant

type Daemon

type Daemon interface {
	Start() error
}

Daemon is a background running service.

type IntegrationClient

type IntegrationClient interface {
	Tenant() *BaseTenant
	CollectAllItems() ([]*Item, error)
	LoadItem(sku string) (*Item, error)
	SaveItem(item *Item) error
	CredentialsManager() oauth2.CredentialsManager
	Daemon() Daemon
}

IntegrationClient is an interface for any vendor clients.

type Item

type Item struct {
	ID          string
	TenantID    string
	SellerSKU   string
	Stocks      int
	TenantProps *gjson.Result
	Created     time.Time
	Updated     time.Time
}

Item is an interface for any items for any vendors.

func ItemFrom

func ItemFrom(record *pbm.Record) *Item

ItemFrom creates an item from a db record.

func (*Item) ToRecord

func (i *Item) ToRecord(collection *pbm.Collection) *pbm.Record

ToRecord converts an item into a db record.

Jump to

Keyboard shortcuts

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