Skip to content

Commit

Permalink
Merge branch 'silenceper:v2' into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
hb1707 authored Nov 15, 2024
2 parents 961d560 + 990ba6e commit d28c61a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
23 changes: 15 additions & 8 deletions work/kf/servicer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
}
20 changes: 20 additions & 0 deletions work/material/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 上传图片响应
Expand Down Expand Up @@ -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
}

0 comments on commit d28c61a

Please sign in to comment.