1 Star 0 Fork 0

kingwebasp / openpdd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
user_permit.go 1.21 KB
一键复制 编辑 原始数据 按行查看 历史
kingwebasp 提交于 2023-11-14 17:11 . 初始化导入
package pmc
import (
"strings"
"gitee.com/kingwebasp/openpdd/core"
"gitee.com/kingwebasp/openpdd/model"
)
// UserPermitRequest 为已授权的用户开通消息服务 API Request
type UserPermitRequest struct {
// Topics 消息主题列表,用半角逗号分隔。当用户订阅的topic是应用订阅的子集时才需要设置,不设置表示继承应用所订阅的所有topic,一般情况建议不要设置。
Topics string `json:"topics,omitempty"`
}
// GetType implement Request interface
func (r UserPermitRequest) GetType() string {
return "pdd.pmc.user.permit"
}
// UserPermitResponse 为已授权的用户开通消息服务 API Response
type UserPermitResponse struct {
model.CommonResponse
Response struct {
// IsSuccess 是否成功
IsSuccess bool `json:"is_success,omitempty"`
} `json:"pmc_user_permit_response"`
}
// UserPermit 为已授权的用户开通消息服务
func UserPermit(clt *core.SDKClient, topics []string, accessToken string) (bool, error) {
var req UserPermitRequest
if len(topics) > 0 {
req.Topics = strings.Join(topics, ",")
}
var resp UserPermitResponse
if err := clt.Do(&req, &resp, accessToken); err != nil {
return false, err
}
return resp.Response.IsSuccess, nil
}
1
https://gitee.com/kingwebasp/openpdd.git
git@gitee.com:kingwebasp/openpdd.git
kingwebasp
openpdd
openpdd
v1.0.13

搜索帮助

53164aa7 5694891 3bd8fe86 5694891