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.
42 lines
1.6 KiB
42 lines
1.6 KiB
package wechatunion
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/http"
|
|
)
|
|
|
|
type PromoterProductCategoryResponse struct {
|
|
Errcode int `json:"errcode"` // 错误码
|
|
Errmsg string `json:"errmsg"` // 错误信息
|
|
ProductCats []struct {
|
|
CatId string `json:"catId"` // 类目ID
|
|
Name string `json:"name"` // 类目名称
|
|
} `json:"productCats"` // 类目数据
|
|
}
|
|
|
|
type PromoterProductCategoryResult struct {
|
|
Result PromoterProductCategoryResponse // 结果
|
|
Body []byte // 内容
|
|
Err error // 错误
|
|
}
|
|
|
|
func NewPromoterProductCategoryResult(result PromoterProductCategoryResponse, body []byte, err error) *PromoterProductCategoryResult {
|
|
return &PromoterProductCategoryResult{Result: result, Body: body, Err: err}
|
|
}
|
|
|
|
// PromoterProductCategory 获取联盟商品类目列表及类目ID
|
|
// https://developers.weixin.qq.com/doc/ministore/union/access-guidelines/promoter/api/product/category.html#_1-%E8%8E%B7%E5%8F%96%E8%81%94%E7%9B%9F%E5%95%86%E5%93%81%E7%B1%BB%E7%9B%AE%E5%88%97%E8%A1%A8%E5%8F%8A%E7%B1%BB%E7%9B%AEID
|
|
func (app *App) PromoterProductCategory() *PromoterProductCategoryResult {
|
|
app.AccessToken = app.GetAccessToken()
|
|
// 请求
|
|
body, err := app.request(UnionUrl+fmt.Sprintf("/promoter/product/category?access_token=%s", app.AccessToken), map[string]interface{}{}, http.MethodGet)
|
|
if err != nil {
|
|
return NewPromoterProductCategoryResult(PromoterProductCategoryResponse{}, body, err)
|
|
}
|
|
// 定义
|
|
var response PromoterProductCategoryResponse
|
|
err = json.Unmarshal(body, &response)
|
|
return NewPromoterProductCategoryResult(response, body, err)
|
|
}
|