sms

package
v1.0.2-0...-0000000 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SenderIDSMSAttribute a custom name that's displayed as the message sender on the receiving device.
	SenderIDSMSAttribute = "AWS.SNS.SMS.SenderID"
	// MaxPriceSMSAttribute a maximum price in USD that you are willing to pay to send the message.
	MaxPriceSMSAttribute = "AWS.SNS.SMS.MaxPrice"
	// MessageTypeSMSAttribute a SMS type, can be either Promotional or Transactional.
	MessageTypeSMSAttribute = "AWS.SNS.SMS.MessageType"

	// Promotional message type used for promotional purposes that are noncritical, won't be delivered
	// to DND (Do Not Disturb) numbers.
	Promotional MessageType = "Promotional"
	// Transactional message type used for transactional purposes which includes critical messages as multi-factor
	// authentication. This message type might be more expensive than Promotional message type. Will be delivered to
	// to DND numbers.
	Transactional MessageType = "Transactional"
)

Variables

This section is empty.

Functions

func GetMessageAttributes

func GetMessageAttributes(c *Config) map[string]*sns.MessageAttributeValue

GetMessageAttributes returns message attributes map based on the given config

Types

type Config

type Config struct {
	AWSAccessKey       string   `yaml:"aws_access_key"`
	AWSSecretAccessKey string   `yaml:"aws_secret_access_key"`
	AWSRegion          string   `yaml:"aws_region"`
	SenderID           *string  `yaml:"sender_id,omitempty"`
	MaxPrice           *float32 `yaml:"max_price,omitempty"`
	MessageType        *string  `yaml:"message_type,omitempty"`
}

Config sender configuration

type MessageType

type MessageType string

MessageType SNS SMS type

func (MessageType) IsValid

func (mt MessageType) IsValid() bool

IsValid returns true if the message type is either transactional or promotional used to validate that a valid message type is being provided.

func (MessageType) String

func (mt MessageType) String() string

String returns message type string value

type Sender

type Sender struct {
	MessageAttributes map[string]*sns.MessageAttributeValue
	// contains filtered or unexported fields
}

Sender used to send text messages using AWS SNS

func New

func New(config Config) *Sender

New initialise sender with the given configuration

func NewWithSNS

func NewWithSNS(awsSNS snsiface.SNSAPI) *Sender

NewWithSNS initialise sender with custom SNS

func (*Sender) Send

func (s *Sender) Send(msg, receiver string) (*string, error)

Send message to the given message to the receiver mobile phone number

func (*Sender) WithMaxPrice

func (s *Sender) WithMaxPrice(p float32) *Sender

WithMaxPrice sets the max price in USD that you are willing to pay to send a single text message

func (*Sender) WithMessageType

func (s *Sender) WithMessageType(t MessageType) *Sender

WithMessageType sets the message type. The message type will be set only when message type is either transactional or promotional.

func (*Sender) WithSenderID

func (s *Sender) WithSenderID(id string) *Sender

WithSenderID will include a sender ID in the sent text message. Sender ID won't be set when the provided ID contains only whitespaces, to avoid making a request with a bad SMS attribute.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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