/
tbk.shop.get.go
50 lines (45 loc) · 1.53 KB
/
tbk.shop.get.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package taobao
import (
"context"
"go.dtapp.net/gojson"
"go.dtapp.net/gorequest"
)
type TbkShopGetResponse struct {
TbkShopGetResponse struct {
Results struct {
NTbkShop []struct {
PictUrl string `json:"pict_url"`
SellerNick string `json:"seller_nick"`
ShopTitle string `json:"shop_title"`
ShopType string `json:"shop_type"`
ShopUrl string `json:"shop_url"`
UserId int64 `json:"user_id"`
} `json:"n_tbk_shop"`
} `json:"results"`
TotalResults int `json:"total_results"`
RequestId string `json:"request_id"`
} `json:"tbk_shop_get_response"`
}
type TbkShopGetResult struct {
Result TbkShopGetResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
}
func newTbkShopGetResult(result TbkShopGetResponse, body []byte, http gorequest.Response) *TbkShopGetResult {
return &TbkShopGetResult{Result: result, Body: body, Http: http}
}
// TbkShopGet 淘宝客-推广者-店铺搜索
// https://open.taobao.com/api.htm?docId=24521&docType=2
func (c *Client) TbkShopGet(ctx context.Context, notMustParams ...gorequest.Params) (*TbkShopGetResult, error) {
// 参数
params := NewParamsWithType("taobao.tbk.shop.get", notMustParams...)
// 请求
request, err := c.request(ctx, params)
if err != nil {
return newTbkShopGetResult(TbkShopGetResponse{}, request.ResponseBody, request), err
}
// 定义
var response TbkShopGetResponse
err = gojson.Unmarshal(request.ResponseBody, &response)
return newTbkShopGetResult(response, request.ResponseBody, request), err
}