contactmethod

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: Apache-2.0 Imports: 13 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
	Name     string
	Type     Type
	Value    string
	Disabled bool
	UserID   string
	Pending  bool

	StatusUpdates bool
	// 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 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

func (m Metadata) MarshalJSON() ([]byte, error)

MarshalJSON implements `json.Marshaler`. It is used to allow `omitempty` behavior with embedded structs.

type Store

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

Store implements the lookup and management of ContactMethods against a *sql.Store backend.

func NewStore added in v0.30.0

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

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

func (*Store) CreateTx

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

CreateTx inserts the new ContactMethod into the database. A new ID is always created.

func (*Store) DeleteTx

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

Delete removes the ContactMethod from the database using the provided ID within a transaction.

func (*Store) DisableByValue

func (s *Store) DisableByValue(ctx context.Context, t Type, v string) error

func (*Store) EnableByValue added in v0.25.0

func (s *Store) EnableByValue(ctx context.Context, t Type, v string) error

func (*Store) FindAll

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

FindAll finds all contact methods from the database associated with the given user ID.

func (*Store) FindMany

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

FindMany will fetch all contact methods matching the given ids.

func (*Store) FindOne

func (s *Store) FindOne(ctx context.Context, id string) (*ContactMethod, error)

FindOne finds the contact method from the database using the provided ID.

func (*Store) FindOneTx

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

FindOneTx finds the contact method from the database using the provided ID within a transaction.

func (*Store) MetadataByTypeValue added in v0.25.0

func (s *Store) MetadataByTypeValue(ctx context.Context, tx *sql.Tx, typ Type, value string) (*Metadata, error)

func (*Store) SetCarrierV1MetadataByTypeValue added in v0.25.0

func (s *Store) SetCarrierV1MetadataByTypeValue(ctx context.Context, tx *sql.Tx, typ Type, value string, newM *Metadata) error

func (*Store) UpdateTx

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

UpdateTx updates the contact method with the newly provided values within a transaction.

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"
	TypeSlackDM Type = "SLACK_DM"
)

ContactMethod types

func (*Type) Scan

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

Scan handles reading a Type from the DB format

func (Type) StatusUpdatesAlways added in v0.31.0

func (t Type) StatusUpdatesAlways() bool

func (Type) StatusUpdatesNever added in v0.31.0

func (t Type) StatusUpdatesNever() bool

func (Type) Value added in v0.28.0

func (t Type) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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