message

package
v0.0.0-...-9cf9cea Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAWSSESClient

func NewAWSSESClient(accessKeyID, secretAccessKey, region, senderID string) (*awsSESClient, error)

NewAWSSESClient creates a new AWS SES client, that is used to send emails.

func NewAWSSNSClient

func NewAWSSNSClient(accessKeyID, secretAccessKey, region, senderID string) (*awsSNSClient, error)

NewAWSSNSClient creates a new awsSNSClient, that is used to send SMS messages.

func NewTwilioClient

func NewTwilioClient(accountSid, authToken, senderID string) (*twilioClient, error)

Types

type Message

type Message struct {
	ToPhoneNumber string
	ToEmail       string
	Message       string
	Title         string
}

func (*Message) ValidateFor

func (s *Message) ValidateFor(messengerType MessengerType) error

ValidateFor validates if the message object is valid for the given messengerType.

type MessengerClient

type MessengerClient interface {
	SendMessage(message Message) error
	MessengerType() MessengerType
}

func GetClient

func GetClient(opts MessengerOptions) (MessengerClient, error)

func NewDryRunClient

func NewDryRunClient() (MessengerClient, error)

type MessengerClientMock

type MessengerClientMock struct {
	mock.Mock
}

func (*MessengerClientMock) MessengerType

func (mc *MessengerClientMock) MessengerType() MessengerType

func (*MessengerClientMock) SendMessage

func (mc *MessengerClientMock) SendMessage(message Message) error

type MessengerOptions

type MessengerOptions struct {
	MessengerType MessengerType
	Environment   string

	// Twilio
	TwilioAccountSID string
	TwilioAuthToken  string
	TwilioServiceSID string

	// AWS
	AWSAccessKeyID     string
	AWSSecretAccessKey string
	AWSRegion          string
	// AWS SNS (SMS messages)
	AWSSNSSenderID string
	// AWS SES (EMAIL messages)
	AWSSESSenderID string
}

type MessengerType

type MessengerType string
const (
	// MessengerTypeTwilioSMS is used to send SMS messages using Twilio.
	MessengerTypeTwilioSMS MessengerType = "TWILIO_SMS"
	// MessengerTypeAWSSMS is used to send SMS messages using AWS SNS.
	MessengerTypeAWSSMS MessengerType = "AWS_SMS"
	// MessengerTypeAWSEmail is used to send emails using AWS SES.
	MessengerTypeAWSEmail MessengerType = "AWS_EMAIL"
	// MessengerTypeDryRun is used for development environment
	MessengerTypeDryRun MessengerType = "DRY_RUN"
)

ATTENTION: when adding a new type, make ure to update the MessengerType methods!

func ParseMessengerType

func ParseMessengerType(messengerTypeStr string) (MessengerType, error)

func (MessengerType) All

func (mt MessengerType) All() []MessengerType

func (MessengerType) IsEmail

func (mt MessengerType) IsEmail() bool

func (MessengerType) IsSMS

func (mt MessengerType) IsSMS() bool

func (MessengerType) ValidEmailTypes

func (mt MessengerType) ValidEmailTypes() []MessengerType

func (MessengerType) ValidSMSTypes

func (mt MessengerType) ValidSMSTypes() []MessengerType

Jump to

Keyboard shortcuts

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