1 Star 0 Fork 0

h79 / gothird

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
agent.go 1.67 KB
一键复制 编辑 原始数据 按行查看 历史
huqiuyun 提交于 2024-04-15 14:17 . 可见范围
package work
import (
"encoding/json"
"fmt"
"gitee.com/h79/gothird/token"
"gitee.com/h79/gothird/weixin/consts"
"gitee.com/h79/gothird/weixin/response"
"gitee.com/h79/gothird/weixin/work/structs"
"gitee.com/h79/goutils/common/http"
)
// AGGetDetail 获取指定的应用详情
// 对于互联企业的应用,如果需要获取应用可见范围内其他互联企业的部门与成员,请调用互联企业-获取应用可见范围接口
// 请求方式:GET(HTTPS)
// 请求地址:https://qyapi.weixin.qq.com/cgi-bin/agent/get?access_token=ACCESS_TOKEN&agentid=AGENTID
func AGGetDetail(api *token.Api, agentId string) (structs.AgentDetail, error) {
url := fmt.Sprintf("%s/cgi-bin/agent/get?agentid=%s&", consts.WorkApiPrefixUrl, agentId)
var res = struct {
response.Response
structs.AgentDetail
}{}
err := api.Request("GET", url, nil, func(hp *http.Http, body []byte) error {
if er := json.Unmarshal(body, &res); er != nil {
return er
}
return res.ReturnIf(api)
})
if err != nil {
return structs.AgentDetail{}, err
}
return res.AgentDetail, res.ErrorIf()
}
// AGGetList 请求方式:GET(HTTPS)
// 请求地址:https://qyapi.weixin.qq.com/cgi-bin/agent/list?access_token=ACCESS_TOKEN
func AGGetList(api *token.Api) ([]structs.AgentInfo, error) {
url := fmt.Sprintf("%s/cgi-bin/agent/list?", consts.WorkApiPrefixUrl)
var res = struct {
response.Response
List []structs.AgentInfo `json:"agentlist"`
}{}
err := api.Request("GET", url, nil, func(hp *http.Http, body []byte) error {
if er := json.Unmarshal(body, &res); er != nil {
return er
}
return res.ReturnIf(api)
})
if err != nil {
return nil, err
}
return res.List, res.ErrorIf()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/h79/gothird.git
git@gitee.com:h79/gothird.git
h79
gothird
gothird
v1.8.106

搜索帮助

344bd9b3 5694891 D2dac590 5694891