Documentation ¶
Index ¶
- type ContactMethod
- type DB
- func (db *DB) CreateTx(ctx context.Context, tx *sql.Tx, c *ContactMethod) (*ContactMethod, error)
- func (db *DB) Delete(ctx context.Context, id string) error
- func (db *DB) DeleteTx(ctx context.Context, tx *sql.Tx, ids ...string) error
- func (db *DB) DisableByValue(ctx context.Context, t Type, v string) error
- func (db *DB) FindAll(ctx context.Context, userID string) ([]ContactMethod, error)
- func (db *DB) FindMany(ctx context.Context, ids []string) ([]ContactMethod, error)
- func (db *DB) FindOne(ctx context.Context, id string) (*ContactMethod, error)
- func (db *DB) FindOneTx(ctx context.Context, tx *sql.Tx, id string) (*ContactMethod, error)
- func (db *DB) Insert(ctx context.Context, c *ContactMethod) (*ContactMethod, error)
- func (db *DB) Update(ctx context.Context, c *ContactMethod) error
- func (db *DB) UpdateTx(ctx context.Context, tx *sql.Tx, c *ContactMethod) error
- type Store
- type Type
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 ¶
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) DisableByValue ¶
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.
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