Skip to content

Commit

Permalink
feat: add GroupChatJoinWay AppchatUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
Nottwoc committed Aug 20, 2023
1 parent c8009c3 commit af938e8
Show file tree
Hide file tree
Showing 8 changed files with 249 additions and 3 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ CI 会在 `go1.17` 和 Go 的当前稳定版本、上一个稳定版本上跑测
* [x] 通讯录管理 (**部分支持**,见下)
* [x] 客户联系 (**大部分支持**,见下)
* [ ] 应用管理
* [x] 消息发送 (除修改群聊会话外全部支持)
* [x] 消息发送 (全部支持)
* [x] 消息接收
* [x] 素材管理 (**支持上传**, 见下)
* [x] OA (**大部分支持**,见下)
Expand Down Expand Up @@ -134,11 +134,16 @@ CI 会在 `go1.17` 和 Go 的当前稳定版本、上一个稳定版本上跑测
* [x] 企业服务人员管理
- [x] 获取配置了客户联系功能的成员列表
- [x] 客户联系「联系我」管理
- [x] 客户群「加入群聊」管理
* [x] 客户管理
- [x] 获取客户列表
- [x] 获取客户详情
- [x] 批量获取客户详情
- [x] 修改客户备注信息
* [x] 客户群管理
- [x] 获取客户群列表
- [ ] 获取客户群详情
- [ ] 客户群opengid转换
* [x] 在职继承
- [x] 分配在职成员的客户
- [x] 查询客户接替状态
Expand Down Expand Up @@ -198,7 +203,7 @@ CI 会在 `go1.17` 和 Go 的当前稳定版本、上一个稳定版本上跑测
* [x] 接收消息
* [x] 发送消息到群聊会话
- [x] 创建群聊会话
- [ ] 修改群聊会话
- [x] 修改群聊会话
- [x] 获取群聊会话
- [x] 应用推送消息

Expand Down
70 changes: 70 additions & 0 deletions apis.md.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions appchat.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ func (c *WorkwxApp) CreateAppchat(chatInfo *ChatInfo) (chatID string, err error)
return resp.ChatID, nil
}

// UpdateAppchat 修改群聊会话
func (c *WorkwxApp) UpdateAppchat(chatInfo ChatInfo, addMemberUserIDs, delMemberUserIDs []string) (err error) {
_, err = c.execAppchatUpdate(reqAppchatUpdate{
ChatInfo: chatInfo,
AddMemberUserIDs: addMemberUserIDs,
DelMemberUserIDs: delMemberUserIDs,
})
if err != nil {
return err
}
return nil
}

// GetAppchat 获取群聊会话
func (c *WorkwxApp) GetAppchat(chatID string) (*ChatInfo, error) {
resp, err := c.execAppchatGet(reqAppchatGet{
Expand Down
6 changes: 5 additions & 1 deletion docs/apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Name|Request Type|Response Type|Access Token|URL|Doc
`execAppchatListGet`|`reqAppchatList`|`respAppchatList`|+|`POST /cgi-bin/externalcontact/groupchat/list`|[获取客户群列表](https://developer.work.weixin.qq.com/document/path/92120)
`execAppchatInfoGet`|`reqAppchatInfo`|`respAppchatInfo`|+|`POST /cgi-bin/externalcontact/groupchat/get`|[获取客户群详细](https://developer.work.weixin.qq.com/document/path/92122)
`execAppchatCreate`|`reqAppchatCreate`|`respAppchatCreate`|+|`POST /cgi-bin/appchat/create`|[创建群聊会话](https://work.weixin.qq.com/api/doc#90000/90135/90245)
`execAppchatUpdate`|TODO|TODO|+|`POST /cgi-bin/appchat/update`|[修改群聊会话](https://work.weixin.qq.com/api/doc#90000/90135/90246)
`execAppchatUpdate`|`reqAppchatUpdate`|`respAppchatUpdate`|+|`POST /cgi-bin/appchat/update`|[修改群聊会话](https://work.weixin.qq.com/api/doc#90000/90135/90246)
`execAppchatGet`|`reqAppchatGet`|`respAppchatGet`|+|`GET /cgi-bin/appchat/get`|[获取群聊会话](https://work.weixin.qq.com/api/doc#90000/90135/90247)
`execMessageSend`|`reqMessage`|`respMessageSend`|+|`POST /cgi-bin/message/send`|[发送应用消息](https://work.weixin.qq.com/api/doc#90000/90135/90236)
`execAppchatSend`|`reqMessage`|`respMessageSend`|+|`POST /cgi-bin/appchat/send`|[应用推送消息](https://work.weixin.qq.com/api/doc#90000/90135/90248)
Expand Down Expand Up @@ -198,6 +198,10 @@ Name|Request Type|Response Type|Access Token|URL|Doc
`execUpdateContactWayExternalContact`|`reqUpdateContactWayExternalContact`|`respUpdateContactWayExternalContact`|+|`POST /cgi-bin/externalcontact/update_contact_way`|[更新企业已配置的「联系我」成员配置](https://developer.work.weixin.qq.com/document/path/92572#%E6%9B%B4%E6%96%B0%E4%BC%81%E4%B8%9A%E5%B7%B2%E9%85%8D%E7%BD%AE%E7%9A%84%E3%80%8C%E8%81%94%E7%B3%BB%E6%88%91%E3%80%8D%E6%96%B9%E5%BC%8F)
`execDelContactWayExternalContact`|`reqDelContactWayExternalContact`|`respDelContactWayExternalContact`|+|`POST /cgi-bin/externalcontact/del_contact_way`|[删除企业已配置的「联系我」方式](https://developer.work.weixin.qq.com/document/path/92572#%E5%88%A0%E9%99%A4%E4%BC%81%E4%B8%9A%E5%B7%B2%E9%85%8D%E7%BD%AE%E7%9A%84%E3%80%8C%E8%81%94%E7%B3%BB%E6%88%91%E3%80%8D%E6%96%B9%E5%BC%8F)
`execCloseTempChatExternalContact`|`reqCloseTempChatExternalContact`|`respCloseTempChatExternalContact`|+|`POST /cgi-bin/externalcontact/close_temp_chat`|[结束临时会话](https://developer.work.weixin.qq.com/document/path/92572#%E7%BB%93%E6%9D%9F%E4%B8%B4%E6%97%B6%E4%BC%9A%E8%AF%9D)
`execAddGroupChatJoinWayExternalContact`|`reqAddGroupChatJoinWayExternalContact`|`respAddGroupChatJoinWayExternalContact`|+|`POST /cgi-bin/externalcontact/groupchat/add_join_way`|[配置客户群「加入群聊」方式](https://developer.work.weixin.qq.com/document/path/92229#%E9%85%8D%E7%BD%AE%E5%AE%A2%E6%88%B7%E7%BE%A4%E8%BF%9B%E7%BE%A4%E6%96%B9%E5%BC%8F)
`execGetGroupChatJoinWayExternalContact`|`reqGetGroupChatJoinWayExternalContact`|`respGetGroupChatJoinWayExternalContact`|+|`POST /cgi-bin/externalcontact/groupchat/get_join_way`|[获取企业已配置的客户群「加入群聊」方式](https://developer.work.weixin.qq.com/document/path/92229#%E8%8E%B7%E5%8F%96%E5%AE%A2%E6%88%B7%E7%BE%A4%E8%BF%9B%E7%BE%A4%E6%96%B9%E5%BC%8F%E9%85%8D%E7%BD%AE)
`execUpdateGroupChatJoinWayExternalContact`|`reqUpdateGroupChatJoinWayExternalContact`|`respUpdateGroupChatJoinWayExternalContact`|+|`POST /cgi-bin/externalcontact/groupchat/update_join_way`|[更新企业已配置的客户群「加入群聊」方式](https://developer.work.weixin.qq.com/document/path/92229#%E8%8E%B7%E5%8F%96%E5%AE%A2%E6%88%B7%E7%BE%A4%E8%BF%9B%E7%BE%A4%E6%96%B9%E5%BC%8F%E9%85%8D%E7%BD%AE)
`execDelGroupChatJoinWayExternalContact`|`reqDelGroupChatJoinWayExternalContact`|`respDelGroupChatJoinWayExternalContact`|+|`POST /cgi-bin/externalcontact/groupchat/del_join_way`|[删除企业已配置的客户群「加入群聊」方式](https://developer.work.weixin.qq.com/document/path/92229#%E5%88%A0%E9%99%A4%E5%AE%A2%E6%88%B7%E7%BE%A4%E8%BF%9B%E7%BE%A4%E6%96%B9%E5%BC%8F%E9%85%8D%E7%BD%AE)

# 在职继承

Expand Down
12 changes: 12 additions & 0 deletions docs/external_contact.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,18 @@ Name|JSON|Type|Doc
`UnionID`|`unionid`|`string`| 可进行临时会话的客户UnionID,该参数仅在is_temp为true时有效,如不指定则不进行限制
`Conclusions`|`conclusions`|`Conclusions`| 结束语,会话结束时自动发送给客户,可参考“结束语定义”,仅在is_temp为true时有效,<https://developer.work.weixin.qq.com/document/path/92572#%E7%BB%93%E6%9D%9F%E8%AF%AD%E5%AE%9A%E4%B9%89>

### `ExternalGroupChatJoinWay` 配置客户群「加入群聊」方式

Name|JSON|Type|Doc
:---|:---|:---|:--
`Scene`|`scene`|`int`| 场景,1 - 群的小程序插件,2 - 群的二维码插件
`Remark`|`remark`|`string`| 联系方式的备注信息,用于助记,超过30个字符将被截断
`AutoCreateRoom`|`auto_create_room`|`int`| 当群满了后,是否自动新建群。0-否;1-是。 默认为1
`RoomBaseName`|`room_base_name`|`string`| 自动建群的群名前缀,当auto_create_room为1时有效。最长40个utf8字符
`RoomBaseID`|`room_base_id`|`int`| 自动建群的群起始序号,当auto_create_room为1时有效
`ChatIDs`|`chat_id_list`|`[]string`| 使用该配置的客户群ID列表,支持5个。
`State`|`state`|`string`| 企业自定义的state参数,用于区分不同的入群渠道。不超过30个UTF-8字符

### `Conclusions` 结束语,会话结束时自动发送给客户

Name|JSON|Type|Doc
Expand Down
40 changes: 40 additions & 0 deletions external_contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,46 @@ func (c *WorkwxApp) ExternalContactDelContactWay(configID string) error {
return err
}

// ExternalContactAddGroupChatJoinWay 配置客户群「加入群聊」方式
func (c *WorkwxApp) ExternalContactAddGroupChatJoinWay(externalGroupChatJoinWay ExternalGroupChatJoinWay) (string, error) {
resp, err := c.execAddGroupChatJoinWayExternalContact(
reqAddGroupChatJoinWayExternalContact{
ExternalGroupChatJoinWay: externalGroupChatJoinWay,
})
if err != nil {
return "", err
}

return resp.ConfigID, nil
}

// ExternalContactGetGroupChatJoinWay 获取企业已配置的客户群「加入群聊」方式
func (c *WorkwxApp) ExternalContactGetGroupChatJoinWay(configID string) (*ExternalContactGroupChatJoinWay, error) {
resp, err := c.execGetGroupChatJoinWayExternalContact(reqGetGroupChatJoinWayExternalContact{ConfigID: configID})
if err != nil {
return nil, err
}

return &resp.JoinWay, nil
}

// ExternalContactUpdateGroupChatJoinWay 更新企业已配置的客户群「加入群聊」方式
func (c *WorkwxApp) ExternalContactUpdateGroupChatJoinWay(configID string, externalGroupChatJoinWay ExternalGroupChatJoinWay) error {
_, err := c.execUpdateGroupChatJoinWayExternalContact(reqUpdateGroupChatJoinWayExternalContact{
ConfigID: configID,
ExternalGroupChatJoinWay: externalGroupChatJoinWay,
})

return err
}

// ExternalContactDelGroupChatJoinWay 删除企业已配置的客户群「加入群聊」方式
func (c *WorkwxApp) ExternalContactDelGroupChatJoinWay(configID string) error {
_, err := c.execDelGroupChatJoinWayExternalContact(reqDelGroupChatJoinWayExternalContact{ConfigID: configID})

return err
}

// ExternalContactCloseTempChat 结束临时会话
func (c *WorkwxApp) ExternalContactCloseTempChat(userID, externalUserID string) error {
_, err := c.execCloseTempChatExternalContact(reqCloseTempChatExternalContact{
Expand Down
18 changes: 18 additions & 0 deletions external_contact.md.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 84 additions & 0 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,24 @@ type respAppchatCreate struct {
ChatID string `json:"chatid"`
}

// reqAppchatUpdate 修改群聊会话请求
type reqAppchatUpdate struct {
ChatInfo
AddMemberUserIDs []string `json:"add_user_list"`
DelMemberUserIDs []string `json:"del_user_list"`
}

var _ bodyer = reqAppchatUpdate{}

func (x reqAppchatUpdate) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}

// respAppchatUpdate 修改群聊会话响应
type respAppchatUpdate struct {
respCommon
}

// reqMediaUpload 临时素材上传请求
type reqMediaUpload struct {
Type string
Expand Down Expand Up @@ -1183,6 +1201,72 @@ type respDelContactWayExternalContact struct {
respCommon
}

type reqAddGroupChatJoinWayExternalContact struct {
ExternalGroupChatJoinWay
}

var _ bodyer = reqAddGroupChatJoinWayExternalContact{}

func (x reqAddGroupChatJoinWayExternalContact) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}

type respAddGroupChatJoinWayExternalContact struct {
respCommon

ConfigID string `json:"config_id"`
}

type reqGetGroupChatJoinWayExternalContact struct {
ConfigID string `json:"config_id"`
}

var _ bodyer = reqGetGroupChatJoinWayExternalContact{}

func (x reqGetGroupChatJoinWayExternalContact) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}

type respGetGroupChatJoinWayExternalContact struct {
respCommon
JoinWay ExternalContactGroupChatJoinWay `json:"join_way"`
}

type ExternalContactGroupChatJoinWay struct {
ConfigID string `json:"config_id"`
QRCode string `json:"qr_code"`
ExternalGroupChatJoinWay
}

type reqUpdateGroupChatJoinWayExternalContact struct {
ConfigID string `json:"config_id"`
ExternalGroupChatJoinWay
}

var _ bodyer = reqUpdateGroupChatJoinWayExternalContact{}

func (x reqUpdateGroupChatJoinWayExternalContact) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}

type respUpdateGroupChatJoinWayExternalContact struct {
respCommon
}

type reqDelGroupChatJoinWayExternalContact struct {
ConfigID string `json:"config_id"`
}

var _ bodyer = reqDelGroupChatJoinWayExternalContact{}

func (x reqDelGroupChatJoinWayExternalContact) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}

type respDelGroupChatJoinWayExternalContact struct {
respCommon
}

type reqCloseTempChatExternalContact struct {
UserID string `json:"userid"`
ExternalUserID string `json:"external_userid"`
Expand Down

0 comments on commit af938e8

Please sign in to comment.