mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-09 23:22:27 +08:00
Merge remote-tracking branch '官方/v2' into release-2.0
# Conflicts: # work/message/client.go # work/message/message.go # work/oauth/oauth.go # work/work.go
This commit is contained in:
@@ -38,8 +38,6 @@ func (r *Client) GetCallbackMessage(encryptedMsg []byte) (msg EventCallbackMessa
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if err = xml.Unmarshal(bData, &msg); err != nil {
|
||||
return
|
||||
}
|
||||
err = xml.Unmarshal(bData, &msg)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -7,16 +7,16 @@ import (
|
||||
)
|
||||
|
||||
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"
|
||||
// UpdateContactWayURL 更新企业已配置的「联系我」方式
|
||||
UpdateContactWayURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/update_contact_way?access_token=%s"
|
||||
// ListContactWayURL 获取企业已配置的「联系我」列表
|
||||
ListContactWayURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list_contact_way?access_token=%s"
|
||||
// DelContactWayURL 删除企业已配置的「联系我」方式
|
||||
DelContactWayURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/del_contact_way?access_token=%s"
|
||||
// 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"
|
||||
// updateContactWayURL 更新企业已配置的「联系我」方式
|
||||
updateContactWayURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/update_contact_way?access_token=%s"
|
||||
// listContactWayURL 获取企业已配置的「联系我」列表
|
||||
listContactWayURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list_contact_way?access_token=%s"
|
||||
// delContactWayURL 删除企业已配置的「联系我」方式
|
||||
delContactWayURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/del_contact_way?access_token=%s"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -98,14 +98,12 @@ func (r *Client) AddContactWay(req *AddContactWayRequest) (*AddContactWayRespons
|
||||
return nil, err
|
||||
}
|
||||
var response []byte
|
||||
if response, err = util.PostJSON(fmt.Sprintf(AddContactWayURL, accessToken), req); err != nil {
|
||||
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
|
||||
err = util.DecodeWithError(response, result, "AddContactWay")
|
||||
return result, err
|
||||
}
|
||||
|
||||
type (
|
||||
@@ -149,14 +147,12 @@ func (r *Client) GetContactWay(req *GetContactWayRequest) (*GetContactWayRespons
|
||||
return nil, err
|
||||
}
|
||||
var response []byte
|
||||
if response, err = util.PostJSON(fmt.Sprintf(GetContactWayURL, accessToken), req); err != nil {
|
||||
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
|
||||
err = util.DecodeWithError(response, result, "GetContactWay")
|
||||
return result, err
|
||||
}
|
||||
|
||||
type (
|
||||
@@ -191,14 +187,12 @@ func (r *Client) UpdateContactWay(req *UpdateContactWayRequest) (*UpdateContactW
|
||||
return nil, err
|
||||
}
|
||||
var response []byte
|
||||
if response, err = util.PostJSON(fmt.Sprintf(UpdateContactWayURL, accessToken), req); err != nil {
|
||||
if response, err = util.PostJSON(fmt.Sprintf(updateContactWayURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &UpdateContactWayResponse{}
|
||||
if err = util.DecodeWithError(response, result, "UpdateContactWay"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
err = util.DecodeWithError(response, result, "UpdateContactWay")
|
||||
return result, err
|
||||
}
|
||||
|
||||
type (
|
||||
@@ -232,14 +226,12 @@ func (r *Client) ListContactWay(req *ListContactWayRequest) (*ListContactWayResp
|
||||
return nil, err
|
||||
}
|
||||
var response []byte
|
||||
if response, err = util.PostJSON(fmt.Sprintf(ListContactWayURL, accessToken), req); err != nil {
|
||||
if response, err = util.PostJSON(fmt.Sprintf(listContactWayURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &ListContactWayResponse{}
|
||||
if err = util.DecodeWithError(response, result, "ListContactWay"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
err = util.DecodeWithError(response, result, "ListContactWay")
|
||||
return result, err
|
||||
}
|
||||
|
||||
type (
|
||||
@@ -264,12 +256,10 @@ func (r *Client) DelContactWay(req *DelContactWayRequest) (*DelContactWayRespons
|
||||
return nil, err
|
||||
}
|
||||
var response []byte
|
||||
if response, err = util.PostJSON(fmt.Sprintf(DelContactWayURL, accessToken), req); err != nil {
|
||||
if response, err = util.PostJSON(fmt.Sprintf(delContactWayURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &DelContactWayResponse{}
|
||||
if err = util.DecodeWithError(response, result, "DelContactWay"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
err = util.DecodeWithError(response, result, "DelContactWay")
|
||||
return result, err
|
||||
}
|
||||
|
||||
310
work/externalcontact/customer_acquisition.go
Normal file
310
work/externalcontact/customer_acquisition.go
Normal file
@@ -0,0 +1,310 @@
|
||||
package externalcontact
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/silenceper/wechat/v2/util"
|
||||
)
|
||||
|
||||
const (
|
||||
// listLinkUrl 获取获客链接列表
|
||||
listLinkURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition/list_link?access_token=%s"
|
||||
// getCustomerAcquisition 获取获客链接详情
|
||||
getCustomerAcquisitionURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition/get?access_token=%s"
|
||||
// createCustomerAcquisitionLink 创建获客链接
|
||||
createCustomerAcquisitionLinkURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition/create_link?access_token=%s"
|
||||
// updateCustomerAcquisitionLink 编辑获客链接
|
||||
updateCustomerAcquisitionLinkURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition/update_link?access_token=%s"
|
||||
// deleteCustomerAcquisitionLink 删除获客链接
|
||||
deleteCustomerAcquisitionLinkURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition/delete_link?access_token=%s"
|
||||
// getCustomerInfoWithCustomerAcquisitionLinkURL 获取由获客链接添加的客户信息
|
||||
getCustomerInfoWithCustomerAcquisitionLinkURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition/customer?access_token=%s"
|
||||
// customerAcquisitionQuota 查询剩余使用量
|
||||
customerAcquisitionQuotaURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition_quota?access_token=%s"
|
||||
// customerAcquisitionStatistic 查询链接使用详情
|
||||
customerAcquisitionStatisticURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition/statistic?access_token=%s"
|
||||
)
|
||||
|
||||
type (
|
||||
// ListLinkRequest 获取获客链接列表请求
|
||||
ListLinkRequest struct {
|
||||
Limit int `json:"limit"`
|
||||
Cursor string `json:"cursor"`
|
||||
}
|
||||
// ListLinkResponse 获取获客链接列表响应
|
||||
ListLinkResponse struct {
|
||||
util.CommonError
|
||||
LinkIDList []string `json:"link_id_list"`
|
||||
NextCursor string `json:"next_cursor"`
|
||||
}
|
||||
)
|
||||
|
||||
// ListLink 获客助手--获取获客链接列表
|
||||
// see https://developer.work.weixin.qq.com/document/path/97297
|
||||
func (r *Client) ListLink(req *ListLinkRequest) (*ListLinkResponse, 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(listLinkURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &ListLinkResponse{}
|
||||
err = util.DecodeWithError(response, result, "ListLink")
|
||||
return result, err
|
||||
}
|
||||
|
||||
type (
|
||||
// GetCustomerAcquisitionRequest 获取获客链接详情请求
|
||||
GetCustomerAcquisitionRequest struct {
|
||||
LinkID string `json:"link_id"`
|
||||
}
|
||||
// GetCustomerAcquisitionResponse 获取获客链接详情响应
|
||||
GetCustomerAcquisitionResponse struct {
|
||||
util.CommonError
|
||||
Link Link `json:"link"`
|
||||
Range CustomerAcquisitionRange `json:"range"`
|
||||
SkipVerify bool `json:"skip_verify"`
|
||||
}
|
||||
// Link 获客链接
|
||||
Link struct {
|
||||
LinkID string `json:"link_id"`
|
||||
LinkName string `json:"link_name"`
|
||||
URL string `json:"url"`
|
||||
CreateTime int64 `json:"create_time"`
|
||||
}
|
||||
|
||||
// CustomerAcquisitionRange 该获客链接使用范围
|
||||
CustomerAcquisitionRange struct {
|
||||
UserList []string `json:"user_list"`
|
||||
DepartmentList []int64 `json:"department_list"`
|
||||
}
|
||||
)
|
||||
|
||||
// GetCustomerAcquisition 获客助手--获取获客链接详情
|
||||
// see https://developer.work.weixin.qq.com/document/path/97297
|
||||
func (r *Client) GetCustomerAcquisition(req *GetCustomerAcquisitionRequest) (*GetCustomerAcquisitionResponse, 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(getCustomerAcquisitionURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetCustomerAcquisitionResponse{}
|
||||
err = util.DecodeWithError(response, result, "GetCustomerAcquisition")
|
||||
return result, err
|
||||
}
|
||||
|
||||
type (
|
||||
// CreateCustomerAcquisitionLinkRequest 创建获客链接请求
|
||||
CreateCustomerAcquisitionLinkRequest struct {
|
||||
LinkName string `json:"link_name"`
|
||||
Range CustomerAcquisitionRange `json:"range"`
|
||||
SkipVerify bool `json:"skip_verify"`
|
||||
}
|
||||
// CreateCustomerAcquisitionLinkResponse 创建获客链接响应
|
||||
CreateCustomerAcquisitionLinkResponse struct {
|
||||
util.CommonError
|
||||
Link Link `json:"link"`
|
||||
}
|
||||
)
|
||||
|
||||
// CreateCustomerAcquisitionLink 获客助手--创建获客链接
|
||||
// see https://developer.work.weixin.qq.com/document/path/97297
|
||||
func (r *Client) CreateCustomerAcquisitionLink(req *CreateCustomerAcquisitionLinkRequest) (*CreateCustomerAcquisitionLinkResponse, 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(createCustomerAcquisitionLinkURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &CreateCustomerAcquisitionLinkResponse{}
|
||||
err = util.DecodeWithError(response, result, "CreateCustomerAcquisitionLink")
|
||||
return result, err
|
||||
}
|
||||
|
||||
type (
|
||||
// UpdateCustomerAcquisitionLinkRequest 编辑获客链接请求
|
||||
UpdateCustomerAcquisitionLinkRequest struct {
|
||||
LinkID string `json:"link_id"`
|
||||
LinkName string `json:"link_name"`
|
||||
Range CustomerAcquisitionRange `json:"range"`
|
||||
SkipVerify bool `json:"skip_verify"`
|
||||
}
|
||||
// UpdateCustomerAcquisitionLinkResponse 编辑获客链接响应
|
||||
UpdateCustomerAcquisitionLinkResponse struct {
|
||||
util.CommonError
|
||||
}
|
||||
)
|
||||
|
||||
// UpdateCustomerAcquisitionLink 获客助手--编辑获客链接
|
||||
// see https://developer.work.weixin.qq.com/document/path/97297
|
||||
func (r *Client) UpdateCustomerAcquisitionLink(req *UpdateCustomerAcquisitionLinkRequest) (*UpdateCustomerAcquisitionLinkResponse, 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(updateCustomerAcquisitionLinkURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &UpdateCustomerAcquisitionLinkResponse{}
|
||||
err = util.DecodeWithError(response, result, "UpdateCustomerAcquisitionLink")
|
||||
return result, err
|
||||
}
|
||||
|
||||
type (
|
||||
// DeleteCustomerAcquisitionLinkRequest 删除获客链接请求
|
||||
DeleteCustomerAcquisitionLinkRequest struct {
|
||||
LinkID string `json:"link_id"`
|
||||
}
|
||||
// DeleteCustomerAcquisitionLinkResponse 删除获客链接响应
|
||||
DeleteCustomerAcquisitionLinkResponse struct {
|
||||
util.CommonError
|
||||
}
|
||||
)
|
||||
|
||||
// DeleteCustomerAcquisitionLink 获客助手--删除获客链接
|
||||
// see https://developer.work.weixin.qq.com/document/path/97297
|
||||
func (r *Client) DeleteCustomerAcquisitionLink(req *DeleteCustomerAcquisitionLinkRequest) (*DeleteCustomerAcquisitionLinkResponse, 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(deleteCustomerAcquisitionLinkURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &DeleteCustomerAcquisitionLinkResponse{}
|
||||
err = util.DecodeWithError(response, result, "DeleteCustomerAcquisitionLink")
|
||||
return result, err
|
||||
}
|
||||
|
||||
type (
|
||||
// GetCustomerInfoWithCustomerAcquisitionLinkRequest 获取由获客链接添加的客户信息请求
|
||||
GetCustomerInfoWithCustomerAcquisitionLinkRequest struct {
|
||||
LinkID string `json:"link_id"`
|
||||
Limit int64 `json:"limit"`
|
||||
Cursor string `json:"cursor"`
|
||||
}
|
||||
// GetCustomerInfoWithCustomerAcquisitionLinkResponse 获取由获客链接添加的客户信息响应
|
||||
GetCustomerInfoWithCustomerAcquisitionLinkResponse struct {
|
||||
util.CommonError
|
||||
CustomerList []CustomerList `json:"customer_list"`
|
||||
NextCursor string `json:"next_cursor"`
|
||||
}
|
||||
// CustomerList 客户列表
|
||||
CustomerList struct {
|
||||
ExternalUserid string `json:"external_userid"`
|
||||
Userid string `json:"userid"`
|
||||
ChatStatus int64 `json:"chat_status"`
|
||||
State string `json:"state"`
|
||||
}
|
||||
)
|
||||
|
||||
// GetCustomerInfoWithCustomerAcquisitionLink 获客助手--获取由获客链接添加的客户信息
|
||||
// see https://developer.work.weixin.qq.com/document/path/97298
|
||||
func (r *Client) GetCustomerInfoWithCustomerAcquisitionLink(req *GetCustomerInfoWithCustomerAcquisitionLinkRequest) (*GetCustomerInfoWithCustomerAcquisitionLinkResponse, 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(getCustomerInfoWithCustomerAcquisitionLinkURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetCustomerInfoWithCustomerAcquisitionLinkResponse{}
|
||||
err = util.DecodeWithError(response, result, "GetCustomerInfoWithCustomerAcquisitionLink")
|
||||
return result, err
|
||||
}
|
||||
|
||||
type (
|
||||
// CustomerAcquisitionQuotaResponse 查询剩余使用量响应
|
||||
CustomerAcquisitionQuotaResponse struct {
|
||||
util.CommonError
|
||||
Total int64 `json:"total"`
|
||||
Balance int64 `json:"balance"`
|
||||
QuotaList []QuotaList `json:"quota_list"`
|
||||
}
|
||||
// QuotaList 额度
|
||||
QuotaList struct {
|
||||
ExpireDate int64 `json:"expire_date"`
|
||||
Balance int64 `json:"balance"`
|
||||
}
|
||||
)
|
||||
|
||||
// CustomerAcquisitionQuota 获客助手额度管理与使用统计--查询剩余使用量
|
||||
// see https://developer.work.weixin.qq.com/document/path/97375
|
||||
func (r *Client) CustomerAcquisitionQuota() (*CustomerAcquisitionQuotaResponse, 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(customerAcquisitionQuotaURL, accessToken)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &CustomerAcquisitionQuotaResponse{}
|
||||
err = util.DecodeWithError(response, result, "CustomerAcquisitionQuota")
|
||||
return result, err
|
||||
}
|
||||
|
||||
type (
|
||||
// CustomerAcquisitionStatisticRequest 查询链接使用详情请求
|
||||
CustomerAcquisitionStatisticRequest struct {
|
||||
LinkID string `json:"link_id"`
|
||||
StartTime int64 `json:"start_time"`
|
||||
EndTime int64 `json:"end_time"`
|
||||
}
|
||||
// CustomerAcquisitionStatisticResponse 查询链接使用详情响应
|
||||
CustomerAcquisitionStatisticResponse struct {
|
||||
util.CommonError
|
||||
ClickLinkCustomerCnt int64 `json:"click_link_customer_cnt"`
|
||||
NewCustomerCnt int64 `json:"new_customer_cnt"`
|
||||
}
|
||||
)
|
||||
|
||||
// CustomerAcquisitionStatistic 获客助手额度管理与使用统计--查询链接使用详情
|
||||
// see https://developer.work.weixin.qq.com/document/path/97375
|
||||
func (r *Client) CustomerAcquisitionStatistic(req *CustomerAcquisitionStatisticRequest) (*CustomerAcquisitionStatisticResponse, 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(customerAcquisitionStatisticURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &CustomerAcquisitionStatisticResponse{}
|
||||
err = util.DecodeWithError(response, result, "CustomerAcquisitionStatistic")
|
||||
return result, err
|
||||
}
|
||||
@@ -8,14 +8,26 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// FetchExternalContactUserListURL 获取客户列表
|
||||
FetchExternalContactUserListURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list"
|
||||
// FetchExternalContactUserDetailURL 获取客户详情
|
||||
FetchExternalContactUserDetailURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get"
|
||||
// FetchBatchExternalContactUserDetailURL 批量获取客户详情
|
||||
FetchBatchExternalContactUserDetailURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/batch/get_by_user"
|
||||
// UpdateUserRemarkURL 更新客户备注信息
|
||||
UpdateUserRemarkURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/remark"
|
||||
// fetchExternalContactUserListURL 获取客户列表
|
||||
fetchExternalContactUserListURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list"
|
||||
// fetchExternalContactUserDetailURL 获取客户详情
|
||||
fetchExternalContactUserDetailURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get"
|
||||
// fetchBatchExternalContactUserDetailURL 批量获取客户详情
|
||||
fetchBatchExternalContactUserDetailURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/batch/get_by_user"
|
||||
// updateUserRemarkURL 更新客户备注信息
|
||||
updateUserRemarkURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/remark"
|
||||
// listCustomerStrategyURL 获取规则组列表
|
||||
listCustomerStrategyURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_strategy/list?access_token=%s"
|
||||
// getCustomerStrategyURL 获取规则组详情
|
||||
getCustomerStrategyURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_strategy/get?access_token=%s"
|
||||
// getRangeCustomerStrategyURL 获取规则组管理范围
|
||||
getRangeCustomerStrategyURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_strategy/get_range?access_token=%s"
|
||||
// createCustomerStrategyURL 创建新的规则组
|
||||
createCustomerStrategyURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_strategy/create?access_token=%s"
|
||||
// editCustomerStrategyURL 编辑规则组及其管理范围
|
||||
editCustomerStrategyURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_strategy/edit?access_token=%s"
|
||||
// delCustomerStrategyURL 删除规则组
|
||||
delCustomerStrategyURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_strategy/del?access_token=%s"
|
||||
)
|
||||
|
||||
// ExternalUserListResponse 外部联系人列表响应
|
||||
@@ -32,16 +44,13 @@ func (r *Client) GetExternalUserList(userID string) ([]string, error) {
|
||||
return nil, err
|
||||
}
|
||||
var response []byte
|
||||
response, err = util.HTTPGet(fmt.Sprintf("%s?access_token=%v&userid=%v", FetchExternalContactUserListURL, accessToken, userID))
|
||||
response, err = util.HTTPGet(fmt.Sprintf("%s?access_token=%v&userid=%v", fetchExternalContactUserListURL, accessToken, userID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result ExternalUserListResponse
|
||||
err = util.DecodeWithError(response, &result, "GetExternalUserList")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.ExternalUserID, nil
|
||||
return result.ExternalUserID, err
|
||||
}
|
||||
|
||||
// ExternalUserDetailResponse 外部联系人详情响应
|
||||
@@ -54,16 +63,16 @@ type ExternalUserDetailResponse struct {
|
||||
|
||||
// ExternalUser 外部联系人
|
||||
type ExternalUser struct {
|
||||
ExternalUserID string `json:"external_userid"`
|
||||
Name string `json:"name"`
|
||||
Avatar string `json:"avatar"`
|
||||
Type int64 `json:"type"`
|
||||
Gender int64 `json:"gender"`
|
||||
UnionID string `json:"unionid"`
|
||||
Position string `json:"position"`
|
||||
CorpName string `json:"corp_name"`
|
||||
CorpFullName string `json:"corp_full_name"`
|
||||
ExternalProfile string `json:"external_profile"`
|
||||
ExternalUserID string `json:"external_userid"`
|
||||
Name string `json:"name"`
|
||||
Avatar string `json:"avatar"`
|
||||
Type int64 `json:"type"`
|
||||
Gender int64 `json:"gender"`
|
||||
UnionID string `json:"unionid"`
|
||||
Position string `json:"position"`
|
||||
CorpName string `json:"corp_name"`
|
||||
CorpFullName string `json:"corp_full_name"`
|
||||
ExternalProfile *ExternalProfile `json:"external_profile,omitempty"`
|
||||
}
|
||||
|
||||
// FollowUser 跟进用户(指企业内部用户)
|
||||
@@ -71,7 +80,7 @@ type FollowUser struct {
|
||||
UserID string `json:"userid"`
|
||||
Remark string `json:"remark"`
|
||||
Description string `json:"description"`
|
||||
CreateTime string `json:"create_time"`
|
||||
CreateTime int64 `json:"createtime"`
|
||||
Tags []Tag `json:"tags"`
|
||||
RemarkCorpName string `json:"remark_corp_name"`
|
||||
RemarkMobiles []string `json:"remark_mobiles"`
|
||||
@@ -92,7 +101,47 @@ type Tag struct {
|
||||
// WechatChannel 视频号添加的场景
|
||||
type WechatChannel struct {
|
||||
NickName string `json:"nickname"`
|
||||
Source string `json:"source"`
|
||||
Source int `json:"source"`
|
||||
}
|
||||
|
||||
// ExternalProfile 外部联系人的自定义展示信息,可以有多个字段和多种类型,包括文本,网页和小程序
|
||||
type ExternalProfile struct {
|
||||
ExternalCorpName string `json:"external_corp_name"`
|
||||
WechatChannels WechatChannels `json:"wechat_channels"`
|
||||
ExternalAttr []ExternalAttr `json:"external_attr"`
|
||||
}
|
||||
|
||||
// WechatChannels 视频号属性。须从企业绑定到企业微信的视频号中选择,可在“我的企业”页中查看绑定的视频号
|
||||
type WechatChannels struct {
|
||||
Nickname string `json:"nickname"`
|
||||
Status int `json:"status"`
|
||||
}
|
||||
|
||||
// ExternalAttr 属性列表,目前支持文本、网页、小程序三种类型
|
||||
type ExternalAttr struct {
|
||||
Type int `json:"type"`
|
||||
Name string `json:"name"`
|
||||
Text *Text `json:"text,omitempty"`
|
||||
Web *Web `json:"web,omitempty"`
|
||||
MiniProgram *MiniProgram `json:"miniprogram,omitempty"`
|
||||
}
|
||||
|
||||
// Text 文本
|
||||
type Text struct {
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
// Web 网页
|
||||
type Web struct {
|
||||
URL string `json:"url"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
// MiniProgram 小程序
|
||||
type MiniProgram struct {
|
||||
AppID string `json:"appid"`
|
||||
Pagepath string `json:"pagepath"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
// GetExternalUserDetail 获取外部联系人详情
|
||||
@@ -107,22 +156,20 @@ func (r *Client) GetExternalUserDetail(externalUserID string, nextCursor ...stri
|
||||
if len(nextCursor) > 0 {
|
||||
cursor = nextCursor[0]
|
||||
}
|
||||
response, err = util.HTTPGet(fmt.Sprintf("%s?access_token=%v&external_userid=%v&cursor=%v", FetchExternalContactUserDetailURL, accessToken, externalUserID, cursor))
|
||||
response, err = util.HTTPGet(fmt.Sprintf("%s?access_token=%v&external_userid=%v&cursor=%v", fetchExternalContactUserDetailURL, accessToken, externalUserID, cursor))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &ExternalUserDetailResponse{}
|
||||
err = util.DecodeWithError(response, result, "get_external_user_detail")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
return result, err
|
||||
}
|
||||
|
||||
// BatchGetExternalUserDetailsRequest 批量获取外部联系人详情请求
|
||||
type BatchGetExternalUserDetailsRequest struct {
|
||||
UserIDList []string `json:"userid_list"`
|
||||
Cursor string `json:"cursor"`
|
||||
Limit int `json:"limit,omitempty"`
|
||||
}
|
||||
|
||||
// ExternalUserDetailListResponse 批量获取外部联系人详情响应
|
||||
@@ -156,7 +203,7 @@ type FollowInfo struct {
|
||||
UserID string `json:"userid"`
|
||||
Remark string `json:"remark"`
|
||||
Description string `json:"description"`
|
||||
CreateTime int `json:"create_time"`
|
||||
CreateTime int64 `json:"createtime"`
|
||||
TagID []string `json:"tag_id"`
|
||||
RemarkCorpName string `json:"remark_corp_name"`
|
||||
RemarkMobiles []string `json:"remark_mobiles"`
|
||||
@@ -177,16 +224,13 @@ func (r *Client) BatchGetExternalUserDetails(request BatchGetExternalUserDetails
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", FetchBatchExternalContactUserDetailURL, accessToken), string(jsonData))
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", fetchBatchExternalContactUserDetailURL, accessToken), string(jsonData))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result ExternalUserDetailListResponse
|
||||
err = util.DecodeWithError(response, &result, "BatchGetExternalUserDetails")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.ExternalContactList, nil
|
||||
return result.ExternalContactList, err
|
||||
}
|
||||
|
||||
// UpdateUserRemarkRequest 修改客户备注信息请求体
|
||||
@@ -212,9 +256,234 @@ func (r *Client) UpdateUserRemark(request UpdateUserRemarkRequest) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", UpdateUserRemarkURL, accessToken), string(jsonData))
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", updateUserRemarkURL, accessToken), string(jsonData))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return util.DecodeWithCommonError(response, "UpdateUserRemark")
|
||||
}
|
||||
|
||||
// ListCustomerStrategyRequest 获取规则组列表请求
|
||||
type ListCustomerStrategyRequest struct {
|
||||
Cursor string `json:"cursor"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
// ListCustomerStrategyResponse 获取规则组列表响应
|
||||
type ListCustomerStrategyResponse struct {
|
||||
util.CommonError
|
||||
Strategy []StrategyID `json:"strategy"`
|
||||
NextCursor string `json:"next_cursor"`
|
||||
}
|
||||
|
||||
// StrategyID 规则组ID
|
||||
type StrategyID struct {
|
||||
StrategyID int `json:"strategy_id"`
|
||||
}
|
||||
|
||||
// ListCustomerStrategy 获取规则组列表
|
||||
// @see https://developer.work.weixin.qq.com/document/path/94883#%E8%8E%B7%E5%8F%96%E8%A7%84%E5%88%99%E7%BB%84%E5%88%97%E8%A1%A8
|
||||
func (r *Client) ListCustomerStrategy(req *ListCustomerStrategyRequest) (*ListCustomerStrategyResponse, 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(listCustomerStrategyURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &ListCustomerStrategyResponse{}
|
||||
err = util.DecodeWithError(response, result, "ListCustomerStrategy")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// GetCustomerStrategyRequest 获取规则组详情请求
|
||||
type GetCustomerStrategyRequest struct {
|
||||
StrategyID int `json:"strategy_id"`
|
||||
}
|
||||
|
||||
// GetCustomerStrategyResponse 获取规则组详情响应
|
||||
type GetCustomerStrategyResponse struct {
|
||||
util.CommonError
|
||||
Strategy Strategy `json:"strategy"`
|
||||
}
|
||||
|
||||
// Strategy 规则组
|
||||
type Strategy struct {
|
||||
StrategyID int `json:"strategy_id"`
|
||||
ParentID int `json:"parent_id"`
|
||||
StrategyName string `json:"strategy_name"`
|
||||
CreateTime int64 `json:"create_time"`
|
||||
AdminList []string `json:"admin_list"`
|
||||
Privilege Privilege `json:"privilege"`
|
||||
}
|
||||
|
||||
// Privilege 权限
|
||||
type Privilege struct {
|
||||
ViewCustomerList bool `json:"view_customer_list"`
|
||||
ViewCustomerData bool `json:"view_customer_data"`
|
||||
ViewRoomList bool `json:"view_room_list"`
|
||||
ContactMe bool `json:"contact_me"`
|
||||
JoinRoom bool `json:"join_room"`
|
||||
ShareCustomer bool `json:"share_customer"`
|
||||
OperResignCustomer bool `json:"oper_resign_customer"`
|
||||
OperResignGroup bool `json:"oper_resign_group"`
|
||||
SendCustomerMsg bool `json:"send_customer_msg"`
|
||||
EditWelcomeMsg bool `json:"edit_welcome_msg"`
|
||||
ViewBehaviorData bool `json:"view_behavior_data"`
|
||||
ViewRoomData bool `json:"view_room_data"`
|
||||
SendGroupMsg bool `json:"send_group_msg"`
|
||||
RoomDeduplication bool `json:"room_deduplication"`
|
||||
RapidReply bool `json:"rapid_reply"`
|
||||
OnjobCustomerTransfer bool `json:"onjob_customer_transfer"`
|
||||
EditAntiSpamRule bool `json:"edit_anti_spam_rule"`
|
||||
ExportCustomerList bool `json:"export_customer_list"`
|
||||
ExportCustomerData bool `json:"export_customer_data"`
|
||||
ExportCustomerGroupList bool `json:"export_customer_group_list"`
|
||||
ManageCustomerTag bool `json:"manage_customer_tag"`
|
||||
}
|
||||
|
||||
// GetCustomerStrategy 获取规则组详情
|
||||
// @see https://developer.work.weixin.qq.com/document/path/94883#%E8%8E%B7%E5%8F%96%E8%A7%84%E5%88%99%E7%BB%84%E8%AF%A6%E6%83%85
|
||||
func (r *Client) GetCustomerStrategy(req *GetCustomerStrategyRequest) (*GetCustomerStrategyResponse, 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(getCustomerStrategyURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetCustomerStrategyResponse{}
|
||||
err = util.DecodeWithError(response, result, "GetCustomerStrategy")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// GetRangeCustomerStrategyRequest 获取规则组管理范围请求
|
||||
type GetRangeCustomerStrategyRequest struct {
|
||||
StrategyID int `json:"strategy_id"`
|
||||
Cursor string `json:"cursor"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
// GetRangeCustomerStrategyResponse 获取规则组管理范围响应
|
||||
type GetRangeCustomerStrategyResponse struct {
|
||||
util.CommonError
|
||||
Range []Range `json:"range"`
|
||||
NextCursor string `json:"next_cursor"`
|
||||
}
|
||||
|
||||
// Range 管理范围节点
|
||||
type Range struct {
|
||||
Type int `json:"type"`
|
||||
UserID string `json:"userid,omitempty"`
|
||||
PartyID int `json:"partyid,omitempty"`
|
||||
}
|
||||
|
||||
// GetRangeCustomerStrategy 获取规则组管理范围
|
||||
// @see https://developer.work.weixin.qq.com/document/path/94883#%E8%8E%B7%E5%8F%96%E8%A7%84%E5%88%99%E7%BB%84%E7%AE%A1%E7%90%86%E8%8C%83%E5%9B%B4
|
||||
func (r *Client) GetRangeCustomerStrategy(req *GetRangeCustomerStrategyRequest) (*GetRangeCustomerStrategyResponse, 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(getRangeCustomerStrategyURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetRangeCustomerStrategyResponse{}
|
||||
err = util.DecodeWithError(response, result, "GetRangeCustomerStrategy")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// CreateCustomerStrategyRequest 创建新的规则组请求
|
||||
type CreateCustomerStrategyRequest struct {
|
||||
ParentID int `json:"parent_id"`
|
||||
StrategyName string `json:"strategy_name"`
|
||||
AdminList []string `json:"admin_list"`
|
||||
Privilege Privilege `json:"privilege"`
|
||||
Range []Range `json:"range"`
|
||||
}
|
||||
|
||||
// CreateCustomerStrategyResponse 创建新的规则组响应
|
||||
type CreateCustomerStrategyResponse struct {
|
||||
util.CommonError
|
||||
StrategyID int `json:"strategy_id"`
|
||||
}
|
||||
|
||||
// CreateCustomerStrategy 创建新的规则组
|
||||
// @see https://developer.work.weixin.qq.com/document/path/94883#%E5%88%9B%E5%BB%BA%E6%96%B0%E7%9A%84%E8%A7%84%E5%88%99%E7%BB%84
|
||||
func (r *Client) CreateCustomerStrategy(req *CreateCustomerStrategyRequest) (*CreateCustomerStrategyResponse, 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(createCustomerStrategyURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &CreateCustomerStrategyResponse{}
|
||||
err = util.DecodeWithError(response, result, "CreateCustomerStrategy")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// EditCustomerStrategyRequest 编辑规则组及其管理范围请求
|
||||
type EditCustomerStrategyRequest struct {
|
||||
StrategyID int `json:"strategy_id"`
|
||||
StrategyName string `json:"strategy_name"`
|
||||
AdminList []string `json:"admin_list"`
|
||||
Privilege Privilege `json:"privilege"`
|
||||
RangeAdd []Range `json:"range_add"`
|
||||
RangeDel []Range `json:"range_del"`
|
||||
}
|
||||
|
||||
// EditCustomerStrategy 编辑规则组及其管理范围
|
||||
// see https://developer.work.weixin.qq.com/document/path/94883#%E7%BC%96%E8%BE%91%E8%A7%84%E5%88%99%E7%BB%84%E5%8F%8A%E5%85%B6%E7%AE%A1%E7%90%86%E8%8C%83%E5%9B%B4
|
||||
func (r *Client) EditCustomerStrategy(req *EditCustomerStrategyRequest) 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(editCustomerStrategyURL, accessToken), req); err != nil {
|
||||
return err
|
||||
}
|
||||
return util.DecodeWithCommonError(response, "EditCustomerStrategy")
|
||||
}
|
||||
|
||||
// DelCustomerStrategyRequest 删除规则组请求
|
||||
type DelCustomerStrategyRequest struct {
|
||||
StrategyID int `json:"strategy_id"`
|
||||
}
|
||||
|
||||
// DelCustomerStrategy 删除规则组
|
||||
// see https://developer.work.weixin.qq.com/document/path/94883#%E5%88%A0%E9%99%A4%E8%A7%84%E5%88%99%E7%BB%84
|
||||
func (r *Client) DelCustomerStrategy(req *DelCustomerStrategyRequest) 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(delCustomerStrategyURL, accessToken), req); err != nil {
|
||||
return err
|
||||
}
|
||||
return util.DecodeWithCommonError(response, "DelCustomerStrategy")
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// FetchFollowUserListURL 获取配置了客户联系功能的成员列表
|
||||
FetchFollowUserListURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_follow_user_list"
|
||||
// fetchFollowUserListURL 获取配置了客户联系功能的成员列表
|
||||
fetchFollowUserListURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_follow_user_list"
|
||||
)
|
||||
|
||||
// followerUserResponse 客户联系功能的成员列表响应
|
||||
@@ -25,14 +25,11 @@ func (r *Client) GetFollowUserList() ([]string, error) {
|
||||
return nil, err
|
||||
}
|
||||
var response []byte
|
||||
response, err = util.HTTPGet(fmt.Sprintf("%s?access_token=%s", FetchFollowUserListURL, accessToken))
|
||||
response, err = util.HTTPGet(fmt.Sprintf("%s?access_token=%s", fetchFollowUserListURL, accessToken))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result followerUserResponse
|
||||
err = util.DecodeWithError(response, &result, "GetFollowUserList")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.FollowUser, nil
|
||||
return result.FollowUser, err
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"github.com/silenceper/wechat/v2/util"
|
||||
)
|
||||
|
||||
// OpengIDToChatIDURL 客户群opengid转换URL
|
||||
const OpengIDToChatIDURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/opengid_to_chatid"
|
||||
// opengIDToChatIDURL 客户群opengid转换URL
|
||||
const opengIDToChatIDURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/opengid_to_chatid"
|
||||
|
||||
type (
|
||||
//GroupChatListRequest 获取客户群列表的请求参数
|
||||
@@ -39,15 +39,13 @@ func (r *Client) GetGroupChatList(req *GroupChatListRequest) (*GroupChatListResp
|
||||
return nil, err
|
||||
}
|
||||
var response []byte
|
||||
response, err = util.PostJSON(fmt.Sprintf("%s/list?access_token=%s", GroupChatURL, accessToken), req)
|
||||
response, err = util.PostJSON(fmt.Sprintf("%s/list?access_token=%s", groupChatURL, accessToken), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GroupChatListResponse{}
|
||||
if err = util.DecodeWithError(response, result, "GetGroupChatList"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
err = util.DecodeWithError(response, result, "GetGroupChatList")
|
||||
return result, err
|
||||
}
|
||||
|
||||
type (
|
||||
@@ -70,6 +68,7 @@ type (
|
||||
GroupNickname string `json:"group_nickname"` //在群里的昵称
|
||||
Name string `json:"name"` //名字。仅当 need_name = 1 时返回 如果是微信用户,则返回其在微信中设置的名字 如果是企业微信联系人,则返回其设置对外展示的别名或实名
|
||||
UnionID string `json:"unionid,omitempty"` //外部联系人在微信开放平台的唯一身份标识(微信unionid),通过此字段企业可将外部联系人与公众号/小程序用户关联起来。仅当群成员类型是微信用户(包括企业成员未添加好友),且企业绑定了微信开发者ID有此字段(查看绑定方法)。第三方不可获取,上游企业不可获取下游企业客户的unionid字段
|
||||
State string `json:"state,omitempty"` //如果在配置入群方式时,配置了state参数,那么在获取客户群详情时,通过该方式入群的成员,会额外获取到相应的state参数
|
||||
}
|
||||
//GroupChatAdmin 群管理员
|
||||
GroupChatAdmin struct {
|
||||
@@ -77,13 +76,14 @@ type (
|
||||
}
|
||||
//GroupChat 客户群详情
|
||||
GroupChat struct {
|
||||
ChatID string `json:"chat_id"` //客户群ID
|
||||
Name string `json:"name"` //群名
|
||||
Owner string `json:"owner"` //群主ID
|
||||
CreateTime int `json:"create_time"` //群的创建时间
|
||||
Notice string `json:"notice"` //群公告
|
||||
MemberList []GroupChatMember `json:"member_list"` //群成员列表
|
||||
AdminList []GroupChatAdmin `json:"admin_list"` //群管理员列表
|
||||
ChatID string `json:"chat_id"` //客户群ID
|
||||
Name string `json:"name"` //群名
|
||||
Owner string `json:"owner"` //群主ID
|
||||
CreateTime int64 `json:"create_time"` //群的创建时间
|
||||
Notice string `json:"notice"` //群公告
|
||||
MemberList []GroupChatMember `json:"member_list"` //群成员列表
|
||||
AdminList []GroupChatAdmin `json:"admin_list"` //群管理员列表
|
||||
MemberVersion string `json:"member_version"` //当前群成员版本号。可以配合客户群变更事件减少主动调用本接口的次数
|
||||
}
|
||||
//GroupChatDetailResponse 客户群详情 返回值
|
||||
GroupChatDetailResponse struct {
|
||||
@@ -100,15 +100,13 @@ func (r *Client) GetGroupChatDetail(req *GroupChatDetailRequest) (*GroupChatDeta
|
||||
return nil, err
|
||||
}
|
||||
var response []byte
|
||||
response, err = util.PostJSON(fmt.Sprintf("%s/get?access_token=%s", GroupChatURL, accessToken), req)
|
||||
response, err = util.PostJSON(fmt.Sprintf("%s/get?access_token=%s", groupChatURL, accessToken), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GroupChatDetailResponse{}
|
||||
if err = util.DecodeWithError(response, result, "GetGroupChatDetail"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
err = util.DecodeWithError(response, result, "GetGroupChatDetail")
|
||||
return result, err
|
||||
}
|
||||
|
||||
type (
|
||||
@@ -131,13 +129,11 @@ func (r *Client) OpengIDToChatID(req *OpengIDToChatIDRequest) (*OpengIDToChatIDR
|
||||
return nil, err
|
||||
}
|
||||
var response []byte
|
||||
response, err = util.PostJSON(fmt.Sprintf("%s?access_token=%s", OpengIDToChatIDURL, accessToken), req)
|
||||
response, err = util.PostJSON(fmt.Sprintf("%s?access_token=%s", opengIDToChatIDURL, accessToken), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &OpengIDToChatIDResponse{}
|
||||
if err = util.DecodeWithError(response, result, "GetGroupChatDetail"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
err = util.DecodeWithError(response, result, "GetGroupChatDetail")
|
||||
return result, err
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"github.com/silenceper/wechat/v2/util"
|
||||
)
|
||||
|
||||
// GroupChatURL 客户群
|
||||
const GroupChatURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat"
|
||||
// groupChatURL 客户群
|
||||
const groupChatURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat"
|
||||
|
||||
type (
|
||||
// AddJoinWayRequest 添加群配置请求参数
|
||||
@@ -39,15 +39,13 @@ func (r *Client) AddJoinWay(req *AddJoinWayRequest) (*AddJoinWayResponse, error)
|
||||
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err = util.PostJSON(fmt.Sprintf("%s/add_join_way?access_token=%s", GroupChatURL, accessToken), req)
|
||||
response, err = util.PostJSON(fmt.Sprintf("%s/add_join_way?access_token=%s", groupChatURL, accessToken), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &AddJoinWayResponse{}
|
||||
if err = util.DecodeWithError(response, result, "AddJoinWay"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
err = util.DecodeWithError(response, result, "AddJoinWay")
|
||||
return result, err
|
||||
}
|
||||
|
||||
type (
|
||||
@@ -86,15 +84,13 @@ func (r *Client) GetJoinWay(req *JoinWayConfigRequest) (*GetJoinWayResponse, err
|
||||
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err = util.PostJSON(fmt.Sprintf("%s/get_join_way?access_token=%s", GroupChatURL, accessToken), req)
|
||||
response, err = util.PostJSON(fmt.Sprintf("%s/get_join_way?access_token=%s", groupChatURL, accessToken), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetJoinWayResponse{}
|
||||
if err = util.DecodeWithError(response, result, "GetJoinWay"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
err = util.DecodeWithError(response, result, "GetJoinWay")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// UpdateJoinWayRequest 更新群配置的请求参数
|
||||
@@ -120,7 +116,7 @@ func (r *Client) UpdateJoinWay(req *UpdateJoinWayRequest) error {
|
||||
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||
return err
|
||||
}
|
||||
response, err = util.PostJSON(fmt.Sprintf("%s/update_join_way?access_token=%s", GroupChatURL, accessToken), req)
|
||||
response, err = util.PostJSON(fmt.Sprintf("%s/update_join_way?access_token=%s", groupChatURL, accessToken), req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -138,7 +134,7 @@ func (r *Client) DelJoinWay(req *JoinWayConfigRequest) error {
|
||||
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||
return err
|
||||
}
|
||||
response, err = util.PostJSON(fmt.Sprintf("%s/del_join_way?access_token=%s", GroupChatURL, accessToken), req)
|
||||
response, err = util.PostJSON(fmt.Sprintf("%s/del_join_way?access_token=%s", groupChatURL, accessToken), req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
636
work/externalcontact/moment.go
Normal file
636
work/externalcontact/moment.go
Normal file
@@ -0,0 +1,636 @@
|
||||
package externalcontact
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/silenceper/wechat/v2/util"
|
||||
)
|
||||
|
||||
const (
|
||||
// addMomentTaskURL 创建发表任务
|
||||
addMomentTaskURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_moment_task?access_token=%s"
|
||||
// getMomentTaskResultURL 获取任务创建结果
|
||||
getMomentTaskResultURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_moment_task_result?access_token=%s&jobid=%s"
|
||||
// cancelMomentTaskURL 停止发表企业朋友圈
|
||||
cancelMomentTaskURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/cancel_moment_task?access_token=%s"
|
||||
// getMomentListURL 获取企业全部的发表列表
|
||||
getMomentListURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_moment_list?access_token=%s"
|
||||
// getMomentTaskURL 获取客户朋友圈企业发表的列表
|
||||
getMomentTaskURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_moment_task?access_token=%s"
|
||||
// getMomentCustomerListURL 获取客户朋友圈发表时选择的可见范围
|
||||
getMomentCustomerListURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_moment_customer_list?access_token=%s"
|
||||
// getMomentSendResultURL 获取客户朋友圈发表后的可见客户列表
|
||||
getMomentSendResultURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_moment_send_result?access_token=%s"
|
||||
// getMomentCommentsURL 获取客户朋友圈的互动数据
|
||||
getMomentCommentsURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_moment_comments?access_token=%s"
|
||||
// listMomentStrategyURL 获取规则组列表
|
||||
listMomentStrategyURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/moment_strategy/list?access_token=%s"
|
||||
// getMomentStrategyURL 获取规则组详情
|
||||
getMomentStrategyURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/moment_strategy/get?access_token=%s"
|
||||
// getRangeMomentStrategyURL 获取规则组管理范围
|
||||
getRangeMomentStrategyURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/moment_strategy/get_range?access_token=%s"
|
||||
// createMomentStrategyURL 创建新的规则组
|
||||
createMomentStrategyURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/moment_strategy/create?access_token=%s"
|
||||
// editMomentStrategyURL 编辑规则组及其管理范围
|
||||
editMomentStrategyURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/moment_strategy/edit?access_token=%s"
|
||||
// delMomentStrategyURL 删除规则组
|
||||
delMomentStrategyURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/moment_strategy/del?access_token=%s"
|
||||
)
|
||||
|
||||
// AddMomentTaskRequest 创建发表任务请求
|
||||
type AddMomentTaskRequest struct {
|
||||
Text MomentTaskText `json:"text"`
|
||||
Attachments []MomentTaskAttachment `json:"attachments"`
|
||||
VisibleRange MomentVisibleRange `json:"visible_range"`
|
||||
}
|
||||
|
||||
// MomentTaskText 发表任务文本消息
|
||||
type MomentTaskText struct {
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
// MomentTaskImage 发表任务图片消息
|
||||
type MomentTaskImage struct {
|
||||
MediaID string `json:"media_id"`
|
||||
}
|
||||
|
||||
// MomentTaskVideo 发表任务视频消息
|
||||
type MomentTaskVideo struct {
|
||||
MediaID string `json:"media_id"`
|
||||
}
|
||||
|
||||
// MomentTaskLink 发表任务图文消息
|
||||
type MomentTaskLink struct {
|
||||
Title string `json:"title"`
|
||||
URL string `json:"url"`
|
||||
MediaID string `json:"media_id"`
|
||||
}
|
||||
|
||||
// MomentTaskAttachment 发表任务附件
|
||||
type MomentTaskAttachment struct {
|
||||
MsgType string `json:"msgtype"`
|
||||
Image MomentTaskImage `json:"image,omitempty"`
|
||||
Video MomentTaskVideo `json:"video,omitempty"`
|
||||
Link MomentTaskLink `json:"link,omitempty"`
|
||||
}
|
||||
|
||||
// MomentVisibleRange 朋友圈指定的发表范围
|
||||
type MomentVisibleRange struct {
|
||||
SenderList MomentSenderList `json:"sender_list"`
|
||||
ExternalContactList MomentExternalContactList `json:"external_contact_list"`
|
||||
}
|
||||
|
||||
// MomentSenderList 发表任务的执行者列表
|
||||
type MomentSenderList struct {
|
||||
UserList []string `json:"user_list"`
|
||||
DepartmentList []int `json:"department_list"`
|
||||
}
|
||||
|
||||
// MomentExternalContactList 可见到该朋友圈的客户列表
|
||||
type MomentExternalContactList struct {
|
||||
TagList []string `json:"tag_list"`
|
||||
}
|
||||
|
||||
// AddMomentTaskResponse 创建发表任务响应
|
||||
type AddMomentTaskResponse struct {
|
||||
util.CommonError
|
||||
JobID string `json:"jobid"`
|
||||
}
|
||||
|
||||
// AddMomentTask 创建发表任务
|
||||
// see https://developer.work.weixin.qq.com/document/path/95094#%E5%88%9B%E5%BB%BA%E5%8F%91%E8%A1%A8%E4%BB%BB%E5%8A%A1
|
||||
func (r *Client) AddMomentTask(req *AddMomentTaskRequest) (*AddMomentTaskResponse, 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(addMomentTaskURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &AddMomentTaskResponse{}
|
||||
err = util.DecodeWithError(response, result, "AddMomentTask")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// GetMomentTaskResultResponse 获取任务创建结果响应
|
||||
type GetMomentTaskResultResponse struct {
|
||||
util.CommonError
|
||||
Status int `json:"status"`
|
||||
Type string `json:"type"`
|
||||
Result MomentTaskResult `json:"result"`
|
||||
}
|
||||
|
||||
// MomentTaskResult 任务创建结果
|
||||
type MomentTaskResult struct {
|
||||
ErrCode int64 `json:"errcode"`
|
||||
ErrMsg string `json:"errmsg"`
|
||||
MomentID string `json:"moment_id"`
|
||||
InvalidSenderList MomentInvalidSenderList `json:"invalid_sender_list"`
|
||||
InvalidExternalContactList MomentInvalidExternalContactList `json:"invalid_external_contact_list"`
|
||||
}
|
||||
|
||||
// MomentInvalidSenderList 不合法的执行者列表
|
||||
type MomentInvalidSenderList struct {
|
||||
UserList []string `json:"user_list"`
|
||||
DepartmentList []int `json:"department_list"`
|
||||
}
|
||||
|
||||
// MomentInvalidExternalContactList 不合法的可见到该朋友圈的客户列表
|
||||
type MomentInvalidExternalContactList struct {
|
||||
TagList []string `json:"tag_list"`
|
||||
}
|
||||
|
||||
// GetMomentTaskResult 获取任务创建结果
|
||||
// see https://developer.work.weixin.qq.com/document/path/95094#%E8%8E%B7%E5%8F%96%E4%BB%BB%E5%8A%A1%E5%88%9B%E5%BB%BA%E7%BB%93%E6%9E%9C
|
||||
func (r *Client) GetMomentTaskResult(jobID string) (*GetMomentTaskResultResponse, 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(getMomentTaskResultURL, accessToken, jobID)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetMomentTaskResultResponse{}
|
||||
err = util.DecodeWithError(response, result, "GetMomentTaskResult")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// CancelMomentTaskRequest 停止发表企业朋友圈请求
|
||||
type CancelMomentTaskRequest struct {
|
||||
MomentID string `json:"moment_id"`
|
||||
}
|
||||
|
||||
// CancelMomentTask 停止发表企业朋友圈
|
||||
// see https://developer.work.weixin.qq.com/document/path/97612
|
||||
func (r *Client) CancelMomentTask(req *CancelMomentTaskRequest) 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(cancelMomentTaskURL, accessToken), req); err != nil {
|
||||
return err
|
||||
}
|
||||
return util.DecodeWithCommonError(response, "CancelMomentTask")
|
||||
}
|
||||
|
||||
// GetMomentListRequest 获取企业全部的发表列表请求
|
||||
type GetMomentListRequest struct {
|
||||
StartTime int64 `json:"start_time"`
|
||||
EndTime int64 `json:"end_time"`
|
||||
Creator string `json:"creator"`
|
||||
FilterType int `json:"filter_type"`
|
||||
Cursor string `json:"cursor"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
// GetMomentListResponse 获取企业全部的发表列表响应
|
||||
type GetMomentListResponse struct {
|
||||
util.CommonError
|
||||
NextCursor string `json:"next_cursor"`
|
||||
MomentList []MomentItem `json:"moment_list"`
|
||||
}
|
||||
|
||||
// MomentItem 朋友圈
|
||||
type MomentItem struct {
|
||||
MomentID string `json:"moment_id"`
|
||||
Creator string `json:"creator"`
|
||||
CreateTime int64 `json:"create_time"`
|
||||
CreateType int `json:"create_type"`
|
||||
VisibleType int `json:"visible_type"`
|
||||
Text MomentText `json:"text"`
|
||||
Image []MomentImage `json:"image"`
|
||||
Video MomentVideo `json:"video"`
|
||||
Link MomentLink `json:"link"`
|
||||
Location MomentLocation `json:"location"`
|
||||
}
|
||||
|
||||
// MomentText 朋友圈文本消息
|
||||
type MomentText struct {
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
// MomentImage 朋友圈图片
|
||||
type MomentImage struct {
|
||||
MediaID string `json:"media_id"`
|
||||
}
|
||||
|
||||
// MomentVideo 朋友圈视频
|
||||
type MomentVideo struct {
|
||||
MediaID string `json:"media_id"`
|
||||
ThumbMediaID string `json:"thumb_media_id"`
|
||||
}
|
||||
|
||||
// MomentLink 朋友圈网页链接
|
||||
type MomentLink struct {
|
||||
Title string `json:"title"`
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
// MomentLocation 朋友圈地理位置
|
||||
type MomentLocation struct {
|
||||
Latitude string `json:"latitude"`
|
||||
Longitude string `json:"longitude"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// GetMomentList 获取企业全部的发表列表
|
||||
// see https://developer.work.weixin.qq.com/document/path/93333#%E8%8E%B7%E5%8F%96%E4%BC%81%E4%B8%9A%E5%85%A8%E9%83%A8%E7%9A%84%E5%8F%91%E8%A1%A8%E5%88%97%E8%A1%A8
|
||||
func (r *Client) GetMomentList(req *GetMomentListRequest) (*GetMomentListResponse, 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(getMomentListURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetMomentListResponse{}
|
||||
err = util.DecodeWithError(response, result, "GetMomentList")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// GetMomentTaskRequest 获取客户朋友圈企业发表的列表请求
|
||||
type GetMomentTaskRequest struct {
|
||||
MomentID string `json:"moment_id"`
|
||||
Cursor string `json:"cursor"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
// GetMomentTaskResponse 获取客户朋友圈企业发表的列表响应
|
||||
type GetMomentTaskResponse struct {
|
||||
util.CommonError
|
||||
NextCursor string `json:"next_cursor"`
|
||||
TaskList []MomentTask `json:"task_list"`
|
||||
}
|
||||
|
||||
// MomentTask 发表任务
|
||||
type MomentTask struct {
|
||||
UserID string `json:"userid"`
|
||||
PublishStatus int `json:"publish_status"`
|
||||
}
|
||||
|
||||
// GetMomentTask 获取客户朋友圈企业发表的列表
|
||||
// see https://developer.work.weixin.qq.com/document/path/93333#%E8%8E%B7%E5%8F%96%E5%AE%A2%E6%88%B7%E6%9C%8B%E5%8F%8B%E5%9C%88%E4%BC%81%E4%B8%9A%E5%8F%91%E8%A1%A8%E7%9A%84%E5%88%97%E8%A1%A8
|
||||
func (r *Client) GetMomentTask(req *GetMomentTaskRequest) (*GetMomentTaskResponse, 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(getMomentTaskURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetMomentTaskResponse{}
|
||||
err = util.DecodeWithError(response, result, "GetMomentTask")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// GetMomentCustomerListRequest 获取客户朋友圈发表时选择的可见范围请求
|
||||
type GetMomentCustomerListRequest struct {
|
||||
MomentID string `json:"moment_id"`
|
||||
UserID string `json:"userid"`
|
||||
Cursor string `json:"cursor"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
// GetMomentCustomerListResponse 获取客户朋友圈发表时选择的可见范围响应
|
||||
type GetMomentCustomerListResponse struct {
|
||||
util.CommonError
|
||||
NextCursor string `json:"next_cursor"`
|
||||
CustomerList []MomentCustomer `json:"customer_list"`
|
||||
}
|
||||
|
||||
// MomentCustomer 成员可见客户列表
|
||||
type MomentCustomer struct {
|
||||
UserID string `json:"userid"`
|
||||
ExternalUserID string `json:"external_userid"`
|
||||
}
|
||||
|
||||
// GetMomentCustomerList 获取客户朋友圈发表时选择的可见范围
|
||||
// see https://developer.work.weixin.qq.com/document/path/93333#%E8%8E%B7%E5%8F%96%E5%AE%A2%E6%88%B7%E6%9C%8B%E5%8F%8B%E5%9C%88%E5%8F%91%E8%A1%A8%E6%97%B6%E9%80%89%E6%8B%A9%E7%9A%84%E5%8F%AF%E8%A7%81%E8%8C%83%E5%9B%B4
|
||||
func (r *Client) GetMomentCustomerList(req *GetMomentCustomerListRequest) (*GetMomentCustomerListResponse, 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(getMomentCustomerListURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetMomentCustomerListResponse{}
|
||||
err = util.DecodeWithError(response, result, "GetMomentCustomerList")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// GetMomentSendResultRequest 获取客户朋友圈发表后的可见客户列表请求
|
||||
type GetMomentSendResultRequest struct {
|
||||
MomentID string `json:"moment_id"`
|
||||
UserID string `json:"userid"`
|
||||
Cursor string `json:"cursor"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
// GetMomentSendResultResponse 获取客户朋友圈发表后的可见客户列表响应
|
||||
type GetMomentSendResultResponse struct {
|
||||
util.CommonError
|
||||
NextCursor string `json:"next_cursor"`
|
||||
CustomerList []MomentSendCustomer `json:"customer_list"`
|
||||
}
|
||||
|
||||
// MomentSendCustomer 成员发送成功客户
|
||||
type MomentSendCustomer struct {
|
||||
ExternalUserID string `json:"external_userid"`
|
||||
}
|
||||
|
||||
// GetMomentSendResult 获取客户朋友圈发表后的可见客户列表
|
||||
// see https://developer.work.weixin.qq.com/document/path/93333#%E8%8E%B7%E5%8F%96%E5%AE%A2%E6%88%B7%E6%9C%8B%E5%8F%8B%E5%9C%88%E5%8F%91%E8%A1%A8%E5%90%8E%E7%9A%84%E5%8F%AF%E8%A7%81%E5%AE%A2%E6%88%B7%E5%88%97%E8%A1%A8
|
||||
func (r *Client) GetMomentSendResult(req *GetMomentSendResultRequest) (*GetMomentSendResultResponse, 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(getMomentSendResultURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetMomentSendResultResponse{}
|
||||
err = util.DecodeWithError(response, result, "GetMomentSendResult")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// GetMomentCommentsRequest 获取客户朋友圈的互动数据请求
|
||||
type GetMomentCommentsRequest struct {
|
||||
MomentID string `json:"moment_id"`
|
||||
UserID string `json:"userid"`
|
||||
}
|
||||
|
||||
// GetMomentCommentsResponse 获取客户朋友圈的互动数据响应
|
||||
type GetMomentCommentsResponse struct {
|
||||
util.CommonError
|
||||
CommentList []MomentComment `json:"comment_list"`
|
||||
LikeList []MomentLike `json:"like_list"`
|
||||
}
|
||||
|
||||
// MomentComment 朋友圈评论
|
||||
type MomentComment struct {
|
||||
ExternalUserID string `json:"external_userid,omitempty"`
|
||||
UserID string `json:"userid,omitempty"`
|
||||
CreateTime int64 `json:"create_time"`
|
||||
}
|
||||
|
||||
// MomentLike 朋友圈点赞
|
||||
type MomentLike struct {
|
||||
ExternalUserID string `json:"external_userid,omitempty"`
|
||||
UserID string `json:"userid,omitempty"`
|
||||
CreateTime int64 `json:"create_time"`
|
||||
}
|
||||
|
||||
// GetMomentComments 获取客户朋友圈的互动数据
|
||||
// see https://developer.work.weixin.qq.com/document/path/93333#%E8%8E%B7%E5%8F%96%E5%AE%A2%E6%88%B7%E6%9C%8B%E5%8F%8B%E5%9C%88%E7%9A%84%E4%BA%92%E5%8A%A8%E6%95%B0%E6%8D%AE
|
||||
func (r *Client) GetMomentComments(req *GetMomentCommentsRequest) (*GetMomentCommentsResponse, 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(getMomentCommentsURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetMomentCommentsResponse{}
|
||||
err = util.DecodeWithError(response, result, "GetMomentComments")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// ListMomentStrategyRequest 获取规则组列表请求
|
||||
type ListMomentStrategyRequest struct {
|
||||
Cursor string `json:"cursor"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
// ListMomentStrategyResponse 获取规则组列表响应
|
||||
type ListMomentStrategyResponse struct {
|
||||
util.CommonError
|
||||
Strategy []MomentStrategyID `json:"strategy"`
|
||||
NextCursor string `json:"next_cursor"`
|
||||
}
|
||||
|
||||
// MomentStrategyID 规则组ID
|
||||
type MomentStrategyID struct {
|
||||
StrategyID int `json:"strategy_id"`
|
||||
}
|
||||
|
||||
// ListMomentStrategy 获取规则组列表
|
||||
// see https://developer.work.weixin.qq.com/document/path/94890#%E8%8E%B7%E5%8F%96%E8%A7%84%E5%88%99%E7%BB%84%E5%88%97%E8%A1%A8
|
||||
func (r *Client) ListMomentStrategy(req *ListMomentStrategyRequest) (*ListMomentStrategyResponse, 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(listMomentStrategyURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &ListMomentStrategyResponse{}
|
||||
err = util.DecodeWithError(response, result, "ListMomentStrategy")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// GetMomentStrategyRequest 获取规则组详情请求
|
||||
type GetMomentStrategyRequest struct {
|
||||
StrategyID int `json:"strategy_id"`
|
||||
}
|
||||
|
||||
// GetMomentStrategyResponse 获取规则组详情响应
|
||||
type GetMomentStrategyResponse struct {
|
||||
util.CommonError
|
||||
Strategy MomentStrategy `json:"strategy"`
|
||||
}
|
||||
|
||||
// MomentStrategy 规则组
|
||||
type MomentStrategy struct {
|
||||
StrategyID int `json:"strategy_id"`
|
||||
ParentID int `json:"parent_id"`
|
||||
StrategyName string `json:"strategy_name"`
|
||||
CreateTime int64 `json:"create_time"`
|
||||
AdminList []string `json:"admin_list"`
|
||||
Privilege MomentPrivilege `json:"privilege"`
|
||||
}
|
||||
|
||||
// MomentPrivilege 规则组权限
|
||||
type MomentPrivilege struct {
|
||||
ViewMomentList bool `json:"view_moment_list"`
|
||||
SendMoment bool `json:"send_moment"`
|
||||
ManageMomentCoverAndSign bool `json:"manage_moment_cover_and_sign"`
|
||||
}
|
||||
|
||||
// GetMomentStrategy 获取规则组详情
|
||||
// see https://developer.work.weixin.qq.com/document/path/94890#%E8%8E%B7%E5%8F%96%E8%A7%84%E5%88%99%E7%BB%84%E8%AF%A6%E6%83%85
|
||||
func (r *Client) GetMomentStrategy(req *GetMomentStrategyRequest) (*GetMomentStrategyResponse, 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(getMomentStrategyURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetMomentStrategyResponse{}
|
||||
err = util.DecodeWithError(response, result, "GetMomentStrategy")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// GetRangeMomentStrategyRequest 获取规则组管理范围请求
|
||||
type GetRangeMomentStrategyRequest struct {
|
||||
StrategyID int `json:"strategy_id"`
|
||||
Cursor string `json:"cursor"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
// GetRangeMomentStrategyResponse 获取规则组管理范围响应
|
||||
type GetRangeMomentStrategyResponse struct {
|
||||
util.CommonError
|
||||
Range []RangeMomentStrategy `json:"range"`
|
||||
NextCursor string `json:"next_cursor"`
|
||||
}
|
||||
|
||||
// RangeMomentStrategy 管理范围内配置的成员或部门
|
||||
type RangeMomentStrategy struct {
|
||||
Type int `json:"type"`
|
||||
UserID string `json:"userid,omitempty"`
|
||||
PartyID int `json:"partyid,omitempty"`
|
||||
}
|
||||
|
||||
// GetRangeMomentStrategy 获取规则组管理范围
|
||||
// see https://developer.work.weixin.qq.com/document/path/94890#%E8%8E%B7%E5%8F%96%E8%A7%84%E5%88%99%E7%BB%84%E7%AE%A1%E7%90%86%E8%8C%83%E5%9B%B4
|
||||
func (r *Client) GetRangeMomentStrategy(req *GetRangeMomentStrategyRequest) (*GetRangeMomentStrategyResponse, 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(getRangeMomentStrategyURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetRangeMomentStrategyResponse{}
|
||||
err = util.DecodeWithError(response, result, "GetRangeMomentStrategy")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// CreateMomentStrategyRequest 创建新的规则组请求
|
||||
type CreateMomentStrategyRequest struct {
|
||||
ParentID int `json:"parent_id"`
|
||||
StrategyName string `json:"strategy_name"`
|
||||
AdminList []string `json:"admin_list"`
|
||||
Privilege MomentPrivilege `json:"privilege"`
|
||||
Range []RangeMomentStrategy `json:"range"`
|
||||
}
|
||||
|
||||
// CreateMomentStrategyResponse 创建新的规则组响应
|
||||
type CreateMomentStrategyResponse struct {
|
||||
util.CommonError
|
||||
StrategyID int `json:"strategy_id"`
|
||||
}
|
||||
|
||||
// CreateMomentStrategy 创建新的规则组
|
||||
// see https://developer.work.weixin.qq.com/document/path/94890#%E5%88%9B%E5%BB%BA%E6%96%B0%E7%9A%84%E8%A7%84%E5%88%99%E7%BB%84
|
||||
func (r *Client) CreateMomentStrategy(req *CreateMomentStrategyRequest) (*CreateMomentStrategyResponse, 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(createMomentStrategyURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &CreateMomentStrategyResponse{}
|
||||
err = util.DecodeWithError(response, result, "CreateMomentStrategy")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// EditMomentStrategyRequest 编辑规则组及其管理范围请求
|
||||
type EditMomentStrategyRequest struct {
|
||||
StrategyID int `json:"strategy_id"`
|
||||
StrategyName string `json:"strategy_name"`
|
||||
AdminList []string `json:"admin_list"`
|
||||
Privilege MomentPrivilege `json:"privilege"`
|
||||
RangeAdd []RangeMomentStrategy `json:"range_add"`
|
||||
RangeDel []RangeMomentStrategy `json:"range_del"`
|
||||
}
|
||||
|
||||
// EditMomentStrategy 编辑规则组及其管理范围
|
||||
// see https://developer.work.weixin.qq.com/document/path/94890#%E7%BC%96%E8%BE%91%E8%A7%84%E5%88%99%E7%BB%84%E5%8F%8A%E5%85%B6%E7%AE%A1%E7%90%86%E8%8C%83%E5%9B%B4
|
||||
func (r *Client) EditMomentStrategy(req *EditMomentStrategyRequest) 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(editMomentStrategyURL, accessToken), req); err != nil {
|
||||
return err
|
||||
}
|
||||
return util.DecodeWithCommonError(response, "EditMomentStrategy")
|
||||
}
|
||||
|
||||
// DelMomentStrategyRequest 删除规则组请求
|
||||
type DelMomentStrategyRequest struct {
|
||||
StrategyID int `json:"strategy_id"`
|
||||
}
|
||||
|
||||
// DelMomentStrategy 删除规则组
|
||||
// see https://developer.work.weixin.qq.com/document/path/94890#%E5%88%A0%E9%99%A4%E8%A7%84%E5%88%99%E7%BB%84
|
||||
func (r *Client) DelMomentStrategy(req *DelMomentStrategyRequest) 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(delMomentStrategyURL, accessToken), req); err != nil {
|
||||
return err
|
||||
}
|
||||
return util.DecodeWithCommonError(response, "DelMomentStrategy")
|
||||
}
|
||||
@@ -7,24 +7,28 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// AddMsgTemplateURL 创建企业群发
|
||||
AddMsgTemplateURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_msg_template?access_token=%s"
|
||||
// GetGroupMsgListV2URL 获取群发记录列表
|
||||
GetGroupMsgListV2URL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_groupmsg_list_v2?access_token=%s"
|
||||
// GetGroupMsgTaskURL 获取群发成员发送任务列表
|
||||
GetGroupMsgTaskURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_groupmsg_task?access_token=%s"
|
||||
// GetGroupMsgSendResultURL 获取企业群发成员执行结果
|
||||
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"
|
||||
// addMsgTemplateURL 创建企业群发
|
||||
addMsgTemplateURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_msg_template?access_token=%s"
|
||||
// getGroupMsgListV2URL 获取群发记录列表
|
||||
getGroupMsgListV2URL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_groupmsg_list_v2?access_token=%s"
|
||||
// getGroupMsgTaskURL 获取群发成员发送任务列表
|
||||
getGroupMsgTaskURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_groupmsg_task?access_token=%s"
|
||||
// getGroupMsgSendResultURL 获取企业群发成员执行结果
|
||||
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"
|
||||
// remindGroupMsgSendURL 提醒成员群发
|
||||
remindGroupMsgSendURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/remind_groupmsg_send?access_token=%s"
|
||||
// cancelGroupMsgSendURL 停止企业群发
|
||||
cancelGroupMsgSendURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/cancel_groupmsg_send?access_token=%s"
|
||||
)
|
||||
|
||||
// AddMsgTemplateRequest 创建企业群发请求
|
||||
@@ -34,8 +38,23 @@ type AddMsgTemplateRequest struct {
|
||||
Sender string `json:"sender,omitempty"`
|
||||
Text MsgText `json:"text"`
|
||||
Attachments []*Attachment `json:"attachments"`
|
||||
AllowSelect bool `json:"allow_select,omitempty"`
|
||||
ChatIDList []string `json:"chat_id_list,omitempty"`
|
||||
TagFilter TagFilter `json:"tag_filter,omitempty"`
|
||||
}
|
||||
|
||||
type (
|
||||
// TagFilter 标签过滤
|
||||
TagFilter struct {
|
||||
GroupList []TagGroupList `json:"group_list"`
|
||||
}
|
||||
|
||||
// TagGroupList 标签组
|
||||
TagGroupList struct {
|
||||
TagList []string `json:"tag_list"`
|
||||
}
|
||||
)
|
||||
|
||||
// MsgText 文本消息
|
||||
type MsgText struct {
|
||||
Content string `json:"content"`
|
||||
@@ -98,21 +117,19 @@ func (r *Client) AddMsgTemplate(req *AddMsgTemplateRequest) (*AddMsgTemplateResp
|
||||
return nil, err
|
||||
}
|
||||
var response []byte
|
||||
if response, err = util.PostJSON(fmt.Sprintf(AddMsgTemplateURL, accessToken), req); err != nil {
|
||||
if response, err = util.PostJSON(fmt.Sprintf(addMsgTemplateURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &AddMsgTemplateResponse{}
|
||||
if err = util.DecodeWithError(response, result, "AddMsgTemplate"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
err = util.DecodeWithError(response, result, "AddMsgTemplate")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// GetGroupMsgListV2Request 获取群发记录列表请求
|
||||
type GetGroupMsgListV2Request struct {
|
||||
ChatType string `json:"chat_type"`
|
||||
StartTime int `json:"start_time"`
|
||||
EndTime int `json:"end_time"`
|
||||
StartTime int64 `json:"start_time"`
|
||||
EndTime int64 `json:"end_time"`
|
||||
Creator string `json:"creator,omitempty"`
|
||||
FilterType int `json:"filter_type"`
|
||||
Limit int `json:"limit"`
|
||||
@@ -130,7 +147,7 @@ type GetGroupMsgListV2Response struct {
|
||||
type GroupMsg struct {
|
||||
MsgID string `json:"msgid"`
|
||||
Creator string `json:"creator"`
|
||||
CreateTime int `json:"create_time"`
|
||||
CreateTime int64 `json:"create_time"`
|
||||
CreateType int `json:"create_type"`
|
||||
Text MsgText `json:"text"`
|
||||
Attachments []*Attachment `json:"attachments"`
|
||||
@@ -147,14 +164,12 @@ func (r *Client) GetGroupMsgListV2(req *GetGroupMsgListV2Request) (*GetGroupMsgL
|
||||
return nil, err
|
||||
}
|
||||
var response []byte
|
||||
if response, err = util.PostJSON(fmt.Sprintf(GetGroupMsgListV2URL, accessToken), req); err != nil {
|
||||
if response, err = util.PostJSON(fmt.Sprintf(getGroupMsgListV2URL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetGroupMsgListV2Response{}
|
||||
if err = util.DecodeWithError(response, result, "GetGroupMsgListV2"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
err = util.DecodeWithError(response, result, "GetGroupMsgListV2")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// GetGroupMsgTaskRequest 获取群发成员发送任务列表请求
|
||||
@@ -189,14 +204,12 @@ func (r *Client) GetGroupMsgTask(req *GetGroupMsgTaskRequest) (*GetGroupMsgTaskR
|
||||
return nil, err
|
||||
}
|
||||
var response []byte
|
||||
if response, err = util.PostJSON(fmt.Sprintf(GetGroupMsgTaskURL, accessToken), req); err != nil {
|
||||
if response, err = util.PostJSON(fmt.Sprintf(getGroupMsgTaskURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetGroupMsgTaskResponse{}
|
||||
if err = util.DecodeWithError(response, result, "GetGroupMsgTask"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
err = util.DecodeWithError(response, result, "GetGroupMsgTask")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// GetGroupMsgSendResultRequest 获取企业群发成员执行结果请求
|
||||
@@ -234,14 +247,12 @@ func (r *Client) GetGroupMsgSendResult(req *GetGroupMsgSendResultRequest) (*GetG
|
||||
return nil, err
|
||||
}
|
||||
var response []byte
|
||||
if response, err = util.PostJSON(fmt.Sprintf(GetGroupMsgSendResultURL, accessToken), req); err != nil {
|
||||
if response, err = util.PostJSON(fmt.Sprintf(getGroupMsgSendResultURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetGroupMsgSendResultResponse{}
|
||||
if err = util.DecodeWithError(response, result, "GetGroupMsgSendResult"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
err = util.DecodeWithError(response, result, "GetGroupMsgSendResult")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// SendWelcomeMsgRequest 发送新客户欢迎语请求
|
||||
@@ -267,26 +278,23 @@ func (r *Client) SendWelcomeMsg(req *SendWelcomeMsgRequest) error {
|
||||
return err
|
||||
}
|
||||
var response []byte
|
||||
if response, err = util.PostJSON(fmt.Sprintf(SendWelcomeMsgURL, accessToken), req); err != nil {
|
||||
if response, err = util.PostJSON(fmt.Sprintf(sendWelcomeMsgURL, accessToken), req); err != nil {
|
||||
return err
|
||||
}
|
||||
result := &SendWelcomeMsgResponse{}
|
||||
if err = util.DecodeWithError(response, result, "SendWelcomeMsg"); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return util.DecodeWithError(response, result, "SendWelcomeMsg")
|
||||
}
|
||||
|
||||
// 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"`
|
||||
Text MsgText `json:"text"`
|
||||
Image *AttachmentImg `json:"image,omitempty"`
|
||||
Link *AttachmentLink `json:"link,omitempty"`
|
||||
MiniProgram *AttachmentMiniProgram `json:"miniprogram,omitempty"`
|
||||
File *AttachmentFile `json:"file,omitempty"`
|
||||
Video *AttachmentVideo `json:"video,omitempty"`
|
||||
AgentID int `json:"agentid,omitempty"`
|
||||
Notify int `json:"notify,omitempty"`
|
||||
}
|
||||
|
||||
// AddGroupWelcomeTemplateResponse 添加入群欢迎语素材响应
|
||||
@@ -306,26 +314,24 @@ func (r *Client) AddGroupWelcomeTemplate(req *AddGroupWelcomeTemplateRequest) (*
|
||||
return nil, err
|
||||
}
|
||||
var response []byte
|
||||
if response, err = util.PostJSON(fmt.Sprintf(AddGroupWelcomeTemplateURL, accessToken), req); err != nil {
|
||||
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
|
||||
err = util.DecodeWithError(response, result, "AddGroupWelcomeTemplate")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// 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"`
|
||||
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 编辑入群欢迎语素材响应
|
||||
@@ -344,14 +350,11 @@ func (r *Client) EditGroupWelcomeTemplate(req *EditGroupWelcomeTemplateRequest)
|
||||
return err
|
||||
}
|
||||
var response []byte
|
||||
if response, err = util.PostJSON(fmt.Sprintf(EditGroupWelcomeTemplateURL, accessToken), req); err != nil {
|
||||
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
|
||||
return util.DecodeWithError(response, result, "EditGroupWelcomeTemplate")
|
||||
}
|
||||
|
||||
// GetGroupWelcomeTemplateRequest 获取入群欢迎语素材请求
|
||||
@@ -363,11 +366,11 @@ type GetGroupWelcomeTemplateRequest struct {
|
||||
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"`
|
||||
Image AttachmentImg `json:"image,omitempty"`
|
||||
Link AttachmentLink `json:"link,omitempty"`
|
||||
MiniProgram AttachmentMiniProgram `json:"miniprogram,omitempty"`
|
||||
File AttachmentFile `json:"file,omitempty"`
|
||||
Video AttachmentVideo `json:"video,omitempty"`
|
||||
}
|
||||
|
||||
// GetGroupWelcomeTemplate 获取入群欢迎语素材
|
||||
@@ -381,14 +384,12 @@ func (r *Client) GetGroupWelcomeTemplate(req *GetGroupWelcomeTemplateRequest) (*
|
||||
return nil, err
|
||||
}
|
||||
var response []byte
|
||||
if response, err = util.PostJSON(fmt.Sprintf(GetGroupWelcomeTemplateURL, accessToken), req); err != nil {
|
||||
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
|
||||
err = util.DecodeWithError(response, result, "GetGroupWelcomeTemplate")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// DelGroupWelcomeTemplateRequest 删除入群欢迎语素材请求
|
||||
@@ -413,12 +414,53 @@ func (r *Client) DelGroupWelcomeTemplate(req *DelGroupWelcomeTemplateRequest) er
|
||||
return err
|
||||
}
|
||||
var response []byte
|
||||
if response, err = util.PostJSON(fmt.Sprintf(DelGroupWelcomeTemplateURL, accessToken), req); err != nil {
|
||||
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 util.DecodeWithError(response, result, "DelGroupWelcomeTemplate")
|
||||
}
|
||||
|
||||
// RemindGroupMsgSendRequest 提醒成员群发请求
|
||||
type RemindGroupMsgSendRequest struct {
|
||||
MsgID string `json:"msgid"`
|
||||
}
|
||||
|
||||
// RemindGroupMsgSend 提醒成员群发
|
||||
// see https://developer.work.weixin.qq.com/document/path/97610
|
||||
func (r *Client) RemindGroupMsgSend(req *RemindGroupMsgSendRequest) error {
|
||||
var (
|
||||
accessToken string
|
||||
err error
|
||||
)
|
||||
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
var response []byte
|
||||
if response, err = util.PostJSON(fmt.Sprintf(remindGroupMsgSendURL, accessToken), req); err != nil {
|
||||
return err
|
||||
}
|
||||
return util.DecodeWithCommonError(response, "RemindGroupMsgSend")
|
||||
}
|
||||
|
||||
// CancelGroupMsgSendRequest 停止企业群发请求
|
||||
type CancelGroupMsgSendRequest struct {
|
||||
MsgID string `json:"msgid"`
|
||||
}
|
||||
|
||||
// CancelGroupMsgSend 提醒成员群发
|
||||
// see https://developer.work.weixin.qq.com/document/path/97611
|
||||
func (r *Client) CancelGroupMsgSend(req *CancelGroupMsgSendRequest) 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(cancelGroupMsgSendURL, accessToken), req); err != nil {
|
||||
return err
|
||||
}
|
||||
return util.DecodeWithCommonError(response, "CancelGroupMsgSend")
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// GetUserBehaviorDataURL 获取「联系客户统计」数据
|
||||
GetUserBehaviorDataURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_user_behavior_data"
|
||||
// GetGroupChatStatURL 获取「群聊数据统计」数据 按群主聚合的方式
|
||||
GetGroupChatStatURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat/statistic"
|
||||
// GetGroupChatStatByDayURL 获取「群聊数据统计」数据 按自然日聚合的方式
|
||||
GetGroupChatStatByDayURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat/statistic_group_by_day"
|
||||
// getUserBehaviorDataURL 获取「联系客户统计」数据
|
||||
getUserBehaviorDataURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_user_behavior_data"
|
||||
// getGroupChatStatURL 获取「群聊数据统计」数据 按群主聚合的方式
|
||||
getGroupChatStatURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat/statistic"
|
||||
// getGroupChatStatByDayURL 获取「群聊数据统计」数据 按自然日聚合的方式
|
||||
getGroupChatStatByDayURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat/statistic_group_by_day"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -54,16 +54,13 @@ func (r *Client) GetUserBehaviorData(req *GetUserBehaviorRequest) ([]BehaviorDat
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", GetUserBehaviorDataURL, accessToken), string(jsonData))
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", getUserBehaviorDataURL, accessToken), string(jsonData))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result GetUserBehaviorResponse
|
||||
err = util.DecodeWithError(response, &result, "GetUserBehaviorData")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.BehaviorData, nil
|
||||
return result.BehaviorData, err
|
||||
}
|
||||
|
||||
type (
|
||||
@@ -120,16 +117,13 @@ func (r *Client) GetGroupChatStat(req *GetGroupChatStatRequest) (*GetGroupChatSt
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", GetGroupChatStatURL, accessToken), string(jsonData))
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", getGroupChatStatURL, accessToken), string(jsonData))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetGroupChatStatResponse{}
|
||||
err = util.DecodeWithError(response, result, "GetGroupChatStat")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
return result, err
|
||||
}
|
||||
|
||||
type (
|
||||
@@ -163,14 +157,11 @@ func (r *Client) GetGroupChatStatByDay(req *GetGroupChatStatByDayRequest) ([]Get
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", GetGroupChatStatByDayURL, accessToken), string(jsonData))
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", getGroupChatStatByDayURL, accessToken), string(jsonData))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result GetGroupChatStatByDayResponse
|
||||
err = util.DecodeWithError(response, &result, "GetGroupChatStatByDay")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.Items, nil
|
||||
return result.Items, err
|
||||
}
|
||||
|
||||
@@ -8,16 +8,24 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// GetCropTagURL 获取标签列表
|
||||
GetCropTagURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_corp_tag_list"
|
||||
// AddCropTagURL 添加标签
|
||||
AddCropTagURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_corp_tag"
|
||||
// EditCropTagURL 修改标签
|
||||
EditCropTagURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/edit_corp_tag"
|
||||
// DelCropTagURL 删除标签
|
||||
DelCropTagURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/del_corp_tag"
|
||||
// MarkCropTagURL 为客户打上、删除标签
|
||||
MarkCropTagURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/mark_tag"
|
||||
// getCropTagURL 获取标签列表
|
||||
getCropTagURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_corp_tag_list"
|
||||
// addCropTagURL 添加标签
|
||||
addCropTagURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_corp_tag"
|
||||
// editCropTagURL 修改标签
|
||||
editCropTagURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/edit_corp_tag"
|
||||
// delCropTagURL 删除标签
|
||||
delCropTagURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/del_corp_tag"
|
||||
// markCropTagURL 为客户打上、删除标签
|
||||
markCropTagURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/mark_tag"
|
||||
// getStrategyTagListURL 获取指定规则组下的企业客户标签
|
||||
getStrategyTagListURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_strategy_tag_list?access_token=%s"
|
||||
// addStrategyTagURL 为指定规则组创建企业客户标签
|
||||
addStrategyTagURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_strategy_tag?access_token=%s"
|
||||
// editStrategyTagURL 编辑指定规则组下的企业客户标签
|
||||
editStrategyTagURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/edit_strategy_tag?access_token=%s"
|
||||
// delStrategyTagURL 删除指定规则组下的企业客户标签
|
||||
delStrategyTagURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/del_strategy_tag?access_token=%s"
|
||||
)
|
||||
|
||||
// GetCropTagRequest 获取企业标签请求
|
||||
@@ -36,7 +44,7 @@ type GetCropTagListResponse struct {
|
||||
type TagGroup struct {
|
||||
GroupID string `json:"group_id"`
|
||||
GroupName string `json:"group_name"`
|
||||
CreateTime int `json:"create_time"`
|
||||
CreateTime int64 `json:"create_time"`
|
||||
GroupOrder int `json:"group_order"`
|
||||
Deleted bool `json:"deleted"`
|
||||
Tag []TagGroupTagItem `json:"tag"`
|
||||
@@ -46,7 +54,7 @@ type TagGroup struct {
|
||||
type TagGroupTagItem struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
CreateTime int `json:"create_time"`
|
||||
CreateTime int64 `json:"create_time"`
|
||||
Order int `json:"order"`
|
||||
Deleted bool `json:"deleted"`
|
||||
}
|
||||
@@ -63,16 +71,13 @@ func (r *Client) GetCropTagList(req GetCropTagRequest) ([]TagGroup, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", GetCropTagURL, accessToken), string(jsonData))
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", getCropTagURL, accessToken), string(jsonData))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result GetCropTagListResponse
|
||||
err = util.DecodeWithError(response, &result, "GetCropTagList")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.TagGroup, nil
|
||||
return result.TagGroup, err
|
||||
}
|
||||
|
||||
// AddCropTagRequest 添加企业标签请求
|
||||
@@ -109,16 +114,13 @@ func (r *Client) AddCropTag(req AddCropTagRequest) (*TagGroup, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", AddCropTagURL, accessToken), string(jsonData))
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", addCropTagURL, accessToken), string(jsonData))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result AddCropTagResponse
|
||||
err = util.DecodeWithError(response, &result, "AddCropTag")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &result.TagGroup, nil
|
||||
return &result.TagGroup, err
|
||||
}
|
||||
|
||||
// EditCropTagRequest 编辑客户企业标签请求
|
||||
@@ -141,7 +143,7 @@ func (r *Client) EditCropTag(req EditCropTagRequest) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", EditCropTagURL, accessToken), string(jsonData))
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", editCropTagURL, accessToken), string(jsonData))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -167,7 +169,7 @@ func (r *Client) DeleteCropTag(req DeleteCropTagRequest) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", DelCropTagURL, accessToken), string(jsonData))
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", delCropTagURL, accessToken), string(jsonData))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -195,9 +197,163 @@ func (r *Client) MarkTag(request MarkTagRequest) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", MarkCropTagURL, accessToken), string(jsonData))
|
||||
response, err = util.HTTPPost(fmt.Sprintf("%s?access_token=%v", markCropTagURL, accessToken), string(jsonData))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return util.DecodeWithCommonError(response, "MarkTag")
|
||||
}
|
||||
|
||||
// GetStrategyTagListRequest 获取指定规则组下的企业客户标签请求
|
||||
type GetStrategyTagListRequest struct {
|
||||
StrategyID int `json:"strategy_id"`
|
||||
TagID []string `json:"tag_id"`
|
||||
GroupID []string `json:"group_id"`
|
||||
}
|
||||
|
||||
// GetStrategyTagListResponse 获取指定规则组下的企业客户标签响应
|
||||
type GetStrategyTagListResponse struct {
|
||||
util.CommonError
|
||||
TagGroup []StrategyTagGroup `json:"tag_group"`
|
||||
}
|
||||
|
||||
// StrategyTagGroup 规则组下的企业标签组
|
||||
type StrategyTagGroup struct {
|
||||
GroupID string `json:"group_id"`
|
||||
GroupName string `json:"group_name"`
|
||||
CreateTime int64 `json:"create_time"`
|
||||
Order int `json:"order"`
|
||||
StrategyID int `json:"strategy_id"`
|
||||
Tag []StrategyTag `json:"tag"`
|
||||
}
|
||||
|
||||
// StrategyTag 规则组下的企业标签
|
||||
type StrategyTag struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
CreateTime int64 `json:"create_time"`
|
||||
Order int `json:"order"`
|
||||
}
|
||||
|
||||
// GetStrategyTagList 获取指定规则组下的企业客户标签
|
||||
// @see https://developer.work.weixin.qq.com/document/path/94882#%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E8%A7%84%E5%88%99%E7%BB%84%E4%B8%8B%E7%9A%84%E4%BC%81%E4%B8%9A%E5%AE%A2%E6%88%B7%E6%A0%87%E7%AD%BE
|
||||
func (r *Client) GetStrategyTagList(req *GetStrategyTagListRequest) (*GetStrategyTagListResponse, 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(getStrategyTagListURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetStrategyTagListResponse{}
|
||||
err = util.DecodeWithError(response, result, "GetStrategyTagList")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// AddStrategyTagRequest 为指定规则组创建企业客户标签请求
|
||||
type AddStrategyTagRequest struct {
|
||||
StrategyID int `json:"strategy_id"`
|
||||
GroupID string `json:"group_id"`
|
||||
GroupName string `json:"group_name"`
|
||||
Order int `json:"order"`
|
||||
Tag []AddStrategyTagRequestItem `json:"tag"`
|
||||
}
|
||||
|
||||
// AddStrategyTagRequestItem 为指定规则组创建企业客户标签请求条目
|
||||
type AddStrategyTagRequestItem struct {
|
||||
Name string `json:"name"`
|
||||
Order int `json:"order"`
|
||||
}
|
||||
|
||||
// AddStrategyTagResponse 为指定规则组创建企业客户标签响应
|
||||
type AddStrategyTagResponse struct {
|
||||
util.CommonError
|
||||
TagGroup AddStrategyTagResponseTagGroup `json:"tag_group"`
|
||||
}
|
||||
|
||||
// AddStrategyTagResponseTagGroup 为指定规则组创建企业客户标签响应标签组
|
||||
type AddStrategyTagResponseTagGroup struct {
|
||||
GroupID string `json:"group_id"`
|
||||
GroupName string `json:"group_name"`
|
||||
CreateTime int64 `json:"create_time"`
|
||||
Order int `json:"order"`
|
||||
Tag []AddStrategyTagResponseItem `json:"tag"`
|
||||
}
|
||||
|
||||
// AddStrategyTagResponseItem 标签组内的标签列表
|
||||
type AddStrategyTagResponseItem struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
CreateTime int64 `json:"create_time"`
|
||||
Order int `json:"order"`
|
||||
}
|
||||
|
||||
// AddStrategyTag 为指定规则组创建企业客户标签
|
||||
// @see https://developer.work.weixin.qq.com/document/path/94882#%E4%B8%BA%E6%8C%87%E5%AE%9A%E8%A7%84%E5%88%99%E7%BB%84%E5%88%9B%E5%BB%BA%E4%BC%81%E4%B8%9A%E5%AE%A2%E6%88%B7%E6%A0%87%E7%AD%BE
|
||||
func (r *Client) AddStrategyTag(req *AddStrategyTagRequest) (*AddStrategyTagResponse, 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(addStrategyTagURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &AddStrategyTagResponse{}
|
||||
err = util.DecodeWithError(response, result, "AddStrategyTag")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// EditStrategyTagRequest 编辑指定规则组下的企业客户标签请求
|
||||
type EditStrategyTagRequest struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Order int `json:"order"`
|
||||
}
|
||||
|
||||
// EditStrategyTag 编辑指定规则组下的企业客户标签
|
||||
// see https://developer.work.weixin.qq.com/document/path/94882#%E7%BC%96%E8%BE%91%E6%8C%87%E5%AE%9A%E8%A7%84%E5%88%99%E7%BB%84%E4%B8%8B%E7%9A%84%E4%BC%81%E4%B8%9A%E5%AE%A2%E6%88%B7%E6%A0%87%E7%AD%BE
|
||||
func (r *Client) EditStrategyTag(req *EditStrategyTagRequest) 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(editStrategyTagURL, accessToken), req); err != nil {
|
||||
return err
|
||||
}
|
||||
return util.DecodeWithCommonError(response, "EditStrategyTag")
|
||||
}
|
||||
|
||||
// DelStrategyTagRequest 删除指定规则组下的企业客户标签请求
|
||||
type DelStrategyTagRequest struct {
|
||||
TagID []string `json:"tag_id"`
|
||||
GroupID []string `json:"group_id"`
|
||||
}
|
||||
|
||||
// DelStrategyTag 删除指定规则组下的企业客户标签
|
||||
// see https://developer.work.weixin.qq.com/document/path/94882#%E5%88%A0%E9%99%A4%E6%8C%87%E5%AE%9A%E8%A7%84%E5%88%99%E7%BB%84%E4%B8%8B%E7%9A%84%E4%BC%81%E4%B8%9A%E5%AE%A2%E6%88%B7%E6%A0%87%E7%AD%BE
|
||||
func (r *Client) DelStrategyTag(req *DelStrategyTagRequest) 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(delStrategyTagURL, accessToken), req); err != nil {
|
||||
return err
|
||||
}
|
||||
return util.DecodeWithCommonError(response, "DelStrategyTag")
|
||||
}
|
||||
|
||||
277
work/externalcontact/transfer.go
Normal file
277
work/externalcontact/transfer.go
Normal file
@@ -0,0 +1,277 @@
|
||||
package externalcontact
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/silenceper/wechat/v2/util"
|
||||
)
|
||||
|
||||
const (
|
||||
// transferCustomerURL 分配在职成员的客户
|
||||
transferCustomerURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/transfer_customer?access_token=%s"
|
||||
// transferResultURL 查询客户接替状态
|
||||
transferResultURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/transfer_result?access_token=%s"
|
||||
// groupChatOnJobTransferURL 分配在职成员的客户群
|
||||
groupChatOnJobTransferURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat/onjob_transfer?access_token=%s"
|
||||
// getUnassignedListURL 获取待分配的离职成员列表
|
||||
getUnassignedListURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_unassigned_list?access_token=%s"
|
||||
// resignedTransferCustomerURL 分配离职成员的客户
|
||||
resignedTransferCustomerURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/resigned/transfer_customer?access_token=%s"
|
||||
// resignedTransferResultURL 查询离职客户接替状态
|
||||
resignedTransferResultURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/resigned/transfer_result?access_token=%s"
|
||||
// groupChatTransferURL 分配离职成员的客户群
|
||||
groupChatTransferURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat/transfer?access_token=%s"
|
||||
)
|
||||
|
||||
// TransferCustomerRequest 分配在职成员的客户请求
|
||||
type TransferCustomerRequest struct {
|
||||
HandoverUserID string `json:"handover_userid"`
|
||||
TakeoverUserID string `json:"takeover_userid"`
|
||||
ExternalUserID []string `json:"external_userid"`
|
||||
TransferSuccessMsg string `json:"transfer_success_msg"`
|
||||
}
|
||||
|
||||
// TransferCustomerResponse 分配在职成员的客户请求响应
|
||||
type TransferCustomerResponse struct {
|
||||
util.CommonError
|
||||
Customer []TransferCustomerItem `json:"customer"`
|
||||
}
|
||||
|
||||
// TransferCustomerItem 客户分配结果
|
||||
type TransferCustomerItem struct {
|
||||
ExternalUserID string `json:"external_userid"`
|
||||
ErrCode int `json:"errcode"`
|
||||
}
|
||||
|
||||
// TransferCustomer 分配在职成员的客户
|
||||
// see https://developer.work.weixin.qq.com/document/path/92125
|
||||
func (r *Client) TransferCustomer(req *TransferCustomerRequest) (*TransferCustomerResponse, 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(transferCustomerURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &TransferCustomerResponse{}
|
||||
err = util.DecodeWithError(response, result, "TransferCustomer")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// TransferResultRequest 查询客户接替状态请求
|
||||
type TransferResultRequest struct {
|
||||
HandoverUserID string `json:"handover_userid"`
|
||||
TakeoverUserID string `json:"takeover_userid"`
|
||||
Cursor string `json:"cursor"`
|
||||
}
|
||||
|
||||
// TransferResultResponse 查询客户接替状态响应
|
||||
type TransferResultResponse struct {
|
||||
util.CommonError
|
||||
Customer []TransferResultItem `json:"customer"`
|
||||
NextCursor string `json:"next_cursor"`
|
||||
}
|
||||
|
||||
// TransferResultItem 客户接替状态
|
||||
type TransferResultItem struct {
|
||||
ExternalUserID string `json:"external_userid"`
|
||||
Status int `json:"status"`
|
||||
TakeoverTime int64 `json:"takeover_time"`
|
||||
}
|
||||
|
||||
// TransferResult 查询客户接替状态
|
||||
// see https://developer.work.weixin.qq.com/document/path/94088
|
||||
func (r *Client) TransferResult(req *TransferResultRequest) (*TransferResultResponse, 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(transferResultURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &TransferResultResponse{}
|
||||
err = util.DecodeWithError(response, result, "TransferResult")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// GroupChatOnJobTransferRequest 分配在职成员的客户群请求
|
||||
type GroupChatOnJobTransferRequest struct {
|
||||
ChatIDList []string `json:"chat_id_list"`
|
||||
NewOwner string `json:"new_owner"`
|
||||
}
|
||||
|
||||
// GroupChatOnJobTransferResponse 分配在职成员的客户群响应
|
||||
type GroupChatOnJobTransferResponse struct {
|
||||
util.CommonError
|
||||
FailedChatList []FailedChat `json:"failed_chat_list"`
|
||||
}
|
||||
|
||||
// FailedChat 没能成功继承的群
|
||||
type FailedChat struct {
|
||||
ChatID string `json:"chat_id"`
|
||||
ErrCode int `json:"errcode"`
|
||||
ErrMsg string `json:"errmsg"`
|
||||
}
|
||||
|
||||
// GroupChatOnJobTransfer 分配在职成员的客户群
|
||||
// see https://developer.work.weixin.qq.com/document/path/95703
|
||||
func (r *Client) GroupChatOnJobTransfer(req *GroupChatOnJobTransferRequest) (*GroupChatOnJobTransferResponse, 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(groupChatOnJobTransferURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GroupChatOnJobTransferResponse{}
|
||||
err = util.DecodeWithError(response, result, "GroupChatOnJobTransfer")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// GetUnassignedListRequest 获取待分配的离职成员列表请求
|
||||
type GetUnassignedListRequest struct {
|
||||
Cursor string `json:"cursor"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// GetUnassignedListResponse 获取待分配的离职成员列表响应
|
||||
type GetUnassignedListResponse struct {
|
||||
util.CommonError
|
||||
Info []UnassignedListInfo `json:"info"`
|
||||
IsLast bool `json:"is_last"`
|
||||
NextCursor string `json:"next_cursor"`
|
||||
}
|
||||
|
||||
// UnassignedListInfo 离职成员信息
|
||||
type UnassignedListInfo struct {
|
||||
HandoverUserID string `json:"handover_userid"`
|
||||
ExternalUserID string `json:"external_userid"`
|
||||
DimissionTime int64 `json:"dimission_time"`
|
||||
}
|
||||
|
||||
// GetUnassignedList 获取待分配的离职成员列表
|
||||
// see https://developer.work.weixin.qq.com/document/path/92124
|
||||
func (r *Client) GetUnassignedList(req *GetUnassignedListRequest) (*GetUnassignedListResponse, 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(getUnassignedListURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GetUnassignedListResponse{}
|
||||
err = util.DecodeWithError(response, result, "GetUnassignedList")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// ResignedTransferCustomerRequest 分配离职成员的客户请求
|
||||
type ResignedTransferCustomerRequest struct {
|
||||
HandoverUserID string `json:"handover_userid"`
|
||||
TakeoverUserID string `json:"takeover_userid"`
|
||||
ExternalUserID []string `json:"external_userid"`
|
||||
}
|
||||
|
||||
// ResignedTransferCustomerResponse 分配离职成员的客户响应
|
||||
type ResignedTransferCustomerResponse struct {
|
||||
util.CommonError
|
||||
Customer []TransferCustomerItem `json:"customer"`
|
||||
}
|
||||
|
||||
// ResignedTransferCustomer 分配离职成员的客户
|
||||
// see https://developer.work.weixin.qq.com/document/path/94081
|
||||
func (r *Client) ResignedTransferCustomer(req *ResignedTransferCustomerRequest) (*ResignedTransferCustomerResponse, 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(resignedTransferCustomerURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &ResignedTransferCustomerResponse{}
|
||||
err = util.DecodeWithError(response, result, "ResignedTransferCustomer")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// ResignedTransferResultRequest 查询离职客户接替状态请求
|
||||
type ResignedTransferResultRequest struct {
|
||||
HandoverUserID string `json:"handover_userid"`
|
||||
TakeoverUserID string `json:"takeover_userid"`
|
||||
Cursor string `json:"cursor"`
|
||||
}
|
||||
|
||||
// ResignedTransferResultResponse 查询离职客户接替状态响应
|
||||
type ResignedTransferResultResponse struct {
|
||||
util.CommonError
|
||||
Customer []TransferResultItem `json:"customer"`
|
||||
NextCursor string `json:"next_cursor"`
|
||||
}
|
||||
|
||||
// ResignedTransferResult 查询离职客户接替状态
|
||||
// see https://developer.work.weixin.qq.com/document/path/94082
|
||||
func (r *Client) ResignedTransferResult(req *ResignedTransferResultRequest) (*ResignedTransferResultResponse, 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(resignedTransferResultURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &ResignedTransferResultResponse{}
|
||||
err = util.DecodeWithError(response, result, "ResignedTransferResult")
|
||||
return result, err
|
||||
}
|
||||
|
||||
// GroupChatTransferRequest 分配离职成员的客户群请求
|
||||
type GroupChatTransferRequest struct {
|
||||
ChatIDList []string `json:"chat_id_list"`
|
||||
NewOwner string `json:"new_owner"`
|
||||
}
|
||||
|
||||
// GroupChatTransferResponse 分配离职成员的客户群响应
|
||||
type GroupChatTransferResponse struct {
|
||||
util.CommonError
|
||||
FailedChatList []FailedChat `json:"failed_chat_list"`
|
||||
}
|
||||
|
||||
// GroupChatTransfer 分配离职成员的客户群
|
||||
// see https://developer.work.weixin.qq.com/document/path/92127
|
||||
func (r *Client) GroupChatTransfer(req *GroupChatTransferRequest) (*GroupChatTransferResponse, 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(groupChatTransferURL, accessToken), req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &GroupChatTransferResponse{}
|
||||
err = util.DecodeWithError(response, result, "GroupChatTransfer")
|
||||
return result, err
|
||||
}
|
||||
Reference in New Issue
Block a user