sms

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DEFAULT_TENCENT_SMS_ENDPOINT todo
	DEFAULT_TENCENT_SMS_ENDPOINT = "sms.tencentcloudapi.com"
)

Variables

View Source
var (
	// Provider_name name map
	Provider_name = map[Provider]string{
		ProviderTenCent: "tencent",
	}

	// Provider_value value map
	Provider_value = map[string]Provider{
		"tencent": ProviderTenCent,
	}
)

Functions

func NewSender

func NewSender(conf *Config) (notify.SMSSender, error)

NewSender todo

Types

type ALI

type ALI struct {
}

ALI todo

type Config

type Config struct {
	EnabledProvider Provider       `bson:"enabled_provider" json:"enabled_provider"`
	Tencent         *TenCentConfig `bson:"tencent" json:"tencent"`
	ALI             *ALI           `bson:"ali" json:"ali"`
}

Config 短信配置

func LoadConfigFromEnv

func LoadConfigFromEnv() (*Config, error)

LoadConfigFromEnv todo

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig todo

func (*Config) Desensitize

func (c *Config) Desensitize()

Desensitize 脱敏

func (*Config) Validate

func (c *Config) Validate() error

Validate todo

type Provider

type Provider uint

Provider 短信提供商

const (
	// ProviderTenCent (tencent) 腾讯短信服务
	ProviderTenCent Provider = iota + 1
	// ProviderALI (ali) 阿里短信服务
	ProviderALI
)

func ParseProviderFromString

func ParseProviderFromString(str string) (Provider, error)

ParseProviderFromString Parse Provider from string

func (Provider) Equal

func (t Provider) Equal(target Provider) bool

Equal type compare

func (Provider) IsIn

func (t Provider) IsIn(targets ...Provider) bool

IsIn todo

func (Provider) MarshalJSON

func (t Provider) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (Provider) String

func (t Provider) String() string

String stringer

func (*Provider) UnmarshalJSON

func (t *Provider) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type TenCentConfig

type TenCentConfig struct {
	Endpoint   string `bson:"endpoint" json:"endpoint" env:"K_SMS_TENCENT_ENDPOINT"`
	SecretID   string `bson:"secret_id" json:"secret_id" validate:"required,lte=64" env:"K_SMS_TENCENT_SECRET_ID"`
	SecretKey  string `bson:"secret_key" json:"secret_key" validate:"required,lte=64" env:"K_SMS_TENCENT_SECRET_KEY"`
	AppID      string `bson:"app_id" json:"app_id" validate:"required,lte=64" env:"K_SMS_TENCENT_APPID"`
	TemplateID string `bson:"template_id" json:"template_id" validate:"required,lte=64" env:"K_SMS_TENCENT_TEMPLATE_ID"`
	Sign       string `bson:"sign" json:"sign" validate:"required,lte=128" env:"K_SMS_TENCENT_SIGN"`
}

TenCentConfig todo 接口和相关文档请参考https://console.cloud.tencent.com/api/explorer?Product=sms&Version=2019-07-11&Action=SendSms&SignVersion=

func (*TenCentConfig) GetEndpoint

func (s *TenCentConfig) GetEndpoint() string

GetEndpoint todo

func (*TenCentConfig) Validate

func (s *TenCentConfig) Validate() error

Validate todo

type TestSendRequest

type TestSendRequest struct {
	*notify.SendSMSRequest
	*Config
}

TestSendRequest todo

func NewDeaultTestSendRequest

func NewDeaultTestSendRequest() *TestSendRequest

NewDeaultTestSendRequest todo

func (*TestSendRequest) Send

func (req *TestSendRequest) Send() error

Send todo

Jump to

Keyboard shortcuts

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