sms_provider

package
v0.0.0-...-e3e9b0f Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const SMSProvider = "sms"
View Source
const WhatsappProvider = "whatsapp"

Variables

This section is empty.

Functions

func IsValidMessageChannel

func IsValidMessageChannel(channel string, smsProvider string) bool

Types

type MessagebirdErrResponse

type MessagebirdErrResponse struct {
	Errors []MessagebirdError `json:"errors"`
}

func (MessagebirdErrResponse) Error

func (t MessagebirdErrResponse) Error() string

type MessagebirdError

type MessagebirdError struct {
	Code        int    `json:"code"`
	Description string `json:"description"`
	Parameter   string `json:"parameter"`
}

type MessagebirdProvider

type MessagebirdProvider struct {
	Config  *conf.MessagebirdProviderConfiguration
	APIPath string
}

func (*MessagebirdProvider) SendMessage

func (t *MessagebirdProvider) SendMessage(phone, message, channel, otp string) (string, error)

func (*MessagebirdProvider) SendSms

func (t *MessagebirdProvider) SendSms(phone string, message string) (string, error)

Send an SMS containing the OTP with Messagebird's API

type MessagebirdResponse

type MessagebirdResponse struct {
	ID         string                        `json:"id"`
	Recipients MessagebirdResponseRecipients `json:"recipients"`
}

type MessagebirdResponseRecipients

type MessagebirdResponseRecipients struct {
	TotalSentCount int `json:"totalSentCount"`
}

type SmsProvider

type SmsProvider interface {
	SendMessage(phone, message, channel, otp string) (string, error)
}

func GetSmsProvider

func GetSmsProvider(config conf.GlobalConfiguration) (SmsProvider, error)

func NewMessagebirdProvider

func NewMessagebirdProvider(config conf.MessagebirdProviderConfiguration) (SmsProvider, error)

Creates a SmsProvider with the Messagebird Config

func NewTextlocalProvider

func NewTextlocalProvider(config conf.TextlocalProviderConfiguration) (SmsProvider, error)

Creates a SmsProvider with the Textlocal Config

func NewTwilioProvider

func NewTwilioProvider(config conf.TwilioProviderConfiguration) (SmsProvider, error)

Creates a SmsProvider with the Twilio Config

func NewTwilioVerifyProvider

func NewTwilioVerifyProvider(config conf.TwilioVerifyProviderConfiguration) (SmsProvider, error)

Creates a SmsProvider with the Twilio Config

func NewVonageProvider

func NewVonageProvider(config conf.VonageProviderConfiguration) (SmsProvider, error)

Creates a SmsProvider with the Vonage Config

type SmsStatus

type SmsStatus struct {
	To           string `json:"to"`
	From         string `json:"from"`
	MessageSID   string `json:"sid"`
	Status       string `json:"status"`
	ErrorCode    string `json:"error_code"`
	ErrorMessage string `json:"error_message"`
	Body         string `json:"body"`
}

type TextlocalError

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

type TextlocalMessage

type TextlocalMessage struct {
	MessageID string `json:"id"`
}

type TextlocalProvider

type TextlocalProvider struct {
	Config  *conf.TextlocalProviderConfiguration
	APIPath string
}

func (*TextlocalProvider) SendMessage

func (t *TextlocalProvider) SendMessage(phone, message, channel, otp string) (string, error)

func (*TextlocalProvider) SendSms

func (t *TextlocalProvider) SendSms(phone string, message string) (string, error)

Send an SMS containing the OTP with Textlocal's API

type TextlocalResponse

type TextlocalResponse struct {
	Status   string             `json:"status"`
	Errors   []TextlocalError   `json:"errors"`
	Messages []TextlocalMessage `json:"messages"`
}

type TwilioProvider

type TwilioProvider struct {
	Config  *conf.TwilioProviderConfiguration
	APIPath string
}

func (*TwilioProvider) SendMessage

func (t *TwilioProvider) SendMessage(phone, message, channel, otp string) (string, error)

func (*TwilioProvider) SendSms

func (t *TwilioProvider) SendSms(phone, message, channel, otp string) (string, error)

Send an SMS containing the OTP with Twilio's API

type TwilioVerifyProvider

type TwilioVerifyProvider struct {
	Config  *conf.TwilioVerifyProviderConfiguration
	APIPath string
}

func (*TwilioVerifyProvider) SendMessage

func (t *TwilioVerifyProvider) SendMessage(phone, message, channel, otp string) (string, error)

func (*TwilioVerifyProvider) SendSms

func (t *TwilioVerifyProvider) SendSms(phone, message, channel string) (string, error)

Send an SMS containing the OTP with Twilio's API

func (*TwilioVerifyProvider) VerifyOTP

func (t *TwilioVerifyProvider) VerifyOTP(phone, code string) error

type VerificationCheckResponse

type VerificationCheckResponse struct {
	To           string `json:"to"`
	Status       string `json:"status"`
	Channel      string `json:"channel"`
	Valid        bool   `json:"valid"`
	ErrorCode    string `json:"error_code"`
	ErrorMessage string `json:"error_message"`
}

See: https://www.twilio.com/docs/verify/api/verification-check

type VerificationResponse

type VerificationResponse struct {
	To              string `json:"to"`
	Status          string `json:"status"`
	Channel         string `json:"channel"`
	Valid           bool   `json:"valid"`
	VerificationSID string `json:"sid"`
	ErrorCode       string `json:"error_code"`
	ErrorMessage    string `json:"error_message"`
}

type VonageProvider

type VonageProvider struct {
	Config  *conf.VonageProviderConfiguration
	APIPath string
}

func (*VonageProvider) SendMessage

func (t *VonageProvider) SendMessage(phone, message, channel, otp string) (string, error)

func (*VonageProvider) SendSms

func (t *VonageProvider) SendSms(phone string, message string) (string, error)

Send an SMS containing the OTP with Vonage's API

type VonageResponse

type VonageResponse struct {
	Messages []VonageResponseMessage `json:"messages"`
}

type VonageResponseMessage

type VonageResponseMessage struct {
	MessageID string `json:"message-id"`
	Status    string `json:"status"`
	ErrorText string `json:"error-text"`
}

Jump to

Keyboard shortcuts

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