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.
wechatunion/promoter.promotion.list.go

49 lines
1.9 KiB

2 years ago
package wechatunion
import (
2 years ago
"context"
2 years ago
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
"net/http"
)
type PromotionListResponse struct {
Errcode int `json:"errcode"` // 错误码
Errmsg string `json:"errmsg"` // 错误信息
PromotionSourceList []struct {
PromotionSourceName string `json:"promotionSourceName"` // 推广位名称
PromotionSourcePid string `json:"promotionSourcePid"` // 推广位IDPID
Status string `json:"status"` // 状态
PidId string `json:"pidId"`
} `json:"promotionSourceList"` // 推广位数据
Total int `json:"total"` // 推广位总数
PromotionMaxCnt int `json:"promotionMaxCnt"` // 允许创建的推广位最大数量
}
type PromotionListResult struct {
Result PromotionListResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
}
2 years ago
func newPromotionListResult(result PromotionListResponse, body []byte, http gorequest.Response, err error) *PromotionListResult {
2 years ago
return &PromotionListResult{Result: result, Body: body, Http: http, Err: err}
}
// PromotionList 获取推广位列表
// https://developers.weixin.qq.com/doc/ministore/union/access-guidelines/promoter/api/promotion.html#_4-%E8%8E%B7%E5%8F%96%E6%8E%A8%E5%B9%BF%E4%BD%8D%E5%88%97%E8%A1%A8
2 years ago
func (c *Client) PromotionList(ctx context.Context, start int, limit int) *PromotionListResult {
2 years ago
// 参数
2 years ago
params := gorequest.NewParams()
2 years ago
params.Set("start", start) // 偏移
params.Set("limit", limit) // 每页条数
// 请求
2 years ago
request, err := c.request(ctx, apiUrl+fmt.Sprintf("/promoter/promotion/list?access_token%s", c.getAccessToken(ctx)), params, http.MethodGet)
2 years ago
// 定义
var response PromotionListResponse
err = json.Unmarshal(request.ResponseBody, &response)
2 years ago
return newPromotionListResult(response, request.ResponseBody, request, err)
2 years ago
}