44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
|
|
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
|
|||
|
|
}
|