mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-04 12:52:27 +08:00
企业微信-欢迎语素材管理,企业微信-获取成员ID列表 (#629)
* 企业微信-客户联系-统计管理 * 企业微信-客户联系-统计管理 * 企业微信-客户联系-统计管理 * debug * rollback * debug * debug * 获取用户信息 * token * json.Marshal错误输出 * debug * bugfix * 企业微信-通讯录管理相关接口 * 企业微信-通讯录管理 * 企业微信-通讯录管理 * 企业微信-通讯录管理 * 企业微信-[联系我]方式新增和查询 * 企业微信-[联系我]方式新增和获取 * 企业微信-[联系我]方式更新 * 企业微信-[联系我]方式列表、删除 * json.Marshal错误输出 * 已实现接口bug修改 * 历史接口bugfix * 历史接口bugfix * comment * 企业微信:客户联系-消息推送;素材管理-上传图片 * fix * 企业微信-获取群发记录列表 * 历史接口bugfix * 1.企业微信-客户联系-消息推送-入群欢迎语素材管理 2.企业微信-通讯录管理-成员管理-获取成员ID列表 * golangci-lint * gofmt * 方法访问命名 Co-authored-by: wang.yu <wangyu@uniondrug.com>
This commit is contained in:
@@ -62,21 +62,25 @@ host: https://qyapi.weixin.qq.com/
|
||||
### 客户联系
|
||||
[官方文档](https://developer.work.weixin.qq.com/document/path/92132/92133/92228)
|
||||
|
||||
| 名称 | 请求方式 | URL | 是否已实现 | 使用方法 | 贡献者 |
|
||||
|:------------------------:| -------- | :---------------------------------------| ---------- | ------------------------------- |----------|
|
||||
| 获取「联系客户统计」数据 | POST | /cgi-bin/externalcontact/get_user_behavior_data | YES | (r *Client) GetUserBehaviorData | MARKWANG |
|
||||
| 获取「群聊数据统计」数据 (按群主聚合的方式) | POST | /cgi-bin/externalcontact/groupchat/statistic | YES | (r *Client) GetGroupChatStat | MARKWANG |
|
||||
| 获取「群聊数据统计」数据 (按自然日聚合的方式) | POST | /cgi-bin/externalcontact/groupchat/statistic_group_by_day | YES | (r *Client) GetGroupChatStatByDay | MARKWANG |
|
||||
| 配置客户联系「联系我」方式 | POST | /cgi-bin/externalcontact/add_contact_way | YES | (r *Client) AddContactWay | MARKWANG |
|
||||
| 获取企业已配置的「联系我」方式 | POST | /cgi-bin/externalcontact/get_contact_way | YES | (r *Client) GetContactWay | MARKWANG |
|
||||
| 更新企业已配置的「联系我」方式 | POST | /cgi-bin/externalcontact/update_contact_way | YES | (r *Client) UpdateContactWay | MARKWANG |
|
||||
| 获取企业已配置的「联系我」列表 | POST | /cgi-bin/externalcontact/list_contact_way | YES | (r *Client) ListContactWay | MARKWANG |
|
||||
| 删除企业已配置的「联系我」方式 | POST | /cgi-bin/externalcontact/del_contact_way | YES | (r *Client) DelContactWay | MARKWANG |
|
||||
| 创建企业群发 | POST | /cgi-bin/externalcontact/add_msg_template | YES | (r *Client) AddMsgTemplate | MARKWANG |
|
||||
| 获取群发记录列表 | POST | /cgi-bin/externalcontact/get_groupmsg_list_v2 | YES | (r *Client) GetGroupMsgListV2 | MARKWANG |
|
||||
| 获取群发成员发送任务列表 | POST | /cgi-bin/externalcontact/get_groupmsg_task | YES | (r *Client) GetGroupMsgTask | MARKWANG |
|
||||
| 获取企业群发成员执行结果 | POST | /cgi-bin/externalcontact/get_groupmsg_send_result | YES | (r *Client) GetGroupMsgSendResult | MARKWANG |
|
||||
| 发送新客户欢迎语 | POST | /cgi-bin/externalcontact/send_welcome_msg | YES | (r *Client) SendWelcomeMsg | MARKWANG |
|
||||
| 名称 | 请求方式 | URL | 是否已实现 | 使用方法 | 贡献者 |
|
||||
|:------------------------:| -------- |:-------------------------------------------------------------| ---------- | ------------------------------- |----------|
|
||||
| 获取「联系客户统计」数据 | POST | /cgi-bin/externalcontact/get_user_behavior_data | YES | (r *Client) GetUserBehaviorData | MARKWANG |
|
||||
| 获取「群聊数据统计」数据 (按群主聚合的方式) | POST | /cgi-bin/externalcontact/groupchat/statistic | YES | (r *Client) GetGroupChatStat | MARKWANG |
|
||||
| 获取「群聊数据统计」数据 (按自然日聚合的方式) | POST | /cgi-bin/externalcontact/groupchat/statistic_group_by_day | YES | (r *Client) GetGroupChatStatByDay | MARKWANG |
|
||||
| 配置客户联系「联系我」方式 | POST | /cgi-bin/externalcontact/add_contact_way | YES | (r *Client) AddContactWay | MARKWANG |
|
||||
| 获取企业已配置的「联系我」方式 | POST | /cgi-bin/externalcontact/get_contact_way | YES | (r *Client) GetContactWay | MARKWANG |
|
||||
| 更新企业已配置的「联系我」方式 | POST | /cgi-bin/externalcontact/update_contact_way | YES | (r *Client) UpdateContactWay | MARKWANG |
|
||||
| 获取企业已配置的「联系我」列表 | POST | /cgi-bin/externalcontact/list_contact_way | YES | (r *Client) ListContactWay | MARKWANG |
|
||||
| 删除企业已配置的「联系我」方式 | POST | /cgi-bin/externalcontact/del_contact_way | YES | (r *Client) DelContactWay | MARKWANG |
|
||||
| 创建企业群发 | POST | /cgi-bin/externalcontact/add_msg_template | YES | (r *Client) AddMsgTemplate | MARKWANG |
|
||||
| 获取群发记录列表 | POST | /cgi-bin/externalcontact/get_groupmsg_list_v2 | YES | (r *Client) GetGroupMsgListV2 | MARKWANG |
|
||||
| 获取群发成员发送任务列表 | POST | /cgi-bin/externalcontact/get_groupmsg_task | YES | (r *Client) GetGroupMsgTask | MARKWANG |
|
||||
| 获取企业群发成员执行结果 | POST | /cgi-bin/externalcontact/get_groupmsg_send_result | YES | (r *Client) GetGroupMsgSendResult | MARKWANG |
|
||||
| 发送新客户欢迎语 | POST | /cgi-bin/externalcontact/send_welcome_msg | YES | (r *Client) SendWelcomeMsg | MARKWANG |
|
||||
| 添加入群欢迎语素材 | POST | /cgi-bin/externalcontact/group_welcome_template/add | YES | (r *Client) AddGroupWelcomeTemplate | MARKWANG |
|
||||
| 编辑入群欢迎语素材 | POST | /cgi-bin/externalcontact/group_welcome_template/edit | YES | (r *Client) EditGroupWelcomeTemplate | MARKWANG |
|
||||
| 获取入群欢迎语素材 | POST | /cgi-bin/externalcontact/group_welcome_template/get | YES | (r *Client) GetGroupWelcomeTemplate | MARKWANG |
|
||||
| 删除入群欢迎语素材 | POST | /cgi-bin/externalcontact/group_welcome_template/del | YES | (r *Client) DelGroupWelcomeTemplate | MARKWANG |
|
||||
|
||||
## 通讯录管理
|
||||
[官方文档](https://developer.work.weixin.qq.com/document/path/90193)
|
||||
@@ -87,6 +91,7 @@ host: https://qyapi.weixin.qq.com/
|
||||
|:---------:|------|:----------------------------------------| ---------- | ------------------------------- |----------|
|
||||
| 获取子部门ID列表 | GET | /cgi-bin/department/simplelist | YES | (r *Client) DepartmentSimpleList| MARKWANG |
|
||||
| 获取部门成员 | GET | /cgi-bin/user/simplelist | YES | (r *Client) UserSimpleList | MARKWANG |
|
||||
| 获取成员ID列表 | Post | /cgi-bin/user/list_id | YES | (r *Client) UserListId | MARKWANG |
|
||||
|
||||
|
||||
## 素材管理
|
||||
|
||||
@@ -11,6 +11,8 @@ const (
|
||||
UserSimpleListURL = "https://qyapi.weixin.qq.com/cgi-bin/user/simplelist?access_token=%s&department_id=%d"
|
||||
// UserGetURL 读取成员
|
||||
UserGetURL = "https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=%s&userid=%s"
|
||||
// UserListIDURL 获取成员ID列表
|
||||
UserListIDURL = "https://qyapi.weixin.qq.com/cgi-bin/user/list_id?access_token=%s"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -133,3 +135,43 @@ func (r *Client) UserGet(UserID string) (*UserGetResponse, error) {
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UserListIDRequest 获取成员ID列表请求
|
||||
type UserListIDRequest struct {
|
||||
Cursor string `json:"cursor"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
// UserListIDResponse 获取成员ID列表响应
|
||||
type UserListIDResponse struct {
|
||||
util.CommonError
|
||||
NextCursor string `json:"next_cursor"`
|
||||
DeptUser []*DeptUser `json:"dept_user"`
|
||||
}
|
||||
|
||||
// DeptUser 用户-部门关系
|
||||
type DeptUser struct {
|
||||
UserID string `json:"userid"`
|
||||
Department int `json:"department"`
|
||||
}
|
||||
|
||||
// UserListID 获取成员ID列表
|
||||
// see https://developer.work.weixin.qq.com/document/path/96067
|
||||
func (r *Client) UserListID(req *UserListIDRequest) (*UserListIDResponse, 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(UserListIDURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &UserListIDResponse{}
|
||||
if err = util.DecodeWithError(response, result, "UserListID"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -17,6 +17,14 @@ const (
|
||||
GetGroupMsgSendResultURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_groupmsg_send_result?access_token=%s"
|
||||
// SendWelcomeMsgURL 发送新客户欢迎语
|
||||
SendWelcomeMsgURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/send_welcome_msg?access_token=%s"
|
||||
// AddGroupWelcomeTemplateURL 添加入群欢迎语素材
|
||||
AddGroupWelcomeTemplateURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/group_welcome_template/add?access_token=%s"
|
||||
// EditGroupWelcomeTemplateURL 编辑入群欢迎语素材
|
||||
EditGroupWelcomeTemplateURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/group_welcome_template/edit?access_token=%s"
|
||||
// GetGroupWelcomeTemplateURL 获取入群欢迎语素材
|
||||
GetGroupWelcomeTemplateURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/group_welcome_template/get?access_token=%s"
|
||||
// DelGroupWelcomeTemplateURL 删除入群欢迎语素材
|
||||
DelGroupWelcomeTemplateURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/group_welcome_template/del?access_token=%s"
|
||||
)
|
||||
|
||||
// AddMsgTemplateRequest 创建企业群发请求
|
||||
@@ -268,3 +276,149 @@ func (r *Client) SendWelcomeMsg(req *SendWelcomeMsgRequest) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddGroupWelcomeTemplateRequest 添加入群欢迎语素材请求
|
||||
type AddGroupWelcomeTemplateRequest struct {
|
||||
Text MsgText `json:"text"`
|
||||
Image AttachmentImg `json:"image"`
|
||||
Link AttachmentLink `json:"link"`
|
||||
MiniProgram AttachmentMiniProgram `json:"miniprogram"`
|
||||
File AttachmentFile `json:"file"`
|
||||
Video AttachmentVideo `json:"video"`
|
||||
AgentID int `json:"agentid"`
|
||||
Notify int `json:"notify"`
|
||||
}
|
||||
|
||||
// AddGroupWelcomeTemplateResponse 添加入群欢迎语素材响应
|
||||
type AddGroupWelcomeTemplateResponse struct {
|
||||
util.CommonError
|
||||
TemplateID string `json:"template_id"`
|
||||
}
|
||||
|
||||
// AddGroupWelcomeTemplate 添加入群欢迎语素材
|
||||
// see https://developer.work.weixin.qq.com/document/path/92366#%E6%B7%BB%E5%8A%A0%E5%85%A5%E7%BE%A4%E6%AC%A2%E8%BF%8E%E8%AF%AD%E7%B4%A0%E6%9D%90
|
||||
func (r *Client) AddGroupWelcomeTemplate(req *AddGroupWelcomeTemplateRequest) (*AddGroupWelcomeTemplateResponse, 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(AddGroupWelcomeTemplateURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &AddGroupWelcomeTemplateResponse{}
|
||||
if err = util.DecodeWithError(response, result, "AddGroupWelcomeTemplate"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// EditGroupWelcomeTemplateRequest 编辑入群欢迎语素材请求
|
||||
type EditGroupWelcomeTemplateRequest struct {
|
||||
TemplateID string `json:"template_id"`
|
||||
Text MsgText `json:"text"`
|
||||
Image AttachmentImg `json:"image"`
|
||||
Link AttachmentLink `json:"link"`
|
||||
MiniProgram AttachmentMiniProgram `json:"miniprogram"`
|
||||
File AttachmentFile `json:"file"`
|
||||
Video AttachmentVideo `json:"video"`
|
||||
AgentID int `json:"agentid"`
|
||||
}
|
||||
|
||||
// EditGroupWelcomeTemplateResponse 编辑入群欢迎语素材响应
|
||||
type EditGroupWelcomeTemplateResponse struct {
|
||||
util.CommonError
|
||||
}
|
||||
|
||||
// EditGroupWelcomeTemplate 编辑入群欢迎语素材
|
||||
// see https://developer.work.weixin.qq.com/document/path/92366#%E7%BC%96%E8%BE%91%E5%85%A5%E7%BE%A4%E6%AC%A2%E8%BF%8E%E8%AF%AD%E7%B4%A0%E6%9D%90
|
||||
func (r *Client) EditGroupWelcomeTemplate(req *EditGroupWelcomeTemplateRequest) error {
|
||||
var (
|
||||
accessToken string
|
||||
err error
|
||||
)
|
||||
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||
return err
|
||||
}
|
||||
var response []byte
|
||||
if response, err = util.PostJSON(fmt.Sprintf(EditGroupWelcomeTemplateURL, accessToken), req); err != nil {
|
||||
return err
|
||||
}
|
||||
result := &EditGroupWelcomeTemplateResponse{}
|
||||
if err = util.DecodeWithError(response, result, "EditGroupWelcomeTemplate"); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetGroupWelcomeTemplateRequest 获取入群欢迎语素材请求
|
||||
type GetGroupWelcomeTemplateRequest struct {
|
||||
TemplateID string `json:"template_id"`
|
||||
}
|
||||
|
||||
// GetGroupWelcomeTemplateResponse 获取入群欢迎语素材响应
|
||||
type GetGroupWelcomeTemplateResponse struct {
|
||||
util.CommonError
|
||||
Text MsgText `json:"text"`
|
||||
Image AttachmentImg `json:"image"`
|
||||
Link AttachmentLink `json:"link"`
|
||||
MiniProgram AttachmentMiniProgram `json:"miniprogram"`
|
||||
File AttachmentFile `json:"file"`
|
||||
Video AttachmentVideo `json:"video"`
|
||||
}
|
||||
|
||||
// GetGroupWelcomeTemplate 获取入群欢迎语素材
|
||||
// see https://developer.work.weixin.qq.com/document/path/92366#%E8%8E%B7%E5%8F%96%E5%85%A5%E7%BE%A4%E6%AC%A2%E8%BF%8E%E8%AF%AD%E7%B4%A0%E6%9D%90
|
||||
func (r *Client) GetGroupWelcomeTemplate(req *GetGroupWelcomeTemplateRequest) (*GetGroupWelcomeTemplateResponse, 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(GetGroupWelcomeTemplateURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetGroupWelcomeTemplateResponse{}
|
||||
if err = util.DecodeWithError(response, result, "GetGroupWelcomeTemplate"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// DelGroupWelcomeTemplateRequest 删除入群欢迎语素材请求
|
||||
type DelGroupWelcomeTemplateRequest struct {
|
||||
TemplateID string `json:"template_id"`
|
||||
AgentID int `json:"agentid"`
|
||||
}
|
||||
|
||||
// DelGroupWelcomeTemplateResponse 删除入群欢迎语素材响应
|
||||
type DelGroupWelcomeTemplateResponse struct {
|
||||
util.CommonError
|
||||
}
|
||||
|
||||
// DelGroupWelcomeTemplate 删除入群欢迎语素材
|
||||
// see https://developer.work.weixin.qq.com/document/path/92366#%E5%88%A0%E9%99%A4%E5%85%A5%E7%BE%A4%E6%AC%A2%E8%BF%8E%E8%AF%AD%E7%B4%A0%E6%9D%90
|
||||
func (r *Client) DelGroupWelcomeTemplate(req *DelGroupWelcomeTemplateRequest) error {
|
||||
var (
|
||||
accessToken string
|
||||
err error
|
||||
)
|
||||
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||
return err
|
||||
}
|
||||
var response []byte
|
||||
if response, err = util.PostJSON(fmt.Sprintf(DelGroupWelcomeTemplateURL, accessToken), req); err != nil {
|
||||
return err
|
||||
}
|
||||
result := &DelGroupWelcomeTemplateResponse{}
|
||||
if err = util.DecodeWithError(response, result, "DelGroupWelcomeTemplate"); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user