Versions in this module Expand all Collapse all v1 v1.0.0 May 11, 2024 Changes in this version + const KeyPrefixCode + const KeyPrefixIPSourceLimit + const KeyPrefixProviderLimit + const KeyPrefixReceiverLimit + const KeyPrefixSendLimit + const KeyPrefixVerifyLimit + var ErrCaptchaNotFound = bizerr.ErrCaptchaNotFound + var ErrEmailTmplNotFound = bizerr.ErrEmailTmplNotFound + var ErrEmailUnsupported = bizerr.ErrEmailUnsupported + var ErrIPSourceOverQuota = bizerr.ErrIPSourceOverQuota + var ErrInvalidCaptcha = bizerr.ErrInvalidCaptcha + var ErrInvalidParams = errcode.ErrInvalidParams + var ErrProviderOverQuota = bizerr.ErrProviderOverQuota + var ErrReceiverOverQuota = bizerr.ErrReceiverOverQuota + var ErrSendTooFrequently = bizerr.ErrSendTooFrequently + var ErrSmsTmplNotFound = bizerr.ErrSmsTmplNotFound + var ErrSmsUnsupported = bizerr.ErrSmsUnsupported + var ErrVerifyTooFrequently = bizerr.ErrVerifyTooFrequently + func GenCodeKey(p CommonParams) string + func GenIPSourceLimitKey(p CommonParams) string + func GenProviderLimitKey(p CommonParams) string + func GenReceiverLimitKey(p CommonParams) string + func GenSendLimitKey(p CommonParams) string + func GenVerifyLimitKey(p CommonParams) string + type BaseClient struct + HTTPClient *http.Client + func NewBaseClient(opts ...Option) *BaseClient + func (bc *BaseClient) ParseEmailTmpl(templateID string) string + func (bc *BaseClient) ParseSmsTmpl(templateID string) string + type Client interface + Platform func() string + type CodeParam struct + Expiration time.Duration + Key string + Length int + Value string + func (p *CodeParam) GetKey() string + func (p *CodeParam) GetValue() string + func (p *CodeParam) IsEmpty() bool + type CommonParam struct + Key string + Value string + func (p *CommonParam) GetKey() string + func (p *CommonParam) GetValue() string + type CommonParams struct + IP string + NotifyMethod NotifyMethod + Provider string + Receiver string + TemplateID string + func (p CommonParams) IsValid() bool + type EmailClient interface + SendEmail func(receiver, templateID string, params ...Param) error + type EmailClientPicker interface + Add func(key string, value EmailClient) + Get func(key string) (ec EmailClient, isExist bool) + Pick func() (ec EmailClient, key string, isExist bool) + Remove func(keys ...string) + func NewEmailClientPicker() EmailClientPicker + type MockClient struct + func (c *MockClient) Platform() string + func (c *MockClient) SendEmail(receiver, templateID string, params ...Param) error + func (c *MockClient) SendSms(receiver, templateID string, params ...Param) error + type NotifyMethod int32 + const Email + const Sms + func NotifyMethodString(s string) (NotifyMethod, error) + func NotifyMethodValues() []NotifyMethod + func (i *NotifyMethod) UnmarshalJSON(data []byte) error + func (i NotifyMethod) IsANotifyMethod() bool + func (i NotifyMethod) MarshalJSON() ([]byte, error) + func (i NotifyMethod) String() string + type Option func(bc *BaseClient) + func WithEmailTmplMap(m map[string]string) Option + func WithHTTPClient(hc *http.Client) Option + func WithSmsTmplMap(m map[string]string) Option + type Param interface + GetKey func() string + GetValue func() string + type Params []Param + func (ps Params) Keys() []string + func (ps Params) ToMap() map[string]string + func (ps Params) Values() []string + type SendParams struct + IsMock bool + Params []Param + func (p *SendParams) IsValid() bool + type SmsClient interface + SendSms func(receiver, templateID string, params ...Param) error + type SmsClientPicker interface + Add func(key string, value SmsClient) + Get func(key string) (sc SmsClient, isExist bool) + Pick func() (sc SmsClient, key string, isExist bool) + Remove func(keys ...string) + func NewSmsClientPicker() SmsClientPicker + type VerifyParams struct + Clear bool + Code string + func (p *VerifyParams) IsValid() bool