models

package
v0.0.0-...-ca24b28 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTemplateID  = "default"
	DoNotSetTemplateID = ""
)

Variables

This section is empty.

Functions

func Setup

func Setup(database *db.DB)

Types

type Client

type Client struct {
	Primary     int       `db:"primary"`
	ID          string    `db:"id"`
	Description string    `db:"description"`
	CreatedAt   time.Time `db:"created_at"`
	TemplateID  string    `db:"template_id"`
}

func (*Client) PreInsert

func (c *Client) PreInsert(s gorp.SqlExecutor) error

func (Client) TemplateToUse

func (c Client) TemplateToUse() string

type ClientsRepo

type ClientsRepo struct{}

func NewClientsRepo

func NewClientsRepo() ClientsRepo

func (ClientsRepo) Find

func (repo ClientsRepo) Find(conn ConnectionInterface, id string) (Client, error)

func (ClientsRepo) FindAll

func (repo ClientsRepo) FindAll(conn ConnectionInterface) ([]Client, error)

func (ClientsRepo) FindAllByTemplateID

func (repo ClientsRepo) FindAllByTemplateID(conn ConnectionInterface, templateID string) ([]Client, error)

func (ClientsRepo) Update

func (repo ClientsRepo) Update(conn ConnectionInterface, client Client) (Client, error)

func (ClientsRepo) Upsert

func (repo ClientsRepo) Upsert(conn ConnectionInterface, client Client) (Client, error)

type Config

type Config struct {
	DefaultTemplatePath string
}

type ConnectionInterface

type ConnectionInterface interface {
	db.ConnectionInterface
}

type DatabaseInterface

type DatabaseInterface interface {
	db.DatabaseInterface
}

func NewDatabase

func NewDatabase(sqlDB *sql.DB, config Config) DatabaseInterface

type DatabaseMigrator

type DatabaseMigrator struct {
}

func (DatabaseMigrator) Migrate

func (d DatabaseMigrator) Migrate(db *sql.DB, migrationsPath string)

func (DatabaseMigrator) Seed

func (d DatabaseMigrator) Seed(database DatabaseInterface, defaultTemplatePath string)

type DuplicateError

type DuplicateError struct {
	Err error
}

func (DuplicateError) Error

func (e DuplicateError) Error() string

type GlobalUnsubscribe

type GlobalUnsubscribe struct {
	Primary   int       `db:"primary"`
	UserID    string    `db:"user_id"`
	CreatedAt time.Time `db:"created_at"`
}

type GlobalUnsubscribesRepo

type GlobalUnsubscribesRepo struct{}

func NewGlobalUnsubscribesRepo

func NewGlobalUnsubscribesRepo() GlobalUnsubscribesRepo

func (GlobalUnsubscribesRepo) Get

func (repo GlobalUnsubscribesRepo) Get(conn ConnectionInterface, userGUID string) (bool, error)

func (GlobalUnsubscribesRepo) Set

func (repo GlobalUnsubscribesRepo) Set(conn ConnectionInterface, userGUID string, unsubscribe bool) error

type IDGeneratorFunc

type IDGeneratorFunc func() (string, error)

type IDSet

type IDSet []string

func (IDSet) Contains

func (set IDSet) Contains(id string) bool

type Kind

type Kind struct {
	Primary     int       `db:"primary"`
	ID          string    `db:"id"`
	Description string    `db:"description"`
	Critical    bool      `db:"critical"`
	ClientID    string    `db:"client_id"`
	CreatedAt   time.Time `db:"created_at"`
	UpdatedAt   time.Time `db:"updated_at"`
	TemplateID  string    `db:"template_id"`
}

func (*Kind) PreInsert

func (k *Kind) PreInsert(s gorp.SqlExecutor) error

func (Kind) TemplateToUse

func (k Kind) TemplateToUse() string

type KindsRepo

type KindsRepo struct{}

func NewKindsRepo

func NewKindsRepo() KindsRepo

func (KindsRepo) Find

func (repo KindsRepo) Find(conn ConnectionInterface, id, clientID string) (Kind, error)

func (KindsRepo) FindAll

func (repo KindsRepo) FindAll(conn ConnectionInterface) ([]Kind, error)

func (KindsRepo) FindAllByTemplateID

func (repo KindsRepo) FindAllByTemplateID(conn ConnectionInterface, templateID string) ([]Kind, error)

func (KindsRepo) Trim

func (repo KindsRepo) Trim(conn ConnectionInterface, clientID string, kindIDs []string) (int, error)

func (KindsRepo) Update

func (repo KindsRepo) Update(conn ConnectionInterface, kind Kind) (Kind, error)

func (KindsRepo) Upsert

func (repo KindsRepo) Upsert(conn ConnectionInterface, kind Kind) (Kind, error)

type Message

type Message struct {
	ID        string    `db:"id"`
	Status    string    `db:"status"`
	UpdatedAt time.Time `db:"updated_at"`
}

func (*Message) PreInsert

func (m *Message) PreInsert(s gorp.SqlExecutor) error

func (*Message) PreUpdate

func (m *Message) PreUpdate(s gorp.SqlExecutor) error

type MessagesRepo

type MessagesRepo struct {
	// contains filtered or unexported fields
}

func NewMessagesRepo

func NewMessagesRepo(guidGenerator IDGeneratorFunc) MessagesRepo

func (MessagesRepo) Create

func (repo MessagesRepo) Create(conn ConnectionInterface, message Message) (Message, error)

func (MessagesRepo) DeleteBefore

func (repo MessagesRepo) DeleteBefore(conn ConnectionInterface, threshold time.Time) (int, error)

func (MessagesRepo) FindByID

func (repo MessagesRepo) FindByID(conn ConnectionInterface, messageID string) (Message, error)

func (MessagesRepo) Update

func (repo MessagesRepo) Update(conn ConnectionInterface, message Message) (Message, error)

func (MessagesRepo) Upsert

func (repo MessagesRepo) Upsert(conn ConnectionInterface, message Message) (Message, error)

type NotFoundError

type NotFoundError struct {
	Err error
}

func (NotFoundError) Error

func (e NotFoundError) Error() string

type Preference

type Preference struct {
	ClientID          string `db:"client_id"`
	KindID            string `db:"kind_id"`
	KindDescription   string `db:"kind_description"`
	SourceDescription string `db:"source_description"`
	Email             bool
}

type PreferencesRepo

type PreferencesRepo struct {
	// contains filtered or unexported fields
}

func NewPreferencesRepo

func NewPreferencesRepo() PreferencesRepo

func (PreferencesRepo) FindNonCriticalPreferences

func (repo PreferencesRepo) FindNonCriticalPreferences(conn ConnectionInterface, userGUID string) ([]Preference, error)

type Receipt

type Receipt struct {
	Primary   int       `db:"primary"`
	UserGUID  string    `db:"user_guid"`
	ClientID  string    `db:"client_id"`
	KindID    string    `db:"kind_id"`
	Count     int       `db:"count"`
	CreatedAt time.Time `db:"created_at"`
}

func (*Receipt) PreInsert

func (r *Receipt) PreInsert(s gorp.SqlExecutor) error

type ReceiptsRepo

type ReceiptsRepo struct{}

func NewReceiptsRepo

func NewReceiptsRepo() ReceiptsRepo

func (ReceiptsRepo) CreateReceipts

func (repo ReceiptsRepo) CreateReceipts(conn ConnectionInterface, userGUIDs []string, clientID, kindID string) error

type Template

type Template struct {
	Primary    int       `db:"primary"`
	ID         string    `db:"id"`
	Name       string    `db:"name"`
	Subject    string    `db:"subject"`
	Text       string    `db:"text"`
	HTML       string    `db:"html"`
	Metadata   string    `db:"metadata"`
	CreatedAt  time.Time `db:"created_at"`
	UpdatedAt  time.Time `db:"updated_at"`
	Overridden bool      `db:"overridden"`
}

func (*Template) PreInsert

func (t *Template) PreInsert(s gorp.SqlExecutor) error

type TemplateUpdateError

type TemplateUpdateError struct {
	Err error
}

func (TemplateUpdateError) Error

func (e TemplateUpdateError) Error() string

type TemplatesRepo

type TemplatesRepo struct{}

func NewTemplatesRepo

func NewTemplatesRepo() TemplatesRepo

func (TemplatesRepo) Create

func (repo TemplatesRepo) Create(conn ConnectionInterface, template Template) (Template, error)

func (TemplatesRepo) Destroy

func (repo TemplatesRepo) Destroy(conn ConnectionInterface, templateID string) error

func (TemplatesRepo) FindByID

func (repo TemplatesRepo) FindByID(conn ConnectionInterface, templateID string) (Template, error)

func (TemplatesRepo) ListIDsAndNames

func (repo TemplatesRepo) ListIDsAndNames(conn ConnectionInterface) ([]Template, error)

func (TemplatesRepo) Update

func (repo TemplatesRepo) Update(conn ConnectionInterface, templateID string, template Template) (Template, error)

type TransactionCommitError

type TransactionCommitError struct {
	Err error
}

func (TransactionCommitError) Error

func (e TransactionCommitError) Error() string

type Unsubscribe

type Unsubscribe struct {
	Primary   int       `db:"primary"`
	UserID    string    `db:"user_id"`
	ClientID  string    `db:"client_id"`
	KindID    string    `db:"kind_id"`
	CreatedAt time.Time `db:"created_at"`
}

func (*Unsubscribe) PreInsert

func (u *Unsubscribe) PreInsert(s gorp.SqlExecutor) error

type Unsubscribes

type Unsubscribes []Unsubscribe

func (Unsubscribes) Contains

func (unsubscribes Unsubscribes) Contains(clientID, kindID string) bool

type UnsubscribesRepo

type UnsubscribesRepo struct{}

func NewUnsubscribesRepo

func NewUnsubscribesRepo() UnsubscribesRepo

func (UnsubscribesRepo) FindAllByUserID

func (repo UnsubscribesRepo) FindAllByUserID(conn ConnectionInterface, userID string) ([]Unsubscribe, error)

func (UnsubscribesRepo) Get

func (repo UnsubscribesRepo) Get(conn ConnectionInterface, userID, clientID, kindID string) (bool, error)

func (UnsubscribesRepo) Set

func (repo UnsubscribesRepo) Set(conn ConnectionInterface, userID, clientID, kindID string, unsubscribe bool) error

Jump to

Keyboard shortcuts

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