mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-15 10:12:28 +08:00
企业微信-通讯录管理-标签管理-获取/增加/删除标签成员、获取标签列表 (#674)
* 企业微信-客户联系-统计管理 * 企业微信-客户联系-统计管理 * 企业微信-客户联系-统计管理 * debug * rollback * debug * debug * 获取用户信息 * token * json.Marshal错误输出 * debug * bugfix * 企业微信-通讯录管理相关接口 * 企业微信-通讯录管理 * 企业微信-通讯录管理 * 企业微信-通讯录管理 * 企业微信-[联系我]方式新增和查询 * 企业微信-[联系我]方式新增和获取 * 企业微信-[联系我]方式更新 * 企业微信-[联系我]方式列表、删除 * json.Marshal错误输出 * 已实现接口bug修改 * 历史接口bugfix * 历史接口bugfix * comment * 企业微信:客户联系-消息推送;素材管理-上传图片 * fix * 企业微信-获取群发记录列表 * 历史接口bugfix * 1.企业微信-客户联系-消息推送-入群欢迎语素材管理 2.企业微信-通讯录管理-成员管理-获取成员ID列表 * golangci-lint * gofmt * 方法访问命名 * 企业微信-批量获取客户详情入参优化 * 企业微信-通讯录管理-标签管理-创建/更新/删除标签 * 请求地址常量无需导出 * 企业微信保持代码风格统一,接口URL不导出 * 企业微信-通讯录管理-标签管理-获取/增加/删除标签成员、获取标签列表 --------- Co-authored-by: wang.yu <wangyu@uniondrug.com> Co-authored-by: markwang <www.wang61@qq.com>
This commit is contained in:
@@ -13,6 +13,14 @@ const (
|
|||||||
updateTagURL = "https://qyapi.weixin.qq.com/cgi-bin/tag/update?access_token=%s"
|
updateTagURL = "https://qyapi.weixin.qq.com/cgi-bin/tag/update?access_token=%s"
|
||||||
// deleteTagURL 删除标签
|
// deleteTagURL 删除标签
|
||||||
deleteTagURL = "https://qyapi.weixin.qq.com/cgi-bin/tag/delete?access_token=%s&tagid=%d"
|
deleteTagURL = "https://qyapi.weixin.qq.com/cgi-bin/tag/delete?access_token=%s&tagid=%d"
|
||||||
|
// getTagURL 获取标签成员
|
||||||
|
getTagURL = "https://qyapi.weixin.qq.com/cgi-bin/tag/get?access_token=%s&tagid=%d"
|
||||||
|
// addTagUsersURL 增加标签成员
|
||||||
|
addTagUsersURL = "https://qyapi.weixin.qq.com/cgi-bin/tag/addtagusers?access_token=%s"
|
||||||
|
// delTagUsersURL 删除标签成员
|
||||||
|
delTagUsersURL = "https://qyapi.weixin.qq.com/cgi-bin/tag/deltagusers?access_token=%s"
|
||||||
|
// listTagURL 获取标签列表
|
||||||
|
listTagURL = "https://qyapi.weixin.qq.com/cgi-bin/tag/list?access_token=%s"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@@ -90,3 +98,145 @@ func (r *Client) DeleteTag(tagID int) error {
|
|||||||
}
|
}
|
||||||
return util.DecodeWithCommonError(response, "DeleteTag")
|
return util.DecodeWithCommonError(response, "DeleteTag")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
// GetTagResponse 获取标签成员响应
|
||||||
|
GetTagResponse struct {
|
||||||
|
util.CommonError
|
||||||
|
TagName string `json:"tagname"`
|
||||||
|
UserList []GetTagUserList `json:"userlist"`
|
||||||
|
PartyList []int `json:"partylist"`
|
||||||
|
}
|
||||||
|
// GetTagUserList 标签中包含的成员列表
|
||||||
|
GetTagUserList struct {
|
||||||
|
UserID string `json:"userid"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetTag 获取标签成员
|
||||||
|
// @see https://developer.work.weixin.qq.com/document/path/90213
|
||||||
|
func (r *Client) GetTag(tagID int) (*GetTagResponse, error) {
|
||||||
|
var (
|
||||||
|
accessToken string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var response []byte
|
||||||
|
if response, err = util.HTTPGet(fmt.Sprintf(getTagURL, accessToken, tagID)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &GetTagResponse{}
|
||||||
|
if err = util.DecodeWithError(response, result, "GetTag"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
// AddTagUsersRequest 增加标签成员请求
|
||||||
|
AddTagUsersRequest struct {
|
||||||
|
TagID int `json:"tagid"`
|
||||||
|
UserList []string `json:"userlist"`
|
||||||
|
PartyList []int `json:"partylist"`
|
||||||
|
}
|
||||||
|
// AddTagUsersResponse 增加标签成员响应
|
||||||
|
AddTagUsersResponse struct {
|
||||||
|
util.CommonError
|
||||||
|
InvalidList string `json:"invalidlist"`
|
||||||
|
InvalidParty []int `json:"invalidparty"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddTagUsers 增加标签成员
|
||||||
|
// see https://developer.work.weixin.qq.com/document/path/90214
|
||||||
|
func (r *Client) AddTagUsers(req *AddTagUsersRequest) (*AddTagUsersResponse, error) {
|
||||||
|
var (
|
||||||
|
accessToken string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var response []byte
|
||||||
|
if response, err = util.PostJSON(fmt.Sprintf(addTagUsersURL, accessToken), req); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &AddTagUsersResponse{}
|
||||||
|
if err = util.DecodeWithError(response, result, "AddTagUsers"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
// DelTagUsersRequest 删除标签成员请求
|
||||||
|
DelTagUsersRequest struct {
|
||||||
|
TagID int `json:"tagid"`
|
||||||
|
UserList []string `json:"userlist"`
|
||||||
|
PartyList []int `json:"partylist"`
|
||||||
|
}
|
||||||
|
// DelTagUsersResponse 删除标签成员响应
|
||||||
|
DelTagUsersResponse struct {
|
||||||
|
util.CommonError
|
||||||
|
InvalidList string `json:"invalidlist"`
|
||||||
|
InvalidParty []int `json:"invalidparty"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// DelTagUsers 删除标签成员
|
||||||
|
// see https://developer.work.weixin.qq.com/document/path/90215
|
||||||
|
func (r *Client) DelTagUsers(req *DelTagUsersRequest) (*DelTagUsersResponse, error) {
|
||||||
|
var (
|
||||||
|
accessToken string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var response []byte
|
||||||
|
if response, err = util.PostJSON(fmt.Sprintf(delTagUsersURL, accessToken), req); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &DelTagUsersResponse{}
|
||||||
|
if err = util.DecodeWithError(response, result, "DelTagUsers"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
// ListTagResponse 获取标签列表响应
|
||||||
|
ListTagResponse struct {
|
||||||
|
util.CommonError
|
||||||
|
TagList []Tag `json:"taglist"`
|
||||||
|
}
|
||||||
|
// Tag 标签
|
||||||
|
Tag struct {
|
||||||
|
TagID int `json:"tagid"`
|
||||||
|
TagName string `json:"tagname"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListTag 获取标签列表
|
||||||
|
// @see https://developer.work.weixin.qq.com/document/path/90216
|
||||||
|
func (r *Client) ListTag() (*ListTagResponse, error) {
|
||||||
|
var (
|
||||||
|
accessToken string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var response []byte
|
||||||
|
if response, err = util.HTTPGet(fmt.Sprintf(listTagURL, accessToken)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &ListTagResponse{}
|
||||||
|
if err = util.DecodeWithError(response, result, "ListTag"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user