From 44b09c7c3bdbb0aedaae3fd77496d35459bfa97f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E6=99=B6?= Date: Wed, 16 Oct 2024 16:11:03 +0800 Subject: [PATCH 1/2] feat(media): add getTempFile api (#801) add getTempFile api --- work/material/media.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/work/material/media.go b/work/material/media.go index b9647adc..c3c8e0c3 100644 --- a/work/material/media.go +++ b/work/material/media.go @@ -14,6 +14,8 @@ const ( uploadTempFile = "https://qyapi.weixin.qq.com/cgi-bin/media/upload?access_token=%s&type=%s" // uploadAttachment 上传附件资源 uploadAttachment = "https://qyapi.weixin.qq.com/cgi-bin/media/upload_attachment?access_token=%s&media_type=%s&attachment_type=%d" + // getTempFile 获取临时素材 + getTempFile = "https://qyapi.weixin.qq.com/cgi-bin/media/get?access_token=%s&media_id=%s" ) // UploadImgResponse 上传图片响应 @@ -148,3 +150,21 @@ func (r *Client) UploadAttachmentFromReader(filename, mediaType string, reader i err = util.DecodeWithError(response, result, "UploadAttachment") return result, err } + +// GetTempFile 获取临时素材 +// @see https://developer.work.weixin.qq.com/document/path/90254 +func (r *Client) GetTempFile(mediaID string) ([]byte, error) { + var ( + accessToken string + err error + ) + if accessToken, err = r.GetAccessToken(); err != nil { + return nil, err + } + url := fmt.Sprintf(getTempFile, accessToken, mediaID) + response, err := util.HTTPGet(url) + if err != nil { + return nil, err + } + return response, nil +} From 990ba6ede9cf61711201ee6b837ee1efc70cf1b9 Mon Sep 17 00:00:00 2001 From: markwang Date: Wed, 16 Oct 2024 16:11:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E4=BC=81=E4=B8=9A=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1-=E6=8E=A5=E5=BE=85=E4=BA=BA=E5=91=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=A2=9E=E5=8A=A0=E9=83=A8=E9=97=A8ID=E5=8F=8A?= =?UTF-8?q?=E5=81=9C=E6=AD=A2=E6=8E=A5=E5=BE=85=E5=AD=90=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=20(#800)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- work/kf/servicer.go | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/work/kf/servicer.go b/work/kf/servicer.go index 5c34efc9..8e64c3ea 100644 --- a/work/kf/servicer.go +++ b/work/kf/servicer.go @@ -18,20 +18,23 @@ const ( // ReceptionistOptions 添加接待人员请求参数 type ReceptionistOptions struct { - OpenKFID string `json:"open_kfid"` // 客服帐号ID - UserIDList []string `json:"userid_list"` // 接待人员userid列表。第三方应用填密文userid,即open_userid 可填充个数:1 ~ 100。超过100个需分批调用。 + OpenKFID string `json:"open_kfid"` // 客服帐号ID + UserIDList []string `json:"userid_list"` // 接待人员userid列表。第三方应用填密文userid,即open_userid 可填充个数:1 ~ 100。超过100个需分批调用。 + DepartmentIDList []int `json:"department_id_list"` // 接待人员部门id列表 可填充个数:0 ~ 100。超过100个需分批调用。 } // ReceptionistSchema 添加接待人员响应内容 type ReceptionistSchema struct { util.CommonError ResultList []struct { - UserID string `json:"userid"` + UserID string `json:"userid"` + DepartmentID int `json:"department_id"` util.CommonError } `json:"result_list"` } // ReceptionistAdd 添加接待人员 +// @see https://developer.work.weixin.qq.com/document/path/94646 func (r *Client) ReceptionistAdd(options ReceptionistOptions) (info ReceptionistSchema, err error) { var ( accessToken string @@ -49,10 +52,11 @@ func (r *Client) ReceptionistAdd(options ReceptionistOptions) (info Receptionist if info.ErrCode != 0 { return info, NewSDKErr(info.ErrCode, info.ErrMsg) } - return info, nil + return } // ReceptionistDel 删除接待人员 +// @see https://developer.work.weixin.qq.com/document/path/94647 func (r *Client) ReceptionistDel(options ReceptionistOptions) (info ReceptionistSchema, err error) { var ( accessToken string @@ -72,19 +76,22 @@ func (r *Client) ReceptionistDel(options ReceptionistOptions) (info Receptionist if info.ErrCode != 0 { return info, NewSDKErr(info.ErrCode, info.ErrMsg) } - return info, nil + return } // ReceptionistListSchema 获取接待人员列表响应内容 type ReceptionistListSchema struct { util.CommonError ReceptionistList []struct { - UserID string `json:"userid"` // 接待人员的userid。第三方应用获取到的为密文userid,即open_userid - Status int `json:"status"` // 接待人员的接待状态。0:接待中,1:停止接待。第三方应用需具有“管理帐号、分配会话和收发消息”权限才可获取 + UserID string `json:"userid"` // 接待人员的userid。第三方应用获取到的为密文userid,即open_userid + Status int `json:"status"` // 接待人员的接待状态。0:接待中,1:停止接待。第三方应用需具有“管理帐号、分配会话和收发消息”权限才可获取 + DepartmentID int `json:"department_id"` // 接待人员部门的id + StopType int `json:"stop_type"` // 接待人员的接待状态为「停止接待」的子类型。0:停止接待,1:暂时挂起 } `json:"servicer_list"` } // ReceptionistList 获取接待人员列表 +// @see https://developer.work.weixin.qq.com/document/path/94645 func (r *Client) ReceptionistList(kfID string) (info ReceptionistListSchema, err error) { var ( accessToken string @@ -104,5 +111,5 @@ func (r *Client) ReceptionistList(kfID string) (info ReceptionistListSchema, err if info.ErrCode != 0 { return info, NewSDKErr(info.ErrCode, info.ErrMsg) } - return info, nil + return }