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) EnableByValue(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) MetadataByTypeValue(ctx context.Context, tx *sql.Tx, typ Type, value string) (*Metadata, error)
- func (db *DB) SetCarrierV1MetadataByTypeValue(ctx context.Context, tx *sql.Tx, typ Type, value string, newM *Metadata) 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 Metadata
- 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:"-"`
// contains filtered or unexported fields
}
ContactMethod stores the information for contacting a user.
func (ContactMethod) LastTestVerifyAt ¶ added in v0.26.0
func (c ContactMethod) LastTestVerifyAt() time.Time
LastTestVerifyAt will return the timestamp of the last test/verify request.
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) EnableByValue ¶ added in v0.25.0
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) MetadataByTypeValue ¶ added in v0.25.0
func (*DB) SetCarrierV1MetadataByTypeValue ¶ added in v0.25.0
type Metadata ¶ added in v0.25.0
type Metadata struct {
FetchedAt time.Time `json:"-"`
CarrierV1 struct {
UpdatedAt time.Time
Name string
Type string
MobileNetworkCode string
MobileCountryCode string
}
}
Metadata stores information about a contact method.
func (Metadata) MarshalJSON ¶ added in v0.25.0
MarshalJSON implments `json.Marshaler`. It is used to allow `omitempty` behavior with embedded structs.
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
EnableByValue(context.Context, Type, string) error
DisableByValue(context.Context, Type, string) error
MetadataByTypeValue(ctx context.Context, tx *sql.Tx, t Type, value string) (*Metadata, error)
SetCarrierV1MetadataByTypeValue(ctx context.Context, tx *sql.Tx, t Type, value string, m *Metadata) error
}
Store allows the lookup and management of ContactMethods.
type Type ¶
type Type string
Type specifies the medium a ContactMethod is notified.
const ( TypeUnknown Type = "" TypeVoice Type = "VOICE" TypeSMS Type = "SMS" TypeEmail Type = "EMAIL" TypePush Type = "PUSH" TypeWebhook Type = "WEBHOOK" )
ContactMethod types