Skip to content

Commit

Permalink
feat(wecom): add customer service msg struct (#32)
Browse files Browse the repository at this point in the history
Co-authored-by: Walle <walle@artisan-cloud.com>
  • Loading branch information
WalleV and Walle authored Sep 29, 2021
1 parent 83af2a0 commit f5dc216
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 11 deletions.
16 changes: 16 additions & 0 deletions src/work/accountService/customer/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package customer
import (
"github.com/ArtisanCloud/go-libs/object"
"github.com/ArtisanCloud/power-wechat/src/kernel"
"github.com/ArtisanCloud/power-wechat/src/kernel/power"
response2 "github.com/ArtisanCloud/power-wechat/src/kernel/response"
"github.com/ArtisanCloud/power-wechat/src/work/accountService/customer/request"
"github.com/ArtisanCloud/power-wechat/src/work/accountService/customer/response"
Expand Down Expand Up @@ -54,3 +55,18 @@ func (comp *Client) UpgradeService(options *request.RequestUpgradeService) (*res

return result, err
}

// 为客户取消推荐
// https://work.weixin.qq.com/api/doc/90000/90135/94674
func (comp *Client) CancelUpgradeService(openKFID, externalUserID string) (*response2.ResponseWork, error) {

result := &response2.ResponseWork{}
options := &power.StringMap{
"open_kfid": openKFID,
"external_userid": externalUserID,
}

_, err := comp.HttpPostJson("cgi-bin/kf/customer/cancel_upgrade_service", options, nil, nil, result)

return result, err
}
22 changes: 15 additions & 7 deletions src/work/accountService/customer/request/requestUpgradeService.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package request

import "github.com/ArtisanCloud/power-wechat/src/kernel/power"

type RequestUpgradeService struct {
OpenKFID string `json:"open_kfid"`
ExternalUserID string `json:"external_userid"`
Type int `json:"type"`
Member *power.StringMap `json:"member"`
GroupChat *power.StringMap `json:"groupchat"`
OpenKFID string `json:"open_kfid"`
ExternalUserID string `json:"external_userid"`
Type int `json:"type"`
Member *RequestUpgradeServiceMember `json:"member,omitempty"`
GroupChat *RequestUpgradeServiceGroupChat `json:"groupchat,omitempty"`
}

type RequestUpgradeServiceMember struct {
UserID string `json:"userid"`
Wording string `json:"wording"`
}

type RequestUpgradeServiceGroupChat struct {
ChatID string `json:"chat_id"`
Wording string `json:"wording"`
}
6 changes: 3 additions & 3 deletions src/work/accountService/message/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package message
import (
"github.com/ArtisanCloud/go-libs/object"
"github.com/ArtisanCloud/power-wechat/src/kernel"
"github.com/ArtisanCloud/power-wechat/src/kernel/power"
"github.com/ArtisanCloud/power-wechat/src/work/accountService/message/request"
"github.com/ArtisanCloud/power-wechat/src/work/accountService/message/response"
)

Expand Down Expand Up @@ -36,7 +36,7 @@ func (comp *Client) SyncMsg(cursor string, token string, limit int) (*response.R

// 发送消息
// https://work.weixin.qq.com/api/doc/90000/90135/90236
func (comp *Client) SendMsg(messages *power.HashMap) (*response.ResponseAccountServiceSendMsg, error) {
func (comp *Client) SendMsg(messages *request.RequestAccountServiceSendMsg) (*response.ResponseAccountServiceSendMsg, error) {

result := &response.ResponseAccountServiceSendMsg{}

Expand All @@ -47,7 +47,7 @@ func (comp *Client) SendMsg(messages *power.HashMap) (*response.ResponseAccountS

// 发送消息
// https://work.weixin.qq.com/api/doc/90000/90135/95122
func (comp *Client) SendMsgOnEvent(messages *power.HashMap) (*response.ResponseAccountServiceSendMsgOnEvent, error) {
func (comp *Client) SendMsgOnEvent(messages *request.RequestAccountServiceSendMsgOnEvent) (*response.ResponseAccountServiceSendMsgOnEvent, error) {

result := &response.ResponseAccountServiceSendMsgOnEvent{}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package request

type RequestAccountServiceSendMsg struct {
ToUser string `json:"touser"`
OpenKfid string `json:"open_kfid"`
MsgID string `json:"msgid"`
MsgType string `json:"msgtype"`
Text RequestAccountServiceMsgText `json:"text,omitempty"`
Image RequestAccountServiceMsgImage `json:"image,omitempty"`
Voice RequestAccountServiceMsgVoice `json:"voice,omitempty"`
File RequestAccountServiceMsgFile `json:"file,omitempty"`
Link RequestAccountServiceMsgLink `json:"link,omitempty"`
MiniProgram RequestAccountServiceMsgMiniProgram `json:"miniprogram,omitempty"`
Menu RequestAccountServiceMsgMenu `json:"msgmenu,omitempty"`
Location RequestAccountServiceMsgLocation `json:"location,omitempty"`
}

type RequestAccountServiceMsgText struct {
Content string `json:"content"`
}

type RequestAccountServiceMsgImage struct {
MediaID string `json:"media_id"`
}

type RequestAccountServiceMsgVoice struct {
MediaID string `json:"media_id"`
}

type RequestAccountServiceMsgFile struct {
MediaID string `json:"media_id"`
}

type RequestAccountServiceMsgLink struct {
Title string `json:"title"`
Desc string `json:"desc"`
Url string `json:"url"`
ThumbMediaId string `json:"thumb_media_id"`
}

type RequestAccountServiceMsgMiniProgram struct {
AppId string `json:"appid"`
Title string `json:"title"`
ThumbMediaID string `json:"thumb_media_id"`
PagePath string `json:"pagepath"`
}

type RequestAccountServiceMsgMenu struct {
HeadContent string `json:"head_content"`
TailContent string `json:"tail_content,omitempty"`
List []RequestAccountServiceMsgMenuList `json:"list,omitempty"`
}
type RequestAccountServiceMsgMenuList struct {
Click RequestAccountServiceMsgMenuListClick `json:"click,omitempty"`
View RequestAccountServiceMsgMenuListView `json:"view,omitempty"`
MiniProgram RequestAccountServiceMsgMenuListMiniProgram `json:"miniprogram,omitempty"`
}
type RequestAccountServiceMsgMenuListClick struct {
ID string `json:"id"`
Content string `json:"content"`
}
type RequestAccountServiceMsgMenuListView struct {
Url string `json:"url"`
Content string `json:"content"`
}
type RequestAccountServiceMsgMenuListMiniProgram struct {
AppID string `json:"appid"`
PagePath string `json:"pagepath"`
Content string `json:"content"`
}

type RequestAccountServiceMsgLocation struct {
Name string `json:"name"`
Address string `json:"address"`
Latitude int `json:"latitude"`
Longitude int `json:"longitude"`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package request

type RequestAccountServiceSendMsgOnEvent struct {
Code string `json:"code"`
MsgID string `json:"msgid"`
MsgType string `json:"msgtype"`
Text RequestAccountServiceMsgText `json:"text,omitempty"`
Menu RequestAccountServiceMsgMenu `json:"msgmenu,omitempty"`
}
2 changes: 1 addition & 1 deletion src/work/accountService/serviceState/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (comp *Client) Get(openKFID string, externalUserID string) (*response.Respo

// 变更会话状态
// https://work.weixin.qq.com/api/doc/90000/90135/94669
func (comp *Client) Trans(openKFID string, externalUserID string, serviceState string, servicerUserID string ) (*response2.ResponseWork, error) {
func (comp *Client) Trans(openKFID string, externalUserID string, serviceState int, servicerUserID string ) (*response2.ResponseWork, error) {

result := &response2.ResponseWork{}

Expand Down

0 comments on commit f5dc216

Please sign in to comment.