diff --git a/work/kf/servicer.go b/work/kf/servicer.go index 5c34efc99..8e64c3eaa 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 } diff --git a/work/material/media.go b/work/material/media.go index b9647adc3..c3c8e0c34 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 +}