sms

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package sms defines interfaces for sending SMS text messages.

Although exported, this package is non intended for general consumption. It is a shared dependency between multiple exposure notifications projects. We cannot guarantee that there won't be breaking changes in the future.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ProviderType ProviderType

	// Twilio options
	TwilioAccountSid string
	TwilioAuthToken  string
	TwilioFromNumber string
}

Config represents configuration for an SMS provider.

type Noop

type Noop struct{}

Noop does nothing.

func (*Noop) SendSMS

func (p *Noop) SendSMS(_ context.Context, _, _ string) error

SendSMS does nothing.

type Provider

type Provider interface {
	// SendSMS sends an SMS text message from the given number to the given number
	// with the provided message.
	SendSMS(ctx context.Context, to, message string) error
}

func NewNoop

func NewNoop(_ context.Context) (Provider, error)

NewNoop creates a new SMS sender that does nothing.

func NewTwilio

func NewTwilio(ctx context.Context, accountSid, authToken, from string) (Provider, error)

NewTwilio creates a new Twilio SMS sender with the given auth.

func ProviderFor

func ProviderFor(ctx context.Context, c *Config) (Provider, error)

type ProviderType

type ProviderType string

ProviderType represents a type of SMS provider.

const (
	ProviderTypeNoop   ProviderType = "NOOP"
	ProviderTypeTwilio ProviderType = "TWILIO"
)

type Twilio

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

Twilio sends messages via the Twilio API.

func (*Twilio) SendSMS

func (p *Twilio) SendSMS(ctx context.Context, to, message string) error

SendSMS sends a message using the Twilio API.

type TwilioError

type TwilioError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

TwilioError represents an error returned from the Twilio API.

func (*TwilioError) Error

func (e *TwilioError) Error() string

Jump to

Keyboard shortcuts

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