From 86e036a55b22214a705bf374f332a24adb7eea5c Mon Sep 17 00:00:00 2001 From: markwang <2951177317@qq.com> Date: Tue, 23 Aug 2022 22:07:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E5=BE=AE=E4=BF=A1-[=E8=81=94?= =?UTF-8?q?=E7=B3=BB=E6=88=91]=E6=96=B9=E5=BC=8F=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E3=80=81=E5=88=A0=E9=99=A4=20(#606)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/api/work.md | 4 +- work/externalcontact/contact_way.go | 77 +++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/doc/api/work.md b/doc/api/work.md index 2843a7f..43061b6 100644 --- a/doc/api/work.md +++ b/doc/api/work.md @@ -70,6 +70,8 @@ host: https://qyapi.weixin.qq.com/ | 配置客户联系「联系我」方式 | POST | /cgi-bin/externalcontact/add_contact_way | YES | (r *Client) AddContactWay | MARKWANG | | 获取企业已配置的「联系我」方式 | POST | /cgi-bin/externalcontact/get_contact_way | YES | (r *Client) GetContactWay | MARKWANG | | 更新企业已配置的「联系我」方式 | POST | /cgi-bin/externalcontact/update_contact_way | YES | (r *Client) UpdateContactWay | MARKWANG | +| 获取企业已配置的「联系我」列表 | POST | /cgi-bin/externalcontact/list_contact_way | YES | (r *Client) ListContactWay | MARKWANG | +| 删除企业已配置的「联系我」方式 | POST | /cgi-bin/externalcontact/del_contact_way | YES | (r *Client) DelContactWay | MARKWANG | ## 通讯录管理 [官方文档](https://developer.work.weixin.qq.com/document/path/95350/90200) @@ -83,5 +85,3 @@ host: https://qyapi.weixin.qq.com/ ## 应用管理 TODO - - diff --git a/work/externalcontact/contact_way.go b/work/externalcontact/contact_way.go index 9b5d535..5afdc19 100644 --- a/work/externalcontact/contact_way.go +++ b/work/externalcontact/contact_way.go @@ -13,6 +13,10 @@ const ( 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 ( @@ -196,3 +200,76 @@ func (r *Client) UpdateContactWay(req *UpdateContactWayRequest) (*UpdateContactW } return result, nil } + +type ( + //ListContactWayRequest 获取企业已配置的「联系我」列表请求 + ListContactWayRequest struct { + StartTime int `json:"start_time"` + EndTime int `json:"end_time"` + Cursor string `json:"cursor"` + Limit int `json:"limit"` + } + //ListContactWayResponse 获取企业已配置的「联系我」列表响应 + ListContactWayResponse struct { + util.CommonError + ContactWay []*ContactWayForList `json:"contact_way"` + NextCursor string `json:"next_cursor"` + } + // ContactWayForList 「联系我」配置 + ContactWayForList struct { + ConfigID string `json:"config_id"` + } +) + +// ListContactWay 获取企业已配置的「联系我」列表 +// see https://developer.work.weixin.qq.com/document/path/92228 +func (r *Client) ListContactWay(req *ListContactWayRequest) (*ListContactWayResponse, 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(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 +} + +type ( + // DelContactWayRequest 删除企业已配置的「联系我」方式请求 + DelContactWayRequest struct { + ConfigID string `json:"config_id"` + } + // DelContactWayResponse 删除企业已配置的「联系我」方式响应 + DelContactWayResponse struct { + util.CommonError + } +) + +// DelContactWay 删除企业已配置的「联系我」方式 +// see https://developer.work.weixin.qq.com/document/path/92228 +func (r *Client) DelContactWay(req *DelContactWayRequest) (*DelContactWayResponse, 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(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 +}