sms

package
v0.0.0-...-8122643 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusSending string = "sending"
	StatusSuccess string = "success"
	StatusFail    string = "fail"
)
View Source
const (
	ErrorCodeSmsSendingFailed string = "sms_sending_failed"
)

Variables

View Source
var SmsErrorDescriptions = map[string]string{
	ErrorCodeSmsSendingFailed: "Failed to send SMS",
}

Functions

func DbModels

func DbModels() []interface{}

func QueryDbModels

func QueryDbModels() []interface{}

Types

type Provider

type Provider interface {
	object_config.Subobject
	Send(ctx op_context.Context, message string, recipient string, smsID ...string) (*ProviderResponse, error)
}

type ProviderBase

type ProviderBase struct {
	object_config.WithProtocolBase
	common.WithNameBase
}

func (*ProviderBase) Init

func (p *ProviderBase) Init(cfg config.Config, log logger.Logger, vld validator.Validator, configPath ...string) error

func (*ProviderBase) SetProtocolAndName

func (p *ProviderBase) SetProtocolAndName(protocol string, name ...string)

type ProviderFactory

type ProviderFactory interface {
	Create(provider string) (Provider, error)
}

type ProviderResponse

type ProviderResponse struct {
	ProviderMessageID string
	RawContent        string
}

type SmsDestination

type SmsDestination struct {
	SmsDestinationConfig
	// contains filtered or unexported fields
}

func (*SmsDestination) Config

func (s *SmsDestination) Config() interface{}

func (*SmsDestination) Init

func (s *SmsDestination) Init(cfg config.Config, log logger.Logger, vld validator.Validator, configPath ...string) error

type SmsDestinationConfig

type SmsDestinationConfig struct {
	PREFIX   string `validate:"required,number"`
	PROVIDER string `validate:"required"`
}

type SmsManager

type SmsManager interface {
	generic_error.ErrorDefinitions

	Send(ctx auth.UserContext, message string, recipient string) (string, error)
	FindSms(ctx op_context.Context, smsId string) (*SmsMessage, error)
}

type SmsManagerBase

type SmsManagerBase struct {
	SmsManagerBaseConfig
	// contains filtered or unexported fields
}

func NewSmsManager

func NewSmsManager() *SmsManagerBase

func (*SmsManagerBase) AttachToErrorManager

func (s *SmsManagerBase) AttachToErrorManager(errManager generic_error.ErrorManager)

func (*SmsManagerBase) Config

func (s *SmsManagerBase) Config() interface{}

func (*SmsManagerBase) Db

func (*SmsManagerBase) FindSms

func (s *SmsManagerBase) FindSms(ctx op_context.Context, smsId string) (*SmsMessage, error)

func (*SmsManagerBase) Init

func (s *SmsManagerBase) Init(cfg config.Config, log logger.Logger, vld validator.Validator, factory ProviderFactory, configPath ...string) error

func (*SmsManagerBase) InitDbService

func (s *SmsManagerBase) InitDbService(ctx op_context.Context, poool pool.Pool, role string) error

func (*SmsManagerBase) Send

func (s *SmsManagerBase) Send(ctx auth.UserContext, message string, recipient string) (string, error)

type SmsManagerBaseConfig

type SmsManagerBaseConfig struct {
	DEFAULT_PROVIDER      string `validate:"required"`
	ENCRYPT_MESSAGE_STORE bool
	SECRET                string `mask:"true"`
	SALT                  string `mask:"true"`
}

type SmsMessage

type SmsMessage struct {
	common.ObjectWithMonthBase
	auth.WithUserBase
	Context     string `gorm:"index;index:,unique,composite:u_month"`
	ForeignId   string `gorm:"index"`
	Phone       string `gorm:"index"`
	Operation   string `gorm:"index"`
	Provider    string `gorm:"index"`
	Status      string `gorm:"index"`
	Tenancy     string `gorm:"index"`
	Message     string
	RawResponse string
}

Directories

Path Synopsis
providers

Jump to

Keyboard shortcuts

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