Skip to content

Commit 205f9ac

Browse files
authored
Merge pull request #235 from zjvill/master
增加获客助手部分接口
2 parents bb5bb3a + f921b13 commit 205f9ac

File tree

5 files changed

+304
-0
lines changed

5 files changed

+304
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ CI 会在 Go 的当前稳定版本、上一个稳定版本上跑测试,只有
184184
- [ ] 获取企业的全部群发记录
185185
- [x] 发送新客户欢迎语
186186
- [ ] 入群欢迎语素材管理
187+
* [x] 获客助手
188+
- [x] 获取获客链接列表
189+
- [x] 获取获客链接详情
190+
- [x] 创建获客链接
191+
- [ ] 编辑获客链接
192+
- [x] 获取获客客户列表
187193

188194
</details>
189195

apis.md.go

Lines changed: 44 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
@@ -83,6 +83,18 @@ Name|Request Type|Response Type|Access Token|URL|Doc
8383
`execExternalContactBatchList`|`reqExternalContactBatchList`|`respExternalContactBatchList`|+|`POST /cgi-bin/externalcontact/batch/get_by_user`|[批量获取客户详情](https://work.weixin.qq.com/api/doc/90000/90135/92994)
8484
`execExternalContactRemark`|`reqExternalContactRemark`|`respExternalContactRemark`|+|`POST /cgi-bin/externalcontact/remark`|[修改客户备注信息](https://work.weixin.qq.com/api/doc/90000/90135/92115)
8585

86+
# 外部联系人管理 - 获客助手
87+
88+
## API calls
89+
90+
Name| Request Type | Response Type |Access Token| URL |Doc
91+
:---|-------------------------------------------------|--------------------------------------------------|------------|:---------------------------------------------------------------|:--
92+
`execExternalContactCustomerAcquisitionLinkList`| `reqExternalContactCustomerAcquisitionLinkList` | `respExternalContactCustomerAcquisitionLinkList` |+| `POST /cgi-bin/externalcontact/customer_acquisition/list_link` |[获取获客链接列表](https://developer.work.weixin.qq.com/document/path/97394#%E8%8E%B7%E5%8F%96%E8%8E%B7%E5%AE%A2%E9%93%BE%E6%8E%A5%E5%88%97%E8%A1%A8)
93+
`execExternalContactCustomerAcquisitionInfo`| `reqExternalContactCustomerAcquisitionInfo` | `respExternalContactCustomerAcquisitionInfo` |+| `POST /cgi-bin/externalcontact/customer_acquisition/get` |[获取获客链接详情](https://developer.work.weixin.qq.com/document/path/97394#%E8%8E%B7%E5%8F%96%E8%8E%B7%E5%AE%A2%E9%93%BE%E6%8E%A5%E8%AF%A6%E6%83%85)
94+
`execExternalContactCustomerAcquisitionCreate`| `reqExternalContactCustomerAcquisitionCreate` | `respExternalContactCustomerAcquisitionCreate` |+| `POST /cgi-bin/externalcontact/customer_acquisition/create_link` |[创建获客链接](https://developer.work.weixin.qq.com/document/path/97394#%E5%88%9B%E5%BB%BA%E8%8E%B7%E5%AE%A2%E9%93%BE%E6%8E%A5)
95+
`execExternalContactCustomerAcquisitionCustomer`| `reqExternalContactCustomerAcquisitionCustomer` | `respExternalContactCustomerAcquisitionCustomer` |+| `POST /cgi-bin/externalcontact/customer_acquisition/customer` |[获取获客客户列表](https://developer.work.weixin.qq.com/document/path/97298)
96+
97+
8698
# 外部联系人管理 - 客户标签管理
8799

88100
## API calls

external_contact.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,68 @@ func (c *WorkwxApp) BatchListExternalContact(userID string, cursor string, limit
3939
return &BatchListExternalContactsResp{Result: resp.ExternalContactList, NextCursor: resp.NextCursor}, nil
4040
}
4141

42+
// ListExternalContactCustomerAcquisitionLink 获取获客链接列表
43+
func (c *WorkwxApp) ListExternalContactCustomerAcquisitionLink(cursor string, limit int) (*ExternalContactCustomerAcquisitionLinkListResp, error) {
44+
resp, err := c.execExternalContactCustomerAcquisitionLinkList(reqExternalContactCustomerAcquisitionLinkList{
45+
Cursor: cursor,
46+
Limit: limit,
47+
})
48+
if err != nil {
49+
return nil, err
50+
}
51+
return &ExternalContactCustomerAcquisitionLinkListResp{Result: resp.LinkIDList, NextCursor: resp.NextCursor}, nil
52+
}
53+
54+
// GetExternalContactCustomerAcquisitionLink 获取获客链接详情
55+
func (c *WorkwxApp) GetExternalContactCustomerAcquisitionLink(linkID string) (*ExternalContactCustomerAcquisitionInfo, error) {
56+
resp, err := c.execExternalContactCustomerAcquisitionInfo(reqExternalContactCustomerAcquisitionInfo{
57+
LinkID: linkID,
58+
})
59+
if err != nil {
60+
return nil, err
61+
}
62+
return &ExternalContactCustomerAcquisitionInfo{
63+
LinkName: resp.Link.LinkName,
64+
URL: resp.Link.URL,
65+
CreateTime: time.Unix(int64(resp.Link.CreateTime), 0),
66+
SkipVerify: resp.Link.SkipVerify,
67+
Range: resp.Link.Range,
68+
PriorityOption: resp.Link.PriorityOption,
69+
}, nil
70+
}
71+
72+
// CreateExternalContactCustomerAcquisitionLink 创建获客链接
73+
func (c *WorkwxApp) CreateExternalContactCustomerAcquisitionLink(linkName string, customerAcquisitionRange ExternalContactCustomerAcquisitionRange, priorityOption ExternalContactCustomerAcquisitionPriorityOption, skipVerify bool) (*ExternalContactCustomerAcquisitionCreateResp, error) {
74+
resp, err := c.execExternalContactCustomerAcquisitionCreate(reqExternalContactCustomerAcquisitionCreate{
75+
LinkName: linkName,
76+
Range: customerAcquisitionRange,
77+
PriorityOption: priorityOption,
78+
SkipVerify: skipVerify,
79+
})
80+
if err != nil {
81+
return nil, err
82+
}
83+
return &ExternalContactCustomerAcquisitionCreateResp{
84+
LinkID: resp.Link.LinkID,
85+
LinkName: resp.Link.LinkName,
86+
URL: resp.Link.URL,
87+
CreateTime: time.Unix(int64(resp.Link.CreateTime), 0),
88+
}, nil
89+
}
90+
91+
// ExternalContactCustomerAcquisitionCustomer 获取获客客户列表
92+
func (c *WorkwxApp) ExternalContactCustomerAcquisitionCustomer(linkID string, cursor string, limit int) (*ExternalContactCustomerAcquisitionCustomerResp, error) {
93+
resp, err := c.execExternalContactCustomerAcquisitionCustomer(reqExternalContactCustomerAcquisitionCustomer{
94+
LinkID: linkID,
95+
Cursor: cursor,
96+
Limit: limit,
97+
})
98+
if err != nil {
99+
return nil, err
100+
}
101+
return &ExternalContactCustomerAcquisitionCustomerResp{Result: resp.CustomerList, NextCursor: resp.NextCursor}, nil
102+
}
103+
42104
// RemarkExternalContact 修改客户备注信息
43105
func (c *WorkwxApp) RemarkExternalContact(req *ExternalContactRemark) error {
44106
_, err := c.execExternalContactRemark(reqExternalContactRemark{

models.go

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,186 @@ type respExternalContactBatchList struct {
593593
ExternalContactList []ExternalContactBatchInfo `json:"external_contact_list"`
594594
}
595595

596+
// ExternalContactCustomerAcquisitionLinkListResp 获取获客链接列表
597+
type ExternalContactCustomerAcquisitionLinkListResp struct {
598+
Result []string
599+
NextCursor string
600+
}
601+
602+
// reqExternalContactCustomerAcquisitionLinkList 获取获客链接列表
603+
type reqExternalContactCustomerAcquisitionLinkList struct {
604+
Cursor string `json:"cursor"`
605+
Limit int `json:"limit"`
606+
}
607+
608+
var _ bodyer = reqExternalContactCustomerAcquisitionLinkList{}
609+
610+
func (x reqExternalContactCustomerAcquisitionLinkList) intoBody() ([]byte, error) {
611+
return marshalIntoJSONBody(x)
612+
}
613+
614+
// respExternalContactBatchList 获取获客链接列表
615+
type respExternalContactCustomerAcquisitionLinkList struct {
616+
respCommon
617+
NextCursor string `json:"next_cursor"`
618+
LinkIDList []string `json:"link_id_list"`
619+
}
620+
621+
// ExternalContactCustomerAcquisitionInfo 获客链接信息
622+
type ExternalContactCustomerAcquisitionInfo struct {
623+
//获客链接的名称
624+
LinkName string `json:"link_name"`
625+
//获客链接实际的url
626+
URL string `json:"url"`
627+
//创建时间
628+
CreateTime time.Time `json:"create_time"`
629+
//是否无需验证,默认为true
630+
SkipVerify bool `json:"skip_verify"`
631+
//该获客链接使用范围
632+
Range ExternalContactCustomerAcquisitionRange `json:"range"`
633+
//优先级选项
634+
PriorityOption ExternalContactCustomerAcquisitionPriorityOption `json:"priority_option"`
635+
}
636+
637+
// ExternalContactCustomerAcquisitionRange 该获客链接使用范围
638+
type ExternalContactCustomerAcquisitionRange struct {
639+
//该获客链接使用范围成员列表
640+
UserList []string `json:"user_list"`
641+
//该获客链接使用范围的部门列表
642+
DepartmentList []int `json:"department_list"`
643+
}
644+
645+
// ExternalContactCustomerAcquisitionPriorityOption 优先级选项
646+
type ExternalContactCustomerAcquisitionPriorityOption struct {
647+
//优先分配类型,1-全企业范围内优先分配给有好友关系的;2-指定范围内优先分配有好友关系的
648+
PriorityType int `json:"priority_type"`
649+
//priority_type为2时的指定成员列表
650+
PriorityUseridList []string `json:"priority_userid_list"`
651+
}
652+
653+
// reqExternalContactCustomerAcquisitionCreate 创建获客链接
654+
type reqExternalContactCustomerAcquisitionCreate struct {
655+
//获客链接的名称
656+
LinkName string `json:"link_name"`
657+
//该获客链接使用范围
658+
Range ExternalContactCustomerAcquisitionRange `json:"range"`
659+
//优先级选项
660+
PriorityOption ExternalContactCustomerAcquisitionPriorityOption `json:"priority_option"`
661+
//是否无需验证,默认为true
662+
SkipVerify bool `json:"skip_verify"`
663+
}
664+
665+
var _ bodyer = reqExternalContactCustomerAcquisitionCreate{}
666+
667+
func (x reqExternalContactCustomerAcquisitionCreate) intoBody() ([]byte, error) {
668+
669+
obj := map[string]any{
670+
"link_name": x.LinkName,
671+
"skip_verify": x.SkipVerify,
672+
}
673+
674+
if len(x.Range.UserList) > 0 || len(x.Range.DepartmentList) > 0 {
675+
obj["range"] = x.Range
676+
}
677+
if len(x.PriorityOption.PriorityUseridList) > 0 || x.PriorityOption.PriorityType != 0 {
678+
obj["priority_option"] = x.PriorityOption
679+
}
680+
return marshalIntoJSONBody(obj)
681+
}
682+
683+
// respExternalContactCustomerAcquisitionCreate 创建获客链接
684+
type respExternalContactCustomerAcquisitionCreate struct {
685+
respCommon
686+
Link struct {
687+
//获客链接的id
688+
LinkID string `json:"link_id"`
689+
//获客链接的名称
690+
LinkName string `json:"link_name"`
691+
//获客链接实际的url
692+
URL string `json:"url"`
693+
//创建时间
694+
CreateTime int `json:"create_time"`
695+
} `json:"link"`
696+
}
697+
698+
type ExternalContactCustomerAcquisitionCreateResp struct {
699+
LinkID string `json:"link_id"`
700+
//获客链接的名称
701+
LinkName string `json:"link_name"`
702+
//获客链接实际的url
703+
URL string `json:"url"`
704+
//创建时间
705+
CreateTime time.Time `json:"create_time"`
706+
}
707+
708+
// reqExternalContactCustomerAcquisitionInfo 获客链接信息
709+
type reqExternalContactCustomerAcquisitionInfo struct {
710+
LinkID string `json:"link_id"`
711+
}
712+
713+
var _ bodyer = reqExternalContactCustomerAcquisitionInfo{}
714+
715+
func (x reqExternalContactCustomerAcquisitionInfo) intoBody() ([]byte, error) {
716+
return marshalIntoJSONBody(x)
717+
}
718+
719+
// respExternalContactCustomerAcquisitionInfo 获客链接信息
720+
type respExternalContactCustomerAcquisitionInfo struct {
721+
respCommon
722+
Link struct {
723+
//获客链接的名称
724+
LinkName string `json:"link_name"`
725+
//获客链接实际的url
726+
URL string `json:"url"`
727+
//创建时间
728+
CreateTime int `json:"create_time"`
729+
//是否无需验证,默认为true
730+
SkipVerify bool `json:"skip_verify"`
731+
//该获客链接使用范围
732+
Range ExternalContactCustomerAcquisitionRange `json:"range"`
733+
//优先级选项
734+
PriorityOption ExternalContactCustomerAcquisitionPriorityOption `json:"priority_option"`
735+
} `json:"link"`
736+
}
737+
738+
// ExternalContactCustomerAcquisitionCustomerInfo 获客助手客户信息
739+
type ExternalContactCustomerAcquisitionCustomerInfo struct {
740+
//客户external_userid
741+
ExternalUserid string `json:"external_userid"`
742+
//通过获客链接添加此客户的跟进人userid
743+
UserID string `json:"userid"`
744+
//会话状态,0-客户未发消息 1-客户已发送消息 2-客户发送消息状态未知
745+
ChatStatus int `json:"chat_status"`
746+
//用于区分客户具体是通过哪个获客链接进行添加,用户可在获客链接后拼接customer_channel=自定义字符串,字符串不超过64字节,超过会被截断。通过点击带有customer_channel参数的链接获取到的客户,调用获客信息接口或获取客户详情接口时,返回的state参数即为链接后拼接自定义字符串
747+
State string `json:"state"`
748+
}
749+
750+
// ExternalContactCustomerAcquisitionCustomerResp 获客助手客户信息
751+
type ExternalContactCustomerAcquisitionCustomerResp struct {
752+
Result []ExternalContactCustomerAcquisitionCustomerInfo
753+
NextCursor string
754+
}
755+
756+
// reqExternalContactCustomerAcquisitionCustomer 获客助手客户信息
757+
type reqExternalContactCustomerAcquisitionCustomer struct {
758+
LinkID string `json:"link_id"`
759+
Cursor string `json:"cursor"`
760+
Limit int `json:"limit"`
761+
}
762+
763+
var _ bodyer = reqExternalContactCustomerAcquisitionCustomer{}
764+
765+
func (x reqExternalContactCustomerAcquisitionCustomer) intoBody() ([]byte, error) {
766+
return marshalIntoJSONBody(x)
767+
}
768+
769+
// respExternalContactBatchList 获客助手客户信息
770+
type respExternalContactCustomerAcquisitionCustomer struct {
771+
respCommon
772+
NextCursor string `json:"next_cursor"`
773+
CustomerList []ExternalContactCustomerAcquisitionCustomerInfo `json:"customer_list"`
774+
}
775+
596776
// reqExternalContactRemark 获取客户详情
597777
type reqExternalContactRemark struct {
598778
Remark *ExternalContactRemark

0 commit comments

Comments
 (0)