servicer list

This commit is contained in:
jiangyong27 2024-01-23 21:35:31 +08:00
parent c7d7be7320
commit 70ce423182
1 changed files with 27 additions and 0 deletions

View File

@ -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{})