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.opt.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 GoodsOptGetResponse struct {
GoodsOptGetResponse struct {
GoodsOptList []struct {
Level int `json:"level"` // 层级1-一级2-二级3-三级4-四级
OptId int `json:"opt_id"` // 商品标签ID
OptName string `json:"opt_name"` // 商品标签名
ParentOptId int `json:"parent_opt_id"` // id所属父ID其中parent_id=0时为顶级节点
} `json:"goods_opt_list"`
} `json:"goods_opt_get_response"`
}
type GoodsOptGetResult struct {
Result GoodsOptGetResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
}
func newGoodsOptGetResult(result GoodsOptGetResponse, body []byte, http gorequest.Response, err error) *GoodsOptGetResult {
return &GoodsOptGetResult{Result: result, Body: body, Http: http, Err: err}
}
// GoodsOptGet 查询商品标签列表
// https://open.pinduoduo.com/application/document/api?id=pdd.goods.opt.get
func (c *Client) GoodsOptGet(ctx context.Context, parentOptId int) *GoodsOptGetResult {
// 参数
param := NewParams()
param.Set("parent_opt_id", parentOptId)
params := NewParamsWithType("pdd.goods.opt.get", param)
// 请求
request, err := c.request(ctx, params)
// 定义
var response GoodsOptGetResponse
err = json.Unmarshal(request.ResponseBody, &response)
return newGoodsOptGetResult(response, request.ResponseBody, request, err)
}