Skip to content

Commit 807d871

Browse files
bors[bot]w3xse7en
andauthored
Merge #50
50: feat: add ExternalContactGetCorpTagList,ExternalContactAddCorpTag,ExternalContactEditCorpTag,ExternalContactDelCorpTag,ExternalContactMarkTag r=xen0n a=w3xse7en Support Manage ExternalContact CorpTag ExternalContactGetCorpTagList doc: https://work.weixin.qq.com/api/doc/90000/90135/92117#获取企业标签库 ExternalContactAddCorpTag doc: https://work.weixin.qq.com/api/doc/90000/90135/92117#添加企业客户标签 ExternalContactEditCorpTag doc: https://work.weixin.qq.com/api/doc/90000/90135/92117#编辑企业客户标签 ExternalContactDelCorpTag doc: https://work.weixin.qq.com/api/doc/90000/90135/92117#删除企业客户标签 ExternalContactMarkTag doc: https://work.weixin.qq.com/api/doc/90000/90135/92118 Co-authored-by: w3xse7en <w3xse7en@outlook.com>
2 parents 662f2bc + cdadc10 commit 807d871

File tree

9 files changed

+344
-9
lines changed

9 files changed

+344
-9
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ in at least 2 of Qiniu's internal systems.
114114
- [x] 获取客户列表
115115
- [x] 获取客户详情
116116
- [x] 修改客户备注信息
117+
* [x] 客户标签管理
118+
- [x] 管理企业标签
119+
- [x] 编辑客户企业标签
117120
* [x] 变更回调通知
118121
- [x] 添加企业客户事件
119122
- [x] 编辑企业客户事件

apis.md.go

Lines changed: 70 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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ Name|Request Type|Response Type|Access Token|URL|Doc
7676
`execExternalContactGet`|`reqExternalContactGet`|`respExternalContactGet`|+|`GET /cgi-bin/externalcontact/get`|[获取客户详情](https://work.weixin.qq.com/api/doc/90000/90135/92114)
7777
`execExternalContactRemark`|`reqExternalContactRemark`|`respExternalContactRemark`|+|`POST /cgi-bin/externalcontact/remark`|[修改客户备注信息](https://work.weixin.qq.com/api/doc/90000/90135/92115)
7878

79+
# 外部联系人管理 - 客户标签管理
80+
81+
## API calls
82+
83+
Name|Request Type|Response Type|Access Token|URL|Doc
84+
:---|------------|-------------|------------|:--|:--
85+
`execExternalContactListCorpTags`|`reqExternalContactListCorpTags`|`respExternalContactListCorpTags`|+|`POST /cgi-bin/externalcontact/get_corp_tag_list`|[获取企业标签库](https://work.weixin.qq.com/api/doc/90000/90135/92117)
86+
`execExternalContactAddCorpTag`|`reqExternalContactAddCorpTag`|`respExternalContactAddCorpTag`|+|`POST /cgi-bin/externalcontact/add_corp_tag`|[添加企业客户标签](https://work.weixin.qq.com/api/doc/90000/90135/92117)
87+
`execExternalContactEditCorpTag`|`reqExternalContactEditCorpTag`|`respExternalContactEditCorpTag`|+|`POST /cgi-bin/externalcontact/edit_corp_tag`|[编辑企业客户标签](https://work.weixin.qq.com/api/doc/90000/90135/92117)
88+
`execExternalContactDelCorpTag`|`reqExternalContactDelCorpTag`|`respExternalContactDelCorpTag`|+|`POST /cgi-bin/externalcontact/del_corp_tag`|[删除企业客户标签](https://work.weixin.qq.com/api/doc/90000/90135/92117)
89+
`execExternalContactMarkTag`|`reqExternalContactMarkTag`|`respExternalContactMarkTag`|+|`POST /cgi-bin/externalcontact/mark_tag`|[标记客户企业标签](https://work.weixin.qq.com/api/doc/90000/90135/92118)
90+
7991
# 应用管理
8092

8193
## API calls

docs/external_contact.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,33 @@ Name|JSON|Type|Doc
151151
`RemarkCompany`|`remark_company`|`string`| 此用户对外部联系人备注的所属公司名称,最多20个字符,remark_company只在此外部联系人为微信用户时有效。
152152
`RemarkMobiles`|`remark_mobiles`|`[]string`| 此用户对外部联系人备注的手机号,如果填写了remark_mobiles,将会覆盖旧的备注手机号。如果要清除所有备注手机号,请在remark_mobiles填写一个空字符串(“”)。
153153
`RemarkPicMediaid`|`remark_pic_mediaid`|`string`| 备注图片的mediaid,remark_pic_mediaid可以通过素材管理接口获得。
154+
155+
### `ExternalContactCorpTag` 企业客户标签
156+
157+
Name|JSON|Type|Doc
158+
:---|:---|:---|:--
159+
`ID`|`id`|`string`| 标签id
160+
`Name`|`name`|`string`| 标签名称
161+
`CreateTime`|`create_time`|`int`| 标签创建时间
162+
`Order`|`order`|`uint32`| 标签排序的次序值,order值大的排序靠前。有效的值范围是[0, 2^32)
163+
`Deleted`|`deleted`|`bool`| 标签是否已经被删除,只在指定tag_id进行查询时返回
164+
165+
### `ExternalContactCorpTagGroup` 企业客户标签
166+
167+
Name|JSON|Type|Doc
168+
:---|:---|:---|:--
169+
`GroupID`|`group_id`|`string`| 标签组id
170+
`GroupName`|`group_name`|`string`| 标签组名称
171+
`CreateTime`|`create_time`|`int`| 标签组创建时间
172+
`Order`|`order`|`uint32`| 标签组排序的次序值,order值大的排序靠前。有效的值范围是[0, 2^32)
173+
`Deleted`|`deleted`|`bool`| 标签组是否已经被删除,只在指定tag_id进行查询时返回
174+
`Tag`|`tag`|`[]ExternalContactCorpTag`| 标签组内的标签列表
175+
176+
### `ExternalContactMarkTag` 企业标记客户标签
177+
178+
Name|JSON|Type|Doc
179+
:---|:---|:---|:--
180+
`UserID`|`userid`|`string`| 添加外部联系人的userid
181+
`ExternalUserID`|`external_userid`|`string`| 外部联系人userid
182+
`AddTag`|`add_tag`|`[]string`| 要标记的标签列表
183+
`RemoveTag`|`remove_tag`|`[]string`| 要移除的标签列表

docs/user_info.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ Name|Type|Doc
6464

6565
Name|JSON|Type|Doc
6666
:---|:---|:---|:--
67-
`UserId`|`UserId`|`string`|成员UserID。若需要获得用户详情信息,可调用通讯录接口:读取成员。如果是互联企业,则返回的UserId格式如:CorpId/userid
68-
`OpenId`|`OpenId`|`string`|非企业成员的标识,对当前企业唯一。不超过64字节
69-
`DeviceId`|`DeviceId`|`string`|手机设备号(由企业微信在安装时随机生成,删除重装会改变,升级不受影响)
67+
`UserID`|`UserId`|`string`|成员UserID。若需要获得用户详情信息,可调用通讯录接口:读取成员。如果是互联企业,则返回的UserId格式如:CorpId/userid
68+
`OpenID`|`OpenId`|`string`|非企业成员的标识,对当前企业唯一。不超过64字节
69+
`DeviceID`|`DeviceId`|`string`|手机设备号(由企业微信在安装时随机生成,删除重装会改变,升级不受影响)

external_contact.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,55 @@ func (c *WorkwxApp) RemarkExternalContact(req *ExternalContactRemark) error {
2929
})
3030
return err
3131
}
32+
33+
// ListExternalContactCorpTags 获取企业标签库
34+
func (c *WorkwxApp) ListExternalContactCorpTags(tagIDs ...string) ([]ExternalContactCorpTagGroup, error) {
35+
resp, err := c.execExternalContactListCorpTags(reqExternalContactListCorpTags{
36+
TagIDs: tagIDs,
37+
})
38+
if err != nil {
39+
return nil, err
40+
}
41+
return resp.TagGroup, nil
42+
}
43+
44+
// AddExternalContactCorpTag 添加企业客户标签
45+
func (c *WorkwxApp) AddExternalContactCorpTag(req ExternalContactCorpTagGroup) ([]ExternalContactCorpTagGroup, error) {
46+
resp, err := c.execExternalContactAddCorpTag(reqExternalContactAddCorpTag{
47+
ExternalContactCorpTagGroup: req,
48+
})
49+
if err != nil {
50+
return nil, err
51+
}
52+
return resp.TagGroup, nil
53+
}
54+
55+
// EditExternalContactCorpTag 编辑企业客户标签
56+
func (c *WorkwxApp) EditExternalContactCorpTag(id, name string, order uint32) error {
57+
_, err := c.execExternalContactEditCorpTag(reqExternalContactEditCorpTag{
58+
ID: id,
59+
Name: name,
60+
Order: order,
61+
})
62+
return err
63+
}
64+
65+
// DelExternalContactCorpTag 删除企业客户标签
66+
func (c *WorkwxApp) DelExternalContactCorpTag(tagID, groupID []string) error {
67+
_, err := c.execExternalContactDelCorpTag(reqExternalContactDelCorpTag{
68+
TagID: tagID,
69+
GroupID: groupID,
70+
})
71+
return err
72+
}
73+
74+
// MarkExternalContactTag 标记客户企业标签
75+
func (c *WorkwxApp) MarkExternalContactTag(userID, externalUserID string, addTag, removeTag []string) error {
76+
_, err := c.execExternalContactMarkTag(reqExternalContactMarkTag{
77+
UserID: userID,
78+
ExternalUserID: externalUserID,
79+
AddTag: addTag,
80+
RemoveTag: removeTag,
81+
})
82+
return err
83+
}

external_contact.md.go

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

models.go

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,129 @@ type respUserInfoGet struct {
433433
respCommon
434434
UserIdentityInfo
435435
}
436+
437+
// reqExternalContactListCorpTags 获取企业标签库
438+
type reqExternalContactListCorpTags struct {
439+
// 要查询的标签id,如果不填则获取该企业的所有客户标签,目前暂不支持标签组id
440+
TagIDs []string `json:"tag_id"`
441+
}
442+
443+
var _ bodyer = reqExternalContactListCorpTags{}
444+
445+
func (x reqExternalContactListCorpTags) intoBody() ([]byte, error) {
446+
result, err := json.Marshal(x)
447+
if err != nil {
448+
// should never happen unless OOM or similar bad things
449+
// TODO: error_chain
450+
return nil, err
451+
}
452+
453+
return result, nil
454+
}
455+
456+
// respExternalContactListCorpTags 获取企业标签库
457+
type respExternalContactListCorpTags struct {
458+
respCommon
459+
// 标签组列表
460+
TagGroup []ExternalContactCorpTagGroup `json:"tag_group"`
461+
}
462+
463+
// reqExternalContactAddCorpTag 添加企业客户标签
464+
type reqExternalContactAddCorpTag struct {
465+
ExternalContactCorpTagGroup
466+
}
467+
468+
var _ bodyer = reqExternalContactAddCorpTag{}
469+
470+
func (x reqExternalContactAddCorpTag) intoBody() ([]byte, error) {
471+
result, err := json.Marshal(x.ExternalContactCorpTagGroup)
472+
if err != nil {
473+
// should never happen unless OOM or similar bad things
474+
// TODO: error_chain
475+
return nil, err
476+
}
477+
478+
return result, nil
479+
}
480+
481+
// respExternalContactAddCorpTag 添加企业客户标签
482+
type respExternalContactAddCorpTag struct {
483+
respCommon
484+
// 标签组列表
485+
TagGroup []ExternalContactCorpTagGroup `json:"tag_group"`
486+
}
487+
488+
// reqExternalContactEditCorpTag 编辑企业客户标签
489+
type reqExternalContactEditCorpTag struct {
490+
ID string `json:"id"`
491+
Name string `json:"name"`
492+
Order uint32 `json:"order"`
493+
}
494+
495+
var _ bodyer = reqExternalContactEditCorpTag{}
496+
497+
func (x reqExternalContactEditCorpTag) intoBody() ([]byte, error) {
498+
result, err := json.Marshal(x)
499+
if err != nil {
500+
// should never happen unless OOM or similar bad things
501+
// TODO: error_chain
502+
return nil, err
503+
}
504+
505+
return result, nil
506+
}
507+
508+
// respExternalContactEditCorpTag 编辑企业客户标签
509+
type respExternalContactEditCorpTag struct {
510+
respCommon
511+
}
512+
513+
// reqExternalContactDelCorpTag 删除企业客户标签
514+
type reqExternalContactDelCorpTag struct {
515+
TagID []string `json:"tag_id"`
516+
GroupID []string `json:"group_id"`
517+
}
518+
519+
var _ bodyer = reqExternalContactDelCorpTag{}
520+
521+
func (x reqExternalContactDelCorpTag) intoBody() ([]byte, error) {
522+
result, err := json.Marshal(x)
523+
if err != nil {
524+
// should never happen unless OOM or similar bad things
525+
// TODO: error_chain
526+
return nil, err
527+
}
528+
529+
return result, nil
530+
}
531+
532+
// reqExternalContactDelCorpTag 删除企业客户标签
533+
type respExternalContactDelCorpTag struct {
534+
respCommon
535+
}
536+
537+
// reqExternalContactMarkTag 编辑企业客户标签
538+
type reqExternalContactMarkTag struct {
539+
UserID string `json:"userid"`
540+
ExternalUserID string `json:"external_userid"`
541+
AddTag []string `json:"add_tag"`
542+
RemoveTag []string `json:"remove_tag"`
543+
}
544+
545+
var _ bodyer = reqExternalContactMarkTag{}
546+
547+
func (x reqExternalContactMarkTag) intoBody() ([]byte, error) {
548+
result, err := json.Marshal(x)
549+
if err != nil {
550+
// should never happen unless OOM or similar bad things
551+
// TODO: error_chain
552+
return nil, err
553+
}
554+
555+
return result, nil
556+
}
557+
558+
// reqExternalContactMarkTag 编辑企业客户标签
559+
type respExternalContactMarkTag struct {
560+
respCommon
561+
}

user_info.md.go

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

0 commit comments

Comments
 (0)