-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathid_convert.go
140 lines (127 loc) · 3.88 KB
/
id_convert.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package wework
import (
"github.com/go-laoji/wecom-go-sdk/v2/internal"
)
type IdConvertExternalTagIdResponse struct {
internal.BizResponse
Items []struct {
ExternalTagid string `json:"external_tagid"`
OpenExternalTagid string `json:"open_external_tagid"`
} `json:"items"`
InvalidExternalTagidList []string `json:"invalid_external_tagid_list"`
}
func (ww *weWork) IdConvertExternalTagId(corpId uint, tagIdList []string) (resp IdConvertExternalTagIdResponse) {
if len(tagIdList) > 1000 {
resp.ErrCode = 500
resp.ErrorMsg = "参数列表不能超过1000个"
return
}
p := H{"external_tagid_list": tagIdList}
_, err := ww.getRequest(corpId).SetBody(p).SetResult(&resp).
Post("/cgi-bin/idconvert/external_tagid")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
type CorpIdToOpenCorpIdResponse struct {
internal.BizResponse
OpenCorpid string `json:"open_corpid"`
}
func (ww *weWork) CorpIdToOpenCorpId(corpId string) (resp CorpIdToOpenCorpIdResponse) {
p := H{"corpid": corpId}
_, err := ww.getProviderRequest().SetBody(p).SetResult(&resp).
Post("/cgi-bin/service/corpid_to_opencorpid")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
type UserIdToOpenUserIdResponse struct {
internal.BizResponse
OpenUserIdList []struct {
UserId string `json:"userid"`
OpenUserId string `json:"open_userid"`
} `json:"open_userid_list"`
InvalidUserIdList []string `json:"invalid_userid_list"`
}
func (ww *weWork) UserIdToOpenUserId(corpId uint, userIdList []string) (resp UserIdToOpenUserIdResponse) {
if len(userIdList) > 1000 {
resp.ErrCode = 500
resp.ErrorMsg = "参数列表不能超过1000个"
return
}
p := H{"userid_list": userIdList}
_, err := ww.getRequest(corpId).SetBody(p).SetResult(&resp).
Post("/cgi-bin/batch/userid_to_openuserid")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
type GetNewExternalUserIdResponse struct {
internal.BizResponse
Items []struct {
ExternalUserid string `json:"external_userid"`
NewExternalUserid string `json:"new_external_userid"`
} `json:"items"`
}
func (ww *weWork) GetNewExternalUserId(corpId uint, userIdList []string) (resp GetNewExternalUserIdResponse) {
if len(userIdList) > 1000 {
resp.ErrCode = 500
resp.ErrorMsg = "参数列表不能超过1000个"
return
}
p := H{"external_userid_list": userIdList}
_, err := ww.getRequest(corpId).SetBody(p).SetResult(&resp).
Post("/cgi-bin/externalcontact/get_new_external_userid")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
type GroupChatGetNewExternalUserIdRequest struct {
ChatID string `json:"chat_id" validate:"required"`
ExternalUseridList []string `json:"external_userid_list" validate:"required,max=1000"`
}
func (ww *weWork) GroupChatGetNewExternalUserId(corpId uint, request GroupChatGetNewExternalUserIdRequest) (resp GetNewExternalUserIdResponse) {
if ok := validate.Struct(request); ok != nil {
resp.ErrCode = 500
resp.ErrorMsg = ok.Error()
return
}
_, err := ww.getRequest(corpId).SetBody(request).SetResult(&resp).
Post("/cgi-bin/externalcontact/groupchat/get_new_external_userid")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
type IdConvertOpenKfIdResponse struct {
internal.BizResponse
Items []struct {
OpenKfId string `json:"open_kfid"`
NewOpenKfId string `json:"new_open_kfid"`
} `json:"items"`
InvalidOpenKfIdList []string `json:"invalid_open_kfid_list"`
}
func (ww *weWork) IdConvertOpenKfId(corpId uint, kfList []string) (resp IdConvertOpenKfIdResponse) {
if len(kfList) > 1000 {
resp.ErrCode = 500
resp.ErrorMsg = "参数列表不能超过1000个"
return
}
p := H{"open_kfid_list": kfList}
_, err := ww.getRequest(corpId).SetBody(p).SetResult(&resp).
Post("/cgi-bin/idconvert/open_kfid")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}