6
0
gaore-common-sdk-go/services/sms/sms.go

108 lines
2.7 KiB
Go

package sms
import (
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
)
type ReplaceKey = string
const (
ReplaceKeyCode ReplaceKey = "${code}" // 验证码
ReplaceKeySecond ReplaceKey = "${second}" // 秒数
ReplaceKeyUrl ReplaceKey = "${url}" // 链接
)
type Item struct {
Key ReplaceKey // 要替换的key
Value string // 要替换的值
}
type SendSmsRequest struct {
*requests.JsonRequest
Mobile string `position:"Json" field:"mobile"`
Type string `position:"Json" field:"type"`
Replaces []Item `position:"Json" field:"replaces"`
}
type SendSmsResponse struct {
*responses.BaseResponse
}
type SendSmsRequestV2 struct {
*requests.JsonRequest
Phone string `position:"Json" field:"phone"`
Type string `position:"Json" field:"type"`
Replaces []Item `position:"Json" field:"replaces"`
Company string `position:"Json" field:"company"`
Ip string `position:"Json" field:"ip"`
}
type SendSmsResponseV2 struct {
*responses.BaseResponse
TraceID string `json:"trace_id"`
}
type SmsType = string
const (
SmsTypeRegister SmsType = "reg" // 注册
SmsTypeBindPhone SmsType = "bind_phone" // 绑定手机号
TemplateTypeOrderComplete SmsType = "kf_order_complete" // 客服工单完成
TemplateTypeKFOrderAdditional SmsType = "kf_order_additional" // 客服工单完成
)
type SendSmsParam struct {
Mobile string // 手机号
Type SmsType // 验证码类型
Replaces []Item
}
type SendSmsParamV2 struct {
Phone string // 手机号
Type SmsType // 验证码类型
Replaces []Item
Company string // 子游戏公司主体
Ip string // ip
}
func CreateSendSmsRequest(param SendSmsParam) (req *SendSmsRequest) {
req = &SendSmsRequest{
JsonRequest: &requests.JsonRequest{},
Mobile: param.Mobile,
Type: param.Type,
Replaces: param.Replaces,
}
req.InitWithApiInfo(HOST, VERSION, "/v1/sms/send")
req.Method = requests.POST
return
}
func CreateSendSmsResponse() (resp *SendSmsResponse) {
resp = &SendSmsResponse{
BaseResponse: &responses.BaseResponse{},
}
return
}
func CreateSendSmsRequestV2(param SendSmsParamV2) (req *SendSmsRequestV2) {
req = &SendSmsRequestV2{
JsonRequest: &requests.JsonRequest{},
Phone: param.Phone,
Type: param.Type,
Replaces: param.Replaces,
Company: param.Company,
Ip: param.Ip,
}
req.InitWithApiInfo(HOST, VERSION, "/v2/sms/send")
req.Method = requests.POST
return
}
func CreateSendSmsResponseV2() (resp *SendSmsResponseV2) {
resp = &SendSmsResponseV2{
BaseResponse: &responses.BaseResponse{},
}
return
}