third-platform-sdk/platform/zjdg/api.go
2025-02-24 16:51:08 +08:00

44 lines
1.2 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package zjdg
import (
"fmt"
"github.com/zeromicro/go-zero/core/logx"
"repository.lenntc.com/lenntc/third-platform-sdk/client"
"repository.lenntc.com/lenntc/third-platform-sdk/util"
)
// ZjdgApi 中捷乐淘-淘宝一分购
type ZjdgApi interface {
// ZoneAdd 获取推广编号-创建
ZoneAdd(req *ZoneAddRequest) (*ZoneAddResponse, error)
}
type zjdgApiImpl struct {
log logx.Logger
client *Client
}
func newZjdgApiImpl(log logx.Logger, client *Client) ZjdgApi {
return &zjdgApiImpl{
log: log,
client: client,
}
}
// ZoneAdd 获取推广编号
func (a *zjdgApiImpl) ZoneAdd(req *ZoneAddRequest) (*ZoneAddResponse, error) {
// 响应示例 {"code":0,"message":"获取成功","data":"1963667","token_id":""}
zoneAddUrl := fmt.Sprintf("%s%s", ZoneAddUrl, a.client.authConfig.UserId)
args := util.StructToMap(req)
request := &client.HttpRequest{Headers: a.client.headers, QueryArgs: args}
response := new(ZoneAddOriginResponse)
if err := a.client.HttpGet(zoneAddUrl, request, &client.HttpResponse{Result: response}); err != nil {
return nil, err
}
if response.Code != 0 {
return nil, fmt.Errorf("获取推广编号失败返回Code=%d", response.Code)
}
return &ZoneAddResponse{
AdZoneId: response.Data,
}, nil
}