sdk

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeNotAllow int = 401
	CodeNotFound int = 404
	CodeSuccess  int = 200
)
View Source
const ApiCredential = "/open/oauth2/token"
View Source
const ApiSendMessage = "/messages/"

Variables

This section is empty.

Functions

func Debug added in v0.7.2

func Debug(enable bool)

Debug 输出sdk中的log

Types

type ApnsRequest

type ApnsRequest struct {
	BundleId      string      `json:"bundleId,omitempty"` // bundle id
	Template      string      `json:"template"`           // 模板
	TemplateParam interface{} `json:"params"`             // 参数
	Title         string      `json:"subject,omitempty"`  // 标题
	Receiver      string      `json:"receiver"`           // 接收者,多个时用逗号分隔
}

ApnsRequest Apns服务请求参数

type Client

type Client interface {
	SendMail(req MailRequest) (resp Response, err error)
	SendSms(req SmsRequest) (resp Response, err error)
	SendApns(req ApnsRequest) (resp Response, err error)
}

func New added in v0.7.1

func New(options ...Option) (m Client)

New 初始化.

内部存储了Credentials,应该确保复用,而不是每次新建

Client 内置了刷新credentials功能,不需要考虑credentials的获取问题.

type MailRequest

type MailRequest struct {
	Template      string      `json:"template"`                // 模板
	CloudTemplate bool        `json:"cloudTemplate,omitempty"` // 云端模板
	TemplateParam interface{} `json:"params"`                  // 参数
	Title         string      `json:"subject,omitempty"`       // 标题
	Receiver      string      `json:"receiver"`                // 接收者,多个时用逗号分隔
}

MailRequest 邮件服务请求参数

type Option added in v0.7.1

type Option func(*messageClient)

func WithAuth added in v0.7.1

func WithAuth(appKey, secret string) Option

WithAuth Credentials配置

func WithHost added in v0.7.1

func WithHost(host string) Option

type Response

type Response struct {
	Code      interface{} `json:"code,omitempty"`
	Success   interface{} `json:"success,omitempty"`
	Message   string      `json:"message,omitempty"`
	MessageId int         `json:"messageId,omitempty"`
}

type SmsRequest

type SmsRequest struct {
	Template      string      `json:"template"` // 模板
	TemplateParam interface{} `json:"params"`   // 参数
	Receiver      string      `json:"receiver"` // 接收者,多个时用逗号分隔
}

SmsRequest 短信服务请求参数

Jump to

Keyboard shortcuts

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