取消api test秘钥信息
添加有票票渠道
This commit is contained in:
parent
15b7beba01
commit
4c4478dc84
10
index.go
10
index.go
@ -4,6 +4,7 @@ import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/platform/fliggy"
|
||||
shoutu_show "repository.lenntc.com/lenntc/third-platform-sdk/platform/shoutu-show"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/platform/youpiaopiao"
|
||||
|
||||
didiunion "repository.lenntc.com/lenntc/third-platform-sdk/platform/didi-union"
|
||||
elemeunion "repository.lenntc.com/lenntc/third-platform-sdk/platform/eleme-union"
|
||||
@ -37,6 +38,8 @@ const (
|
||||
PlatformFliggy = "fliggy"
|
||||
// PlatformShoutuShow 守兔演出
|
||||
PlatformShoutuShow = "shoutu_show"
|
||||
// PlatformYouPiaoPiao 有票票
|
||||
PlatformYouPiaoPiao = "youpiaopiao"
|
||||
)
|
||||
|
||||
// PlatformNameMap 平台名称
|
||||
@ -51,6 +54,7 @@ var PlatformNameMap = map[string]string{
|
||||
PlatformElongHotel: "同程酒店",
|
||||
PlatformFliggy: "飞猪",
|
||||
PlatformShoutuShow: "守兔演出",
|
||||
PlatformYouPiaoPiao: "有票票",
|
||||
}
|
||||
|
||||
// GetPlatformName 获取平台名称
|
||||
@ -103,6 +107,12 @@ func NewFliggyApi(log logx.Logger, conf fliggy.AuthConfig) fliggy.FliggyApi {
|
||||
return fliggy.NewApiClient(log, conf)
|
||||
}
|
||||
|
||||
// NewShoutuShow 守兔
|
||||
func NewShoutuShow(log logx.Logger, conf shoutu_show.AuthConfig) shoutu_show.ShouTuShowApi {
|
||||
return shoutu_show.NewApiClient(log, conf)
|
||||
}
|
||||
|
||||
// NewYouPiaoPiao 有票票
|
||||
func NewYouPiaoPiao(log logx.Logger, conf youpiaopiao.AuthConfig) youpiaopiao.YouPiaoPiaoApi {
|
||||
return youpiaopiao.NewApiClient(log, conf)
|
||||
}
|
||||
|
||||
@ -24,8 +24,8 @@ func TestApiClient(t *testing.T) {
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
AppKey: "2M0QUa0o6ER8nuX1",
|
||||
AppSecret: "obvJ5mmV45ZWA3YpO95njR1xH62JT50h",
|
||||
AppKey: "",
|
||||
AppSecret: "",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
@ -27,8 +27,8 @@ func TestApiClient(t *testing.T) {
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
AppKey: "34632005",
|
||||
AppSecret: "b0e6b6654825e6124f743b2528be95d7",
|
||||
AppKey: "",
|
||||
AppSecret: "",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ func TestApiClient(t *testing.T) {
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
Token: "dfae91a85341865b",
|
||||
Token: "",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
AppKey: "34755002",
|
||||
AppSecret: "0d4da23206d78ec991c3a96e789dec40",
|
||||
AppSecret: "",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ func TestApiClient(t *testing.T) {
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
ApiKey: "IyftVpzDVqDIRDqPZByW5xVpj9MgZSB7", //
|
||||
ApiKey: "", //
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
@ -22,8 +22,8 @@ func TestApiClient(t *testing.T) {
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
AppKey: "edf37a6019e045aeaec646220e4bd369",
|
||||
AppSecret: "975a5782165041be891c098cd3afe4ce",
|
||||
AppKey: "",
|
||||
AppSecret: "",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
@ -21,9 +21,8 @@ func TestApiClient(t *testing.T) {
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
//AppKey: "8b0a6d711cd573b5b048c90820dbb3fe756",
|
||||
SignKey: "3e4a697ecd9eafa27c2f3f4ccf22072d",
|
||||
NotifyKey: "gb8cwkj53x",
|
||||
SignKey: "",
|
||||
NotifyKey: "",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
@ -22,8 +22,8 @@ func TestApiClient(t *testing.T) {
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
AppKey: "QOHEgCUTeK",
|
||||
AppSecret: "tsTSxrCgibcFbxGOxRDEBGQUhRVJLsFs",
|
||||
AppKey: "",
|
||||
AppSecret: "",
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
33
platform/youpiaopiao/api.go
Normal file
33
platform/youpiaopiao/api.go
Normal file
@ -0,0 +1,33 @@
|
||||
package youpiaopiao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
// YouPiaoPiaoApi 有票票
|
||||
type YouPiaoPiaoApi interface {
|
||||
// GenerateH5Url 生成H5链接
|
||||
GenerateH5Url(ctx context.Context, req GenerateH5UrlRequest) (string, error)
|
||||
}
|
||||
type youpiaopiaoApiImpl struct {
|
||||
log logx.Logger
|
||||
client *Client
|
||||
}
|
||||
|
||||
func newYoupiaopiaoApiImpl(log logx.Logger, client *Client) YouPiaoPiaoApi {
|
||||
return &youpiaopiaoApiImpl{
|
||||
log: log,
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
// GenerateH5Url 生成H5推广链接
|
||||
func (a *youpiaopiaoApiImpl) GenerateH5Url(ctx context.Context, req GenerateH5UrlRequest) (string, error) {
|
||||
if len(req.ActivityUrl) == 0 {
|
||||
return "", errors.New("url参数不能为空")
|
||||
}
|
||||
return fmt.Sprintf("%s&entpara=%s", req.ActivityUrl, req.Sid), nil
|
||||
}
|
||||
45
platform/youpiaopiao/api_test.go
Normal file
45
platform/youpiaopiao/api_test.go
Normal file
@ -0,0 +1,45 @@
|
||||
package youpiaopiao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// api-单元测试
|
||||
type apiClientSuite struct {
|
||||
suite.Suite
|
||||
api YouPiaoPiaoApi
|
||||
}
|
||||
|
||||
func TestApiClient(t *testing.T) {
|
||||
suite.Run(t, new(apiClientSuite))
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) SetupSuite() {
|
||||
log := logx.WithContext(context.Background())
|
||||
apiClient := NewApiClient(log, AuthConfig{
|
||||
ApiKey: "", //
|
||||
})
|
||||
a.api = apiClient
|
||||
}
|
||||
|
||||
func (a *apiClientSuite) Test_GenerateLink() {
|
||||
req := GenerateH5UrlRequest{
|
||||
ActivityUrl: "",
|
||||
Sid: "f3a8c1",
|
||||
}
|
||||
result, err := a.api.GenerateH5Url(context.Background(), req)
|
||||
if !a.NoError(err) {
|
||||
a.T().Errorf("========[Test_GenerateLink] response error:%s", err)
|
||||
return
|
||||
}
|
||||
resultByte, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
a.T().Errorf("========[Test_GenerateLink] json_marshal error:%s", err)
|
||||
return
|
||||
}
|
||||
a.T().Logf("=====[Test_GenerateLink] result: %s", string(resultByte))
|
||||
}
|
||||
36
platform/youpiaopiao/client.go
Normal file
36
platform/youpiaopiao/client.go
Normal file
@ -0,0 +1,36 @@
|
||||
package youpiaopiao
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||||
)
|
||||
|
||||
// AuthConfig api鉴权参数
|
||||
type AuthConfig struct {
|
||||
ApiKey string // api key
|
||||
AppSecret string // api secret
|
||||
}
|
||||
|
||||
// 连接第三方平台的client
|
||||
type Client struct {
|
||||
log logx.Logger
|
||||
authConfig AuthConfig
|
||||
client.HttpClient
|
||||
headers map[string]string
|
||||
}
|
||||
|
||||
func NewApiClient(log logx.Logger, conf AuthConfig) YouPiaoPiaoApi {
|
||||
clt := newClient(log, conf)
|
||||
return newYoupiaopiaoApiImpl(log, clt)
|
||||
}
|
||||
|
||||
func newClient(log logx.Logger, conf AuthConfig) *Client {
|
||||
return &Client{
|
||||
log: log,
|
||||
authConfig: conf,
|
||||
HttpClient: client.NewHttpClient(log),
|
||||
headers: map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
}
|
||||
14
platform/youpiaopiao/consts.go
Normal file
14
platform/youpiaopiao/consts.go
Normal file
@ -0,0 +1,14 @@
|
||||
package youpiaopiao
|
||||
|
||||
// 相关地址
|
||||
const (
|
||||
SiteDomain = "https://www.youpiaopiao.cn" // Domain 后台域名
|
||||
SiteUrl = "https://www.youpiaopiao.cn" // SiteUrl 后台地址
|
||||
DocUrl = "https://www.youpiaopiao.cn" // DocUrl 文档地址
|
||||
ApiDocUrl = "https://www.youpiaopiao.cn" // ApiDocUrl api文档地址
|
||||
)
|
||||
|
||||
// 接口地址
|
||||
const (
|
||||
ApiDomain = "https://www.youpiaopiao.cn" // Domain api域名
|
||||
)
|
||||
7
platform/youpiaopiao/types.go
Normal file
7
platform/youpiaopiao/types.go
Normal file
@ -0,0 +1,7 @@
|
||||
package youpiaopiao
|
||||
|
||||
// GenerateH5UrlRequest 生成H5链接请求
|
||||
type GenerateH5UrlRequest struct {
|
||||
ActivityUrl string `json:"activityUrl"` // 活动url
|
||||
Sid string `json:"sid"` // 二级分销ID
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user