新增发送短信v2接口
This commit is contained in:
parent
eb6157ce05
commit
5f5a1160bf
@ -88,6 +88,22 @@ func (c *Client) SendSms(req *SendSmsRequest) (resp *SendSmsResponse, err error)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) SendSmsV2(req *SendSmsRequestV2) (resp *SendSmsResponseV2, err error) {
|
||||||
|
|
||||||
|
if req.Mobile == "" {
|
||||||
|
err = errors.New("mobile is empty")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Type == "" {
|
||||||
|
err = errors.New("type is empty")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp = CreateSendSmsResponseV2()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func getToken(key string) (ts int64, token string) {
|
func getToken(key string) (ts int64, token string) {
|
||||||
ts = time.Now().Unix()
|
ts = time.Now().Unix()
|
||||||
hash := md5.New()
|
hash := md5.New()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package sms
|
package sms
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
"testing"
|
"testing"
|
||||||
@ -140,3 +141,30 @@ func TestClient_SendSmsUrl(t *testing.T) {
|
|||||||
|
|
||||||
fmt.Println(sms)
|
fmt.Println(sms)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClient_SendSmsCodeV2(t *testing.T) {
|
||||||
|
req := CreateSendSmsRequestV2(SendSmsParamV2{
|
||||||
|
Mobile: "18320021439",
|
||||||
|
Type: SmsTypeBindPhone,
|
||||||
|
Replaces: []Item{{
|
||||||
|
Key: ReplaceKeyCode,
|
||||||
|
Value: "6379",
|
||||||
|
}, {
|
||||||
|
Key: ReplaceKeySecond,
|
||||||
|
Value: "120",
|
||||||
|
}},
|
||||||
|
Company: "",
|
||||||
|
Ip: "192.168.1.103",
|
||||||
|
})
|
||||||
|
|
||||||
|
sms, err := client.SendSmsV2(req)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
marshal, err := json.Marshal(sms)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
fmt.Println(string(marshal))
|
||||||
|
}
|
||||||
|
@ -29,6 +29,20 @@ type SendSmsResponse struct {
|
|||||||
*responses.BaseResponse
|
*responses.BaseResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SendSmsRequestV2 struct {
|
||||||
|
*requests.JsonRequest
|
||||||
|
Mobile string `position:"Json" field:"mobile"`
|
||||||
|
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
|
type SmsType = string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -44,6 +58,14 @@ type SendSmsParam struct {
|
|||||||
Replaces []Item
|
Replaces []Item
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SendSmsParamV2 struct {
|
||||||
|
Mobile string // 手机号
|
||||||
|
Type SmsType // 验证码类型
|
||||||
|
Replaces []Item
|
||||||
|
Company string // 子游戏公司主体
|
||||||
|
Ip string // ip
|
||||||
|
}
|
||||||
|
|
||||||
func CreateSendSmsRequest(param SendSmsParam) (req *SendSmsRequest) {
|
func CreateSendSmsRequest(param SendSmsParam) (req *SendSmsRequest) {
|
||||||
req = &SendSmsRequest{
|
req = &SendSmsRequest{
|
||||||
JsonRequest: &requests.JsonRequest{},
|
JsonRequest: &requests.JsonRequest{},
|
||||||
@ -62,3 +84,24 @@ func CreateSendSmsResponse() (resp *SendSmsResponse) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CreateSendSmsRequestV2(param SendSmsParamV2) (req *SendSmsRequestV2) {
|
||||||
|
req = &SendSmsRequestV2{
|
||||||
|
JsonRequest: &requests.JsonRequest{},
|
||||||
|
Mobile: param.Mobile,
|
||||||
|
Type: param.Type,
|
||||||
|
Replaces: param.Replaces,
|
||||||
|
Company: param.Company,
|
||||||
|
Ip: param.Ip,
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/v1/sms/send")
|
||||||
|
req.Method = requests.POST
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateSendSmsResponseV2() (resp *SendSmsResponseV2) {
|
||||||
|
resp = &SendSmsResponseV2{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user