sms优化
This commit is contained in:
parent
7c96d7163b
commit
3652d43f34
@ -83,17 +83,6 @@ func (c *Client) SendSms(req *SendSmsRequest) (resp *SendSmsResponse, err error)
|
|||||||
err = errors.New("type is empty")
|
err = errors.New("type is empty")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Expired == 0 {
|
|
||||||
err = errors.New("expired is empty")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if req.Code == 0 {
|
|
||||||
err = errors.New("code is empty")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
resp = CreateSendSmsResponse()
|
resp = CreateSendSmsResponse()
|
||||||
err = c.DoAction(req, resp)
|
err = c.DoAction(req, resp)
|
||||||
return
|
return
|
||||||
|
@ -94,12 +94,39 @@ func TestClient_SendFeiShuWebHook(t *testing.T) {
|
|||||||
fmt.Println(resp3)
|
fmt.Println(resp3)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_SendSms(t *testing.T) {
|
func TestClient_SendSmsCode(t *testing.T) {
|
||||||
req := CreateSendSmsRequest(SendSmsParam{
|
req := CreateSendSmsRequest(SendSmsParam{
|
||||||
Mobile: "18320021439",
|
Mobile: "18320021439",
|
||||||
Type: SmsTypeBindPhone,
|
Type: SmsTypeBindPhone,
|
||||||
Code: 123456,
|
Replaces: []Item{{
|
||||||
Expired: 5,
|
Key: ReplaceKeyCode,
|
||||||
|
Value: "6379",
|
||||||
|
}, {
|
||||||
|
Key: ReplaceKeySecond,
|
||||||
|
Value: "120",
|
||||||
|
}},
|
||||||
|
})
|
||||||
|
|
||||||
|
req.Domain = requests.Host{
|
||||||
|
Default: "127.0.0.1:8804",
|
||||||
|
}
|
||||||
|
|
||||||
|
sms, err := client.SendSms(req)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(sms)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestClient_SendSmsUrl(t *testing.T) {
|
||||||
|
req := CreateSendSmsRequest(SendSmsParam{
|
||||||
|
Mobile: "18320021439",
|
||||||
|
Type: TemplateTypeOrderComplete,
|
||||||
|
Replaces: []Item{{
|
||||||
|
Key: ReplaceKeyUrl,
|
||||||
|
Value: "http://www.baidu.com",
|
||||||
|
}},
|
||||||
})
|
})
|
||||||
|
|
||||||
req.Domain = requests.Host{
|
req.Domain = requests.Host{
|
||||||
|
@ -32,7 +32,7 @@ func CreateSendEmailRequest(param SendEmailParam) (req *SendEmailRequest) {
|
|||||||
Body: param.Body,
|
Body: param.Body,
|
||||||
FromName: param.FromName,
|
FromName: param.FromName,
|
||||||
}
|
}
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/email/send")
|
req.InitWithApiInfo(HOST, VERSION, "/v1/email/send")
|
||||||
req.Method = requests.POST
|
req.Method = requests.POST
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ func CreateSendFeiShuWebHookRequest(param SendFeiShuWebHookParam) (req *SendFeiS
|
|||||||
Title: param.Title,
|
Title: param.Title,
|
||||||
TitleColor: param.TitleColor,
|
TitleColor: param.TitleColor,
|
||||||
}
|
}
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/feishu/webhook_send")
|
req.InitWithApiInfo(HOST, VERSION, "/v1/feishu/webhook_send")
|
||||||
req.Method = requests.POST
|
req.Method = requests.POST
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,24 @@ import (
|
|||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
"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 {
|
type SendSmsRequest struct {
|
||||||
*requests.JsonRequest
|
*requests.JsonRequest
|
||||||
Mobile string `position:"Json" field:"mobile"`
|
Mobile string `position:"Json" field:"mobile"`
|
||||||
Type string `position:"Json" field:"type"`
|
Type string `position:"Json" field:"type"`
|
||||||
Expired int64 `position:"Json" field:"expired"`
|
Replaces []Item `position:"Json" field:"replaces"`
|
||||||
Code int64 `position:"Json" field:"code"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type SendSmsResponse struct {
|
type SendSmsResponse struct {
|
||||||
@ -20,15 +32,16 @@ type SendSmsResponse struct {
|
|||||||
type SmsType = string
|
type SmsType = string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SmsTypeRegister SmsType = "reg" // 注册
|
SmsTypeRegister SmsType = "reg" // 注册
|
||||||
SmsTypeBindPhone SmsType = "bind_phone" // 绑定手机号
|
SmsTypeBindPhone SmsType = "bind_phone" // 绑定手机号
|
||||||
|
TemplateTypeOrderComplete SmsType = "kf_order_complete" // 客服工单完成
|
||||||
|
TemplateTypeKFOrderAdditional SmsType = "kf_order_additional" // 客服工单完成
|
||||||
)
|
)
|
||||||
|
|
||||||
type SendSmsParam struct {
|
type SendSmsParam struct {
|
||||||
Mobile string // 手机号
|
Mobile string // 手机号
|
||||||
Type SmsType // 验证码类型
|
Type SmsType // 验证码类型
|
||||||
Expired int64 // 过期时间,秒数
|
Replaces []Item
|
||||||
Code int64 // 验证码
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateSendSmsRequest(param SendSmsParam) (req *SendSmsRequest) {
|
func CreateSendSmsRequest(param SendSmsParam) (req *SendSmsRequest) {
|
||||||
@ -36,10 +49,9 @@ func CreateSendSmsRequest(param SendSmsParam) (req *SendSmsRequest) {
|
|||||||
JsonRequest: &requests.JsonRequest{},
|
JsonRequest: &requests.JsonRequest{},
|
||||||
Mobile: param.Mobile,
|
Mobile: param.Mobile,
|
||||||
Type: param.Type,
|
Type: param.Type,
|
||||||
Expired: param.Expired,
|
Replaces: param.Replaces,
|
||||||
Code: param.Code,
|
|
||||||
}
|
}
|
||||||
req.InitWithApiInfo(HOST, VERSION, "/sms/agg/send")
|
req.InitWithApiInfo(HOST, VERSION, "/v1/sms/send")
|
||||||
req.Method = requests.POST
|
req.Method = requests.POST
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user