You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pinduoduo/pdd.goods.cats.get.go

45 lines
1.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package pinduoduo
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
)
type GoodsCatsGetResponse struct {
GoodsCatsGetResponse struct {
GoodsCatsList []struct {
CatId int `json:"cat_id"` // 商品类目ID
CatName string `json:"cat_name"` // 商品类目名称
Level int `json:"level"` // 类目层级1-一级类目2-二级类目3-三级类目4-四级类目
ParentCatID int `json:"parent_cat_id"` // id所属父类目ID其中parent_id=0时为顶级节点
} `json:"goods_cats_list"`
} `json:"goods_cats_get_response"`
}
type GoodsCatsGetResult struct {
Result GoodsCatsGetResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
}
func newGoodsCatsGetResult(result GoodsCatsGetResponse, body []byte, http gorequest.Response, err error) *GoodsCatsGetResult {
return &GoodsCatsGetResult{Result: result, Body: body, Http: http, Err: err}
}
// GoodsCatsGet 商品标准类目接口
// https://open.pinduoduo.com/application/document/api?id=pdd.goods.cats.get
func (c *Client) GoodsCatsGet(ctx context.Context, parentOptId int) *GoodsCatsGetResult {
// 参数
param := NewParams()
param.Set("parent_cat_id", parentOptId)
params := NewParamsWithType("pdd.goods.cats.get", param)
// 请求
request, err := c.request(ctx, params)
// 定义
var response GoodsCatsGetResponse
err = json.Unmarshal(request.ResponseBody, &response)
return newGoodsCatsGetResult(response, request.ResponseBody, request, err)
}