From 70ce423182e3591652a59053da725dac53316541 Mon Sep 17 00:00:00 2001 From: jiangyong27 Date: Tue, 23 Jan 2024 21:35:31 +0800 Subject: [PATCH] servicer list --- qyweixin/app_customer.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/qyweixin/app_customer.go b/qyweixin/app_customer.go index 2bf5436..dd02fb5 100644 --- a/qyweixin/app_customer.go +++ b/qyweixin/app_customer.go @@ -25,6 +25,10 @@ type CustomerMessage struct { SyncTime int64 Content string } +type CustomerServicer struct { + Userid string + Status int +} type CustomerState struct { State int Servicer string @@ -63,6 +67,29 @@ func (a *AppCustomer) AccountList() ([]*CustomerAccount, error) { return accounts, nil } +func (a *AppCustomer) ServicerList(openKfid string) ([]*CustomerServicer, error) { + reqUrl := fmt.Sprintf("https://qyapi.weixin.qq.com/cgi-bin/kf/service_state/trans?access_token=%s&open_kfid=%s", a.GetToken(), openKfid) + + rspBody, err := util.HttpGet(reqUrl, nil) + if err != nil { + return nil, err + } + result, err := a.GetResult(rspBody) + if err != nil { + return nil, err + } + resultList := make([]*CustomerServicer, 0) + servicerList := cast.ToSlice(result["servicer_list"]) + for _, s := range servicerList { + serv := cast.ToStringMap(s) + r := new(CustomerServicer) + r.Userid = cast.ToString(serv["userid"]) + r.Status = cast.ToInt(serv["status"]) + resultList = append(resultList, r) + } + return resultList, nil +} + func (a *AppCustomer) SetCustomerState(openKfid, externalUserid string, state *CustomerState) error { reqUrl := fmt.Sprintf("https://qyapi.weixin.qq.com/cgi-bin/kf/service_state/trans?access_token=%s", a.GetToken()) params := make(map[string]interface{})