contactmethod

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContactMethod

type ContactMethod struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Type     Type   `json:"type"`
	Value    string `json:"value"`
	Disabled bool   `json:"disabled"`
	UserID   string `json:"-"`
}

ContactMethod stores the information for contacting a user.

func (ContactMethod) Normalize

func (c ContactMethod) Normalize() (*ContactMethod, error)

Normalize will validate and 'normalize' the ContactMethod -- such as making email lower-case and setting carrier to "" (for non-phone types).

type DB

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

DB implements the ContactMethodStore against a *sql.DB backend.

func NewDB

func NewDB(ctx context.Context, db *sql.DB) (*DB, error)

NewDB will create a DB backend from a sql.DB. An error will be returned if statements fail to prepare.

func (*DB) CreateTx

func (db *DB) CreateTx(ctx context.Context, tx *sql.Tx, c *ContactMethod) (*ContactMethod, error)

CreateTx implements the ContactMethodStore interface by inserting the new ContactMethod into the database. A new ID is always created.

func (*DB) Delete

func (db *DB) Delete(ctx context.Context, id string) error

Delete implements the ContactMethodStore interface.

func (*DB) DeleteTx

func (db *DB) DeleteTx(ctx context.Context, tx *sql.Tx, ids ...string) error

DeleteTx implements the ContactMethodStore interface.

func (*DB) DisableByValue

func (db *DB) DisableByValue(ctx context.Context, t Type, v string) error

func (*DB) FindAll

func (db *DB) FindAll(ctx context.Context, userID string) ([]ContactMethod, error)

FindAll implements the ContactMethodStore interface.

func (*DB) FindMany

func (db *DB) FindMany(ctx context.Context, ids []string) ([]ContactMethod, error)

FindMany will fetch all contact methods matching the given ids.

func (*DB) FindOne

func (db *DB) FindOne(ctx context.Context, id string) (*ContactMethod, error)

FindOne implements the ContactMethodStore interface.

func (*DB) FindOneTx

func (db *DB) FindOneTx(ctx context.Context, tx *sql.Tx, id string) (*ContactMethod, error)

FindOneTx implements the ContactMethodStore interface.

func (*DB) Insert

func (db *DB) Insert(ctx context.Context, c *ContactMethod) (*ContactMethod, error)

Insert implements the ContactMethodStore interface by inserting the new ContactMethod into the database. A new ID is always created.

func (*DB) Update

func (db *DB) Update(ctx context.Context, c *ContactMethod) error

Update implements the ContactMethodStore interface.

func (*DB) UpdateTx

func (db *DB) UpdateTx(ctx context.Context, tx *sql.Tx, c *ContactMethod) error

UpdateTx implements the ContactMethodStore interface.

type Store

type Store interface {
	Insert(context.Context, *ContactMethod) (*ContactMethod, error)
	CreateTx(context.Context, *sql.Tx, *ContactMethod) (*ContactMethod, error)
	Update(context.Context, *ContactMethod) error
	UpdateTx(context.Context, *sql.Tx, *ContactMethod) error
	Delete(ctx context.Context, id string) error
	FindOne(ctx context.Context, id string) (*ContactMethod, error)
	FindOneTx(ctx context.Context, tx *sql.Tx, id string) (*ContactMethod, error)
	FindMany(ctx context.Context, ids []string) ([]ContactMethod, error)
	FindAll(ctx context.Context, userID string) ([]ContactMethod, error)
	DeleteTx(ctx context.Context, tx *sql.Tx, id ...string) error
	DisableByValue(context.Context, Type, string) error
}

Store allows the lookup and management of ContactMethods.

type Type

type Type string

Type specifies the medium a ContactMethod is notified.

const (
	TypeVoice Type = "VOICE"
	TypeSMS   Type = "SMS"
	TypeEmail Type = "EMAIL"
	TypePush  Type = "PUSH"
)

ContactMethod types

func TypeFromDestType

func TypeFromDestType(t notification.DestType) Type

TypeFromDestType will return the Type associated with a notification.DestType.

func (Type) DestType

func (t Type) DestType() notification.DestType

func (*Type) Scan

func (r *Type) Scan(value interface{}) error

Scan handles reading a Type from the DB format

Jump to

Keyboard shortcuts

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