sms_provider

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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, config *conf.GlobalConfiguration) 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

func (*MessagebirdProvider) VerifyOTP

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

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)
	VerifyOTP(phone, token string) error
}
var MockProvider SmsProvider = nil

overrides the SmsProvider set to always return the mock provider

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

func (*TextlocalProvider) VerifyOTP

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

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

func (*TwilioProvider) VerifyOTP

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

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

func (*VonageProvider) VerifyOTP

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

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