mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-04 12:52:27 +08:00
企业微信-[联系我]方式新增和获取 (#603)
This commit is contained in:
@@ -60,13 +60,25 @@ host: https://qyapi.weixin.qq.com/
|
||||
| 获取视频号绑定状态 | GET | /cgi-bin/kf/get_corp_qualification | YES | (r *Client) GetCorpQualification | NICEXAI |
|
||||
|
||||
### 客户联系
|
||||
[官方文档](https://developer.work.weixin.qq.com/document/path/92132/92133)
|
||||
[官方文档](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 |
|
||||
|
||||
|
||||
## 通讯录管理
|
||||
[官方文档](https://developer.work.weixin.qq.com/document/path/95350/90200)
|
||||
|
||||
| 名称 | 请求方式 | URL | 是否已实现 | 使用方法 | 贡献者 |
|
||||
|:---------:|------|:----------------------------------------| ---------- | ------------------------------- |----------|
|
||||
| 获取子部门ID列表 | GET | /cgi-bin/department/simplelist | YES | (r *Client) DepartmentSimpleList| MARKWANG |
|
||||
| 获取部门成员 | GET | /cgi-bin/user/simplelist | YES | (r *Client) UserSimpleList | MARKWANG |
|
||||
=======
|
||||
|
||||
|
||||
## 通讯录管理
|
||||
|
||||
154
work/externalcontact/contact_way.go
Normal file
154
work/externalcontact/contact_way.go
Normal file
@@ -0,0 +1,154 @@
|
||||
package externalcontact
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/silenceper/wechat/v2/util"
|
||||
)
|
||||
|
||||
const (
|
||||
// AddContactWayURL 配置客户联系「联系我」方式
|
||||
AddContactWayURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_contact_way?access_token=%s"
|
||||
// GetContactWayURL 获取企业已配置的「联系我」方式
|
||||
GetContactWayURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_contact_way?access_token=%s"
|
||||
)
|
||||
|
||||
type (
|
||||
// ConclusionsRequest 结束语请求
|
||||
ConclusionsRequest struct {
|
||||
Text ConclusionsText `json:"text"`
|
||||
Image ConclusionsImageRequest `json:"image"`
|
||||
Link ConclusionsLink `json:"link"`
|
||||
MiniProgram ConclusionsMiniProgram `json:"miniprogram"`
|
||||
}
|
||||
// ConclusionsText 文本格式结束语
|
||||
ConclusionsText struct {
|
||||
Content string `json:"content"`
|
||||
}
|
||||
// ConclusionsImageRequest 图片格式结束语请求
|
||||
ConclusionsImageRequest struct {
|
||||
MediaID string `json:"media_id"`
|
||||
}
|
||||
// ConclusionsLink 链接格式结束语
|
||||
ConclusionsLink struct {
|
||||
Title string `json:"title"`
|
||||
PicURL string `json:"picurl"`
|
||||
Desc string `json:"desc"`
|
||||
URL string `json:"url"`
|
||||
}
|
||||
// ConclusionsMiniProgram 小程序格式结束语
|
||||
ConclusionsMiniProgram struct {
|
||||
Title string `json:"title"`
|
||||
PicMediaID string `json:"pic_media_id"`
|
||||
AppID string `json:"appid"`
|
||||
Page string `json:"page"`
|
||||
}
|
||||
// ConclusionsResponse 结束语响应
|
||||
ConclusionsResponse struct {
|
||||
Text ConclusionsText `json:"text"`
|
||||
Image ConclusionsImageResponse `json:"image"`
|
||||
Link ConclusionsLink `json:"link"`
|
||||
MiniProgram ConclusionsMiniProgram `json:"miniprogram"`
|
||||
}
|
||||
// ConclusionsImageResponse 图片格式结束语响应
|
||||
ConclusionsImageResponse struct {
|
||||
PicURL string `json:"pic_url"`
|
||||
}
|
||||
)
|
||||
|
||||
type (
|
||||
// AddContactWayRequest 配置客户联系「联系我」方式请求
|
||||
AddContactWayRequest struct {
|
||||
Type int `json:"type"`
|
||||
Scene int `json:"scene"`
|
||||
Style int `json:"style"`
|
||||
Remark string `json:"remark"`
|
||||
SkipVerify bool `json:"skip_verify"`
|
||||
State string `json:"state"`
|
||||
User []string `json:"user"`
|
||||
Party []int `json:"party"`
|
||||
IsTemp bool `json:"is_temp"`
|
||||
ExpiresIn int `json:"expires_in"`
|
||||
ChatExpiresIn int `json:"chat_expires_in"`
|
||||
UnionID string `json:"unionid"`
|
||||
Conclusions ConclusionsRequest `json:"conclusions"`
|
||||
}
|
||||
// AddContactWayResponse 配置客户联系「联系我」方式响应
|
||||
AddContactWayResponse struct {
|
||||
util.CommonError
|
||||
ConfigID string `json:"config_id"`
|
||||
QrCode string `json:"qr_code"`
|
||||
}
|
||||
)
|
||||
|
||||
// AddContactWay 配置客户联系「联系我」方式
|
||||
// see https://developer.work.weixin.qq.com/document/path/92228
|
||||
func (r *Client) AddContactWay(req *AddContactWayRequest) (*AddContactWayResponse, 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(AddContactWayURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &AddContactWayResponse{}
|
||||
if err = util.DecodeWithError(response, result, "AddContactWay"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type (
|
||||
// GetContactWayRequest 获取企业已配置的「联系我」方式请求
|
||||
GetContactWayRequest struct {
|
||||
ConfigID string `json:"config_id"`
|
||||
}
|
||||
// GetContactWayResponse 获取企业已配置的「联系我」方式响应
|
||||
GetContactWayResponse struct {
|
||||
util.CommonError
|
||||
ContactWay ContactWay `json:"contact_way"`
|
||||
}
|
||||
// ContactWay 「联系我」配置
|
||||
ContactWay struct {
|
||||
ConfigID string `json:"config_id"`
|
||||
Type int `json:"type"`
|
||||
Scene int `json:"scene"`
|
||||
Style int `json:"style"`
|
||||
Remark string `json:"remark"`
|
||||
SkipVerify bool `json:"skip_verify"`
|
||||
State string `json:"state"`
|
||||
QrCode string `json:"qr_code"`
|
||||
User []string `json:"user"`
|
||||
Party []int `json:"party"`
|
||||
IsTemp bool `json:"is_temp"`
|
||||
ExpiresIn int `json:"expires_in"`
|
||||
ChatExpiresIn int `json:"chat_expires_in"`
|
||||
UnionID string `json:"unionid"`
|
||||
Conclusions ConclusionsResponse `json:"conclusions"`
|
||||
}
|
||||
)
|
||||
|
||||
// GetContactWay 获取企业已配置的「联系我」方式
|
||||
// see https://developer.work.weixin.qq.com/document/path/92228
|
||||
func (r *Client) GetContactWay(req *GetContactWayRequest) (*GetContactWayResponse, 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(GetContactWayURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetContactWayResponse{}
|
||||
if err = util.DecodeWithError(response, result, "GetContactWay"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user