Skip to content

Commit 10e25a0

Browse files
bors[bot]w3xse7en
andauthored
Merge #65
65: feat: add BatchExternalContact r=xen0n a=w3xse7en BatchExternalContact doc: https://work.weixin.qq.com/api/doc/90000/90135/92994 Co-authored-by: w3xse7en <[email protected]>
2 parents 68e8836 + 37ca19d commit 10e25a0

7 files changed

+107
-9
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ in at least 2 of Qiniu's internal systems.
6060
## Supported APIs
6161

6262
* [x] 通讯录管理 (**部分支持**,见下)
63-
* [ ] 外部联系人管理
63+
* [ ] 客户联系
6464
* [ ] 应用管理
6565
* [x] 消息发送 (除修改群聊会话外全部支持)
6666
* [x] 消息接收 (**接口尚不稳定,极有可能做出不兼容改动,先不要用**)
@@ -110,12 +110,13 @@ in at least 2 of Qiniu's internal systems.
110110
</details>
111111

112112
<details>
113-
<summary>外部联系人管理 API</summary>
113+
<summary>客户联系 API</summary>
114114

115115
* [x] 成员对外信息
116116
* [x] 客户管理
117117
- [x] 获取客户列表
118118
- [x] 获取客户详情
119+
- [x] 批量获取客户详情
119120
- [x] 修改客户备注信息
120121
* [x] 客户标签管理
121122
- [x] 管理企业标签

apis.md.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/apis.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Name|Request Type|Response Type|Access Token|URL|Doc
7575
:---|------------|-------------|------------|:--|:--
7676
`execExternalContactList`|`reqExternalContactList`|`respExternalContactList`|+|`GET /cgi-bin/externalcontact/list`|[获取客户列表](https://work.weixin.qq.com/api/doc/90000/90135/92113)
7777
`execExternalContactGet`|`reqExternalContactGet`|`respExternalContactGet`|+|`GET /cgi-bin/externalcontact/get`|[获取客户详情](https://work.weixin.qq.com/api/doc/90000/90135/92114)
78+
`execExternalContactBatchList`|`reqExternalContactBatchList`|`respExternalContactBatchList`|+|`POST /cgi-bin/externalcontact/batch/get_by_user`|[批量获取客户详情](https://work.weixin.qq.com/api/doc/90000/90135/92994)
7879
`execExternalContactRemark`|`reqExternalContactRemark`|`respExternalContactRemark`|+|`POST /cgi-bin/externalcontact/remark`|[修改客户备注信息](https://work.weixin.qq.com/api/doc/90000/90135/92115)
7980

8081
# 外部联系人管理 - 客户标签管理

docs/external_contact.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,28 @@ const (
7474

7575
Name|JSON|Type|Doc
7676
:---|:---|:---|:--
77-
`Userid`|`userid`|`string`| 外部联系人的userid
77+
``|``|`FollowUserInfo`| 添加了外部联系人的企业成员
78+
`Tags`|`tags`|`[]FollowUserTag`| 该成员添加此外部联系人所打标签
79+
80+
### `FollowInfo` 企业成员客户跟进信息,可以参考获取客户详情,但标签信息只会返回企业标签的tag_id,个人标签将不再返回
81+
82+
Name|JSON|Type|Doc
83+
:---|:---|:---|:--
84+
``|``|`FollowUserInfo`| 添加了外部联系人的企业成员
85+
`TagID`|`tag_id`|`[]string`| 该成员添加此外部联系人所打标签
86+
87+
### `FollowUserInfo` 添加了外部联系人的企业成员
88+
89+
Name|JSON|Type|Doc
90+
:---|:---|:---|:--
91+
`UserID`|`userid`|`string`| 外部联系人的userid
7892
`Remark`|`remark`|`string`| 该成员对此外部联系人的备注
7993
`Description`|`description`|`string`| 该成员对此外部联系人的描述
8094
`Createtime`|`createtime`|`int`| 该成员添加此外部联系人的时间
81-
`Tags`|`tags`|`[]FollowUserTag`| 该成员添加此外部联系人所打标签
8295
`RemarkCorpName`|`remark_corp_name`|`string`| 该成员对此客户备注的企业名称
8396
`RemarkMobiles`|`remark_mobiles`|`[]string`| 该成员对此客户备注的手机号码,第三方不可获取
8497
`AddWay`|`add_way`|`FollowUserAddWay`| 该成员添加此客户的来源
98+
`OperUserID`|`oper_userid`|`string`| 发起添加的userid,如果成员主动添加,为成员的userid;如果是客户主动添加,则为客户的外部联系人userid;如果是内部成员共享/管理员分配,则为对应的成员/管理员userid
8599
`State`|`state`|`string`| 企业自定义的state参数,用于区分客户具体是通过哪个「联系我」添加,由企业通过[创建「联系我」方式](https://work.weixin.qq.com/api/doc/90000/90135/92114#15645/%E9%85%8D%E7%BD%AE%E5%AE%A2%E6%88%B7%E8%81%94%E7%B3%BB%E3%80%8C%E8%81%94%E7%B3%BB%E6%88%91%E3%80%8D%E6%96%B9%E5%BC%8F)指定
86100

87101
### `FollowUserTag` 该成员添加此外部联系人所打标签
@@ -92,7 +106,6 @@ Name|JSON|Type|Doc
92106
`TagName`|`tag_name`|`string`| 该成员添加此外部联系人所打标签名称
93107
`Type`|`type`|`FollowUserTagType`| 该成员添加此外部联系人所打标签类型, 1-企业设置, 2-用户自定义
94108

95-
96109
```go
97110
// FollowUserTagType 该成员添加此外部联系人所打标签类型
98111
//

external_contact.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ func (c *WorkwxApp) GetExternalContact(externalUserid string) (*ExternalContactI
2626
return &resp.ExternalContactInfo, nil
2727
}
2828

29+
// BatchListExternalContact 批量获取客户详情
30+
func (c *WorkwxApp) BatchListExternalContact(userID string, cursor string, limit int) (*BatchListExternalContactsResp, error) {
31+
resp, err := c.execExternalContactBatchList(reqExternalContactBatchList{
32+
UserID: userID,
33+
Cursor: cursor,
34+
Limit: limit,
35+
})
36+
if err != nil {
37+
return nil, err
38+
}
39+
return &BatchListExternalContactsResp{Result: resp.ExternalContactList, NextCursor: resp.NextCursor}, nil
40+
}
41+
2942
// RemarkExternalContact 修改客户备注信息
3043
func (c *WorkwxApp) RemarkExternalContact(req *ExternalContactRemark) error {
3144
_, err := c.execExternalContactRemark(reqExternalContactRemark{

external_contact.md.go

Lines changed: 20 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,51 @@ type respExternalContactGet struct {
387387
ExternalContactInfo
388388
}
389389

390+
// ExternalContactInfo 外部联系人信息
390391
type ExternalContactInfo struct {
391392
ExternalContact ExternalContact `json:"external_contact"`
392393
FollowUser []FollowUser `json:"follow_user"`
393394
}
394395

396+
// ExternalContactBatchInfo 外部联系人信息
397+
type ExternalContactBatchInfo struct {
398+
ExternalContact ExternalContact `json:"external_contact"`
399+
FollowInfo FollowInfo `json:"follow_info"`
400+
}
401+
402+
// BatchListExternalContactsResp 外部联系人信息
403+
type BatchListExternalContactsResp struct {
404+
Result []ExternalContactBatchInfo
405+
NextCursor string
406+
}
407+
408+
// reqExternalContactBatchList 批量获取客户详情
409+
type reqExternalContactBatchList struct {
410+
UserID string `json:"userid"`
411+
Cursor string `json:"cursor"`
412+
Limit int `json:"limit"`
413+
}
414+
415+
var _ bodyer = reqExternalContactBatchList{}
416+
417+
func (x reqExternalContactBatchList) intoBody() ([]byte, error) {
418+
result, err := json.Marshal(x)
419+
if err != nil {
420+
// should never happen unless OOM or similar bad things
421+
// TODO: error_chain
422+
return nil, err
423+
}
424+
425+
return result, nil
426+
}
427+
428+
// respExternalContactBatchList 批量获取客户详情
429+
type respExternalContactBatchList struct {
430+
respCommon
431+
NextCursor string `json:"next_cursor"`
432+
ExternalContactList []ExternalContactBatchInfo `json:"external_contact_list"`
433+
}
434+
395435
// reqExternalContactRemark 获取客户详情
396436
type reqExternalContactRemark struct {
397437
Remark *ExternalContactRemark

0 commit comments

Comments
 (0)