forked from xen0n/go-workwx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
1975 lines (1580 loc) · 53.9 KB
/
models.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package workwx
import (
"encoding/json"
"net/url"
"strconv"
"strings"
"time"
)
func marshalIntoJSONBody(x interface{}) ([]byte, error) {
y, err := json.Marshal(x)
if err != nil {
// should never happen unless OOM or similar bad things
return nil, makeReqMarshalErr(err)
}
return y, nil
}
type reqAccessToken struct {
CorpID string
CorpSecret string
}
var _ urlValuer = reqAccessToken{}
func (x reqAccessToken) intoURLValues() url.Values {
return url.Values{
"corpid": {x.CorpID},
"corpsecret": {x.CorpSecret},
}
}
type respCommon struct {
ErrCode int64 `json:"errcode"`
ErrMsg string `json:"errmsg"`
}
// IsOK 响应体是否为一次成功请求的响应
//
// 实现依据: https://work.weixin.qq.com/api/doc#10013
//
// > 企业微信所有接口,返回包里都有errcode、errmsg。
// > 开发者需根据errcode是否为0判断是否调用成功(errcode意义请见全局错误码)。
// > 而errmsg仅作参考,后续可能会有变动,因此不可作为是否调用成功的判据。
func (x *respCommon) IsOK() bool {
return x.ErrCode == 0
}
func (x *respCommon) TryIntoErr() error {
if x.IsOK() {
return nil
}
return &WorkwxClientError{
Code: x.ErrCode,
Msg: x.ErrMsg,
}
}
type respAccessToken struct {
respCommon
AccessToken string `json:"access_token"`
ExpiresInSecs int64 `json:"expires_in"`
}
type reqJSAPITicketAgentConfig struct{}
var _ urlValuer = reqJSAPITicketAgentConfig{}
func (x reqJSAPITicketAgentConfig) intoURLValues() url.Values {
return url.Values{
"type": {"agent_config"},
}
}
type reqJSAPITicket struct{}
var _ urlValuer = reqJSAPITicket{}
func (x reqJSAPITicket) intoURLValues() url.Values {
return url.Values{}
}
type respJSAPITicket struct {
respCommon
Ticket string `json:"ticket"`
ExpiresInSecs int64 `json:"expires_in"`
}
// reqMessage 消息发送请求
type reqMessage struct {
ToUser []string
ToParty []string
ToTag []string
ChatID string
AgentID int64
OpenKfID string
Code string
MsgType string
Content map[string]interface{}
IsSafe bool
}
var _ bodyer = reqMessage{}
func (x reqMessage) intoBody() ([]byte, error) {
// fuck
safeInt := 0
if x.IsSafe {
safeInt = 1
}
obj := map[string]interface{}{
"msgtype": x.MsgType,
"agentid": x.AgentID,
"safe": safeInt,
}
// msgtype polymorphism
if x.MsgType != "template_card" {
obj[x.MsgType] = x.Content
} else {
obj[x.MsgType] = x.Content["template_card"]
}
// 复用这个结构体,因为是 package-private 的所以这么做没风险
if x.ChatID != "" {
obj["chatid"] = x.ChatID
} else {
if x.Code != "" {
obj["code"] = x.Code
} else if x.OpenKfID != "" {
obj["open_kfid"] = x.OpenKfID
}
obj["touser"] = strings.Join(x.ToUser, "|")
obj["toparty"] = strings.Join(x.ToParty, "|")
obj["totag"] = strings.Join(x.ToTag, "|")
}
return marshalIntoJSONBody(obj)
}
// respMessageSend 消息发送响应
type respMessageSend struct {
respCommon
InvalidUsers string `json:"invaliduser"`
InvalidParties string `json:"invalidparty"`
InvalidTags string `json:"invalidtag"`
}
type reqUserGet struct {
UserID string
}
var _ urlValuer = reqUserGet{}
func (x reqUserGet) intoURLValues() url.Values {
return url.Values{
"userid": {x.UserID},
}
}
// respUserGet 读取成员响应
type respUserGet struct {
respCommon
UserDetail
}
// reqUserUpdate 更新成员请求
type reqUserUpdate struct {
UserDetail *UserDetail
}
var _ bodyer = reqUserUpdate{}
func (x reqUserUpdate) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x.UserDetail)
}
// respUserUpdate 更新成员响应
type respUserUpdate struct {
respCommon
}
// reqUserList 部门成员请求
type reqUserList struct {
DeptID int64
FetchChild bool
}
var _ urlValuer = reqUserList{}
func (x reqUserList) intoURLValues() url.Values {
var fetchChild int64
if x.FetchChild {
fetchChild = 1
}
return url.Values{
"department_id": {strconv.FormatInt(x.DeptID, 10)},
"fetch_child": {strconv.FormatInt(fetchChild, 10)},
}
}
// respUsersByDeptID 部门成员详情响应
type respUserList struct {
respCommon
Users []*UserDetail `json:"userlist"`
}
// reqConvertUserIDToOpenID userid转openid 请求
type reqConvertUserIDToOpenID struct {
UserID string `json:"userid"`
}
var _ bodyer = reqConvertUserIDToOpenID{}
// respConvertUserIDToOpenID userid转openid 响应
type respConvertUserIDToOpenID struct {
respCommon
OpenID string `json:"openid"`
}
func (x reqConvertUserIDToOpenID) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}
// reqConvertOpenIDToUserID openid转userid 请求
type reqConvertOpenIDToUserID struct {
OpenID string `json:"openid"`
}
var _ bodyer = reqConvertOpenIDToUserID{}
// respConvertUserIDToOpenID openid转userid 响应
type respConvertOpenIDToUserID struct {
respCommon
UserID string `json:"userid"`
}
func (x reqConvertOpenIDToUserID) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}
// SizeType qrcode尺寸类型
//
// 1: 171 x 171; 2: 399 x 399; 3: 741 x 741; 4: 2052 x 2052
type SizeType int
const (
// SizeTypeMini 171 x 171
SizeTypeMini SizeType = iota + 1
// SizeTypeSmall 399 x 399
SizeTypeSmall
// SizeTypeMedium 741 x 741
SizeTypeMedium
// SizeTypeLarge 2052 x 2052
SizeTypeLarge
)
// reqUserJoinQrcode 获取加入企业二维码 请求
type reqUserJoinQrcode struct {
SizeType SizeType `json:"size_type"`
}
var _ urlValuer = reqUserJoinQrcode{}
func (x reqUserJoinQrcode) intoURLValues() url.Values {
return url.Values{
"size_type": {strconv.Itoa(int(x.SizeType))},
}
}
// respUserJoinQrcode 获取加入企业二维码 响应
type respUserJoinQrcode struct {
respCommon
JoinQrcode string `json:"join_qrcode"`
}
// reqUserIDByMobile 手机号获取 userid 请求
type reqUserIDByMobile struct {
Mobile string `json:"mobile"`
}
var _ bodyer = reqUserIDByMobile{}
func (x reqUserIDByMobile) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}
// respUserIDByMobile 手机号获取 userid 响应
type respUserIDByMobile struct {
respCommon
UserID string `json:"userid"`
}
// EmailType 用户邮箱的类型
//
// 1表示用户邮箱是企业邮箱(默认)
// 2表示用户邮箱是个人邮箱
type EmailType int
const (
// EmailTypeCorporate 企业邮箱
EmailTypeCorporate EmailType = 1
// EmailTypePersonal 个人邮箱
EmailTypePersonal EmailType = 2
)
// reqUserIDByEmail 邮箱获取 userid 请求
type reqUserIDByEmail struct {
Email string `json:"email"`
EmailType EmailType `json:"email_type"`
}
var _ bodyer = reqUserIDByEmail{}
func (x reqUserIDByEmail) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}
// respUserIDByEmail 邮箱获取 userid 响应
type respUserIDByEmail struct {
respCommon
UserID string `json:"userid"`
}
// reqDeptCreate 创建部门
type reqDeptCreate struct {
DeptInfo *DeptInfo
}
var _ bodyer = reqDeptCreate{}
func (x reqDeptCreate) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x.DeptInfo)
}
// respDeptCreate 创建部门响应
type respDeptCreate struct {
respCommon
ID int64 `json:"id"`
}
// reqDeptList 获取部门列表
// 从2022年8月15日10点开始,“企业管理后台 - 管理工具 - 通讯录同步”的新增IP将不能再调用此接口,企业可通过「获取部门ID列表」接口获取部门ID列表。查看调整详情。
// https://developer.work.weixin.qq.com/document/path/96079
type reqDeptList struct {
HaveID bool
ID int64
}
var _ urlValuer = reqDeptList{}
func (x reqDeptList) intoURLValues() url.Values {
if !x.HaveID {
return url.Values{}
}
return url.Values{
"id": {strconv.FormatInt(x.ID, 10)},
}
}
// respDeptList 部门列表响应
type respDeptList struct {
respCommon
// TODO: 不要懒惰,把 API 层的类型写好
Department []*DeptInfo `json:"department"`
}
// reqDeptSimpleList 获取子部门ID列表
type reqDeptSimpleList struct {
HaveID bool
ID int64
}
var _ urlValuer = reqDeptSimpleList{}
func (x reqDeptSimpleList) intoURLValues() url.Values {
if !x.HaveID {
return url.Values{}
}
return url.Values{
"id": {strconv.FormatInt(x.ID, 10)},
}
}
// respDeptSimpleList 部门列表响应
type respDeptSimpleList struct {
respCommon
DepartmentIDs []*DeptInfo `json:"department_id"`
}
// reqAppchatGet 获取群聊会话请求
type reqAppchatGet struct {
ChatID string
}
var _ urlValuer = reqAppchatGet{}
func (x reqAppchatGet) intoURLValues() url.Values {
return url.Values{
"chatid": {x.ChatID},
}
}
// respAppchatGet 获取群聊会话响应
type respAppchatGet struct {
respCommon
ChatInfo *ChatInfo `json:"chat_info"`
}
// reqAppchatCreate 创建群聊会话请求
type reqAppchatCreate struct {
ChatInfo *ChatInfo
}
var _ bodyer = reqAppchatCreate{}
func (x reqAppchatCreate) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x.ChatInfo)
}
// respAppchatCreate 创建群聊会话响应
type respAppchatCreate struct {
respCommon
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
Media *Media
}
var _ urlValuer = reqMediaUpload{}
var _ mediaUploader = reqMediaUpload{}
func (x reqMediaUpload) intoURLValues() url.Values {
return url.Values{
"type": {x.Type},
}
}
func (x reqMediaUpload) getMedia() *Media {
return x.Media
}
// respMediaUpload 临时素材上传响应
type respMediaUpload struct {
respCommon
Type string `json:"type"`
MediaID string `json:"media_id"`
CreatedAt string `json:"created_at"`
}
// reqMediaUploadImg 永久图片素材上传请求
type reqMediaUploadImg struct {
Media *Media
}
var _ urlValuer = reqMediaUploadImg{}
var _ mediaUploader = reqMediaUploadImg{}
func (x reqMediaUploadImg) intoURLValues() url.Values {
return url.Values{}
}
func (x reqMediaUploadImg) getMedia() *Media {
return x.Media
}
// respMediaUploadImg 永久图片素材上传响应
type respMediaUploadImg struct {
respCommon
URL string `json:"url"`
}
// reqExternalContactList 获取客户列表
type reqExternalContactList struct {
UserID string `json:"userid"`
}
var _ urlValuer = reqExternalContactList{}
func (x reqExternalContactList) intoURLValues() url.Values {
return url.Values{
"userid": {x.UserID},
}
}
// respExternalContactList 获取客户列表
type respExternalContactList struct {
respCommon
ExternalUserID []string `json:"external_userid"`
}
// reqExternalContactGet 获取客户详情
type reqExternalContactGet struct {
ExternalUserID string `json:"external_userid"`
}
var _ urlValuer = reqExternalContactGet{}
func (x reqExternalContactGet) intoURLValues() url.Values {
return url.Values{
"external_userid": {x.ExternalUserID},
}
}
// respExternalContactGet 获取客户详情
type respExternalContactGet struct {
respCommon
ExternalContactInfo
}
// ExternalContactInfo 外部联系人信息
type ExternalContactInfo struct {
ExternalContact ExternalContact `json:"external_contact"`
FollowUser []FollowUser `json:"follow_user"`
}
// ExternalContactBatchInfo 外部联系人信息
type ExternalContactBatchInfo struct {
ExternalContact ExternalContact `json:"external_contact"`
FollowInfo FollowInfo `json:"follow_info"`
}
// BatchListExternalContactsResp 外部联系人信息
type BatchListExternalContactsResp struct {
Result []ExternalContactBatchInfo
NextCursor string
}
// reqExternalContactBatchList 批量获取客户详情
type reqExternalContactBatchList struct {
UserID string `json:"userid"`
Cursor string `json:"cursor"`
Limit int `json:"limit"`
}
var _ bodyer = reqExternalContactBatchList{}
func (x reqExternalContactBatchList) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}
// respExternalContactBatchList 批量获取客户详情
type respExternalContactBatchList struct {
respCommon
NextCursor string `json:"next_cursor"`
ExternalContactList []ExternalContactBatchInfo `json:"external_contact_list"`
}
// reqExternalContactRemark 获取客户详情
type reqExternalContactRemark struct {
Remark *ExternalContactRemark
}
var _ bodyer = reqExternalContactRemark{}
func (x reqExternalContactRemark) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x.Remark)
}
// respExternalContactRemark 获取客户详情
type respExternalContactRemark struct {
respCommon
}
// reqUserInfoGet 获取访问用户身份
type reqUserInfoGet struct {
// 通过成员授权获取到的code,最大为512字节。每次成员授权带上的code将不一样,code只能使用一次,5分钟未被使用自动过期。
Code string
}
var _ urlValuer = reqUserInfoGet{}
func (x reqUserInfoGet) intoURLValues() url.Values {
return url.Values{
"code": {x.Code},
}
}
// respUserInfoGet 部门列表响应
type respUserInfoGet struct {
respCommon
UserIdentityInfo
}
// reqExternalContactListCorpTags 获取企业标签库
type reqExternalContactListCorpTags struct {
// 要查询的标签id,如果不填则获取该企业的所有客户标签,目前暂不支持标签组id
TagIDs []string `json:"tag_id"`
}
var _ bodyer = reqExternalContactListCorpTags{}
func (x reqExternalContactListCorpTags) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}
// respExternalContactListCorpTags 获取企业标签库
type respExternalContactListCorpTags struct {
respCommon
// 标签组列表
TagGroup []ExternalContactCorpTagGroup `json:"tag_group"`
}
// reqExternalContactAddCorpTag 添加企业客户标签
type reqExternalContactAddCorpTag struct {
ExternalContactCorpTagGroup
}
var _ bodyer = reqExternalContactAddCorpTag{}
func (x reqExternalContactAddCorpTag) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x.ExternalContactCorpTagGroup)
}
// respExternalContactAddCorpTag 添加企业客户标签
type respExternalContactAddCorpTag struct {
respCommon
// 标签组列表
TagGroup ExternalContactCorpTagGroup `json:"tag_group"`
}
// reqExternalContactEditCorpTag 编辑企业客户标签
type reqExternalContactEditCorpTag struct {
ID string `json:"id"`
Name string `json:"name"`
Order uint32 `json:"order"`
}
var _ bodyer = reqExternalContactEditCorpTag{}
func (x reqExternalContactEditCorpTag) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}
// respExternalContactEditCorpTag 编辑企业客户标签
type respExternalContactEditCorpTag struct {
respCommon
}
// reqExternalContactDelCorpTag 删除企业客户标签
type reqExternalContactDelCorpTag struct {
TagID []string `json:"tag_id"`
GroupID []string `json:"group_id"`
}
var _ bodyer = reqExternalContactDelCorpTag{}
func (x reqExternalContactDelCorpTag) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}
// respExternalContactDelCorpTag 删除企业客户标签
type respExternalContactDelCorpTag struct {
respCommon
}
// reqExternalContactMarkTag 编辑企业客户标签
type reqExternalContactMarkTag struct {
UserID string `json:"userid"`
ExternalUserID string `json:"external_userid"`
AddTag []string `json:"add_tag"`
RemoveTag []string `json:"remove_tag"`
}
var _ bodyer = reqExternalContactMarkTag{}
func (x reqExternalContactMarkTag) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}
// respExternalContactMarkTag 编辑企业客户标签
type respExternalContactMarkTag struct {
respCommon
}
// reqJSCode2Session 临时登录凭证校验
type reqJSCode2Session struct {
JSCode string
}
var _ urlValuer = reqJSCode2Session{}
func (x reqJSCode2Session) intoURLValues() url.Values {
return url.Values{
"js_code": {x.JSCode},
"grant_type": {"authorization_code"},
}
}
// respJSCode2Session 临时登录凭证校验
type respJSCode2Session struct {
respCommon
JSCodeSession
}
// JSCodeSession 临时登录凭证
type JSCodeSession struct {
CorpID string `json:"corpid"`
UserID string `json:"userid"`
SessionKey string `json:"session_key"`
}
// reqAuthCode2UserInfo 获取访问用户身份
type reqAuthCode2UserInfo struct {
Code string
}
var _ urlValuer = reqAuthCode2UserInfo{}
func (x reqAuthCode2UserInfo) intoURLValues() url.Values {
return url.Values{
"code": {x.Code},
}
}
// respAuthCode2UserInfo 获取访问用户身份响应
type respAuthCode2UserInfo struct {
respCommon
AuthCodeUserInfo
}
// AuthCodeUserInfo 访问用户身份
type AuthCodeUserInfo struct {
UserID string `json:"userid,omitempty"`
UserTicket string `json:"user_ticket,omitempty"`
OpenID string `json:"openid,omitempty"`
ExternalUserID string `json:"external_userid,omitempty"`
}
type reqMsgAuditListPermitUser struct {
MsgAuditEdition MsgAuditEdition `json:"type"`
}
var _ bodyer = reqMsgAuditListPermitUser{}
func (x reqMsgAuditListPermitUser) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}
type respMsgAuditListPermitUser struct {
respCommon
IDs []string `json:"ids"`
}
type reqMsgAuditCheckSingleAgree struct {
Infos []CheckMsgAuditSingleAgreeUserInfo `json:"info"`
}
var _ bodyer = reqMsgAuditCheckSingleAgree{}
func (x reqMsgAuditCheckSingleAgree) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}
type respMsgAuditCheckSingleAgree struct {
respCommon
AgreeInfo []struct {
UserID string `json:"userid"`
ExternalOpenID string `json:"exteranalopenid"`
AgreeStatus MsgAuditAgreeStatus `json:"agree_status"`
StatusChangeTime int `json:"status_change_time"`
} `json:"agreeinfo"`
}
func (x respMsgAuditCheckSingleAgree) intoCheckSingleAgreeInfoList() (resp []CheckMsgAuditSingleAgreeInfo) {
for _, agreeInfo := range x.AgreeInfo {
resp = append(resp, CheckMsgAuditSingleAgreeInfo{
CheckMsgAuditSingleAgreeUserInfo: CheckMsgAuditSingleAgreeUserInfo{
UserID: agreeInfo.UserID,
ExternalOpenID: agreeInfo.ExternalOpenID,
},
AgreeStatus: agreeInfo.AgreeStatus,
StatusChangeTime: time.Unix(int64(agreeInfo.StatusChangeTime), 0),
})
}
return resp
}
type reqMsgAuditCheckRoomAgree struct {
RoomID string `json:"roomid"`
}
var _ bodyer = reqMsgAuditCheckRoomAgree{}
func (x reqMsgAuditCheckRoomAgree) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}
type respMsgAuditCheckRoomAgree struct {
respCommon
AgreeInfo []struct {
StatusChangeTime int `json:"status_change_time"`
AgreeStatus MsgAuditAgreeStatus `json:"agree_status"`
ExternalOpenID string `json:"exteranalopenid"`
} `json:"agreeinfo"`
}
func (x respMsgAuditCheckRoomAgree) intoCheckRoomAgreeInfoList() (resp []CheckMsgAuditRoomAgreeInfo) {
for _, agreeInfo := range x.AgreeInfo {
resp = append(resp, CheckMsgAuditRoomAgreeInfo{
StatusChangeTime: time.Unix(int64(agreeInfo.StatusChangeTime), 0),
AgreeStatus: agreeInfo.AgreeStatus,
ExternalOpenID: agreeInfo.ExternalOpenID,
})
}
return resp
}
type reqMsgAuditGetGroupChat struct {
RoomID string `json:"roomid"`
}
var _ bodyer = reqMsgAuditGetGroupChat{}
func (x reqMsgAuditGetGroupChat) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}
type respMsgAuditGetGroupChat struct {
respCommon
Members []struct {
MemberID string `json:"memberid"`
JoinTime int `json:"jointime"`
} `json:"members"`
RoomName string `json:"roomname"`
Creator string `json:"creator"`
RoomCreateTime int `json:"room_create_time"`
Notice string `json:"notice"`
}
func (x respMsgAuditGetGroupChat) intoGroupChat() (resp MsgAuditGroupChat) {
resp.Creator = x.Creator
resp.Notice = x.Notice
resp.RoomName = x.RoomName
resp.RoomCreateTime = time.Unix(int64(x.RoomCreateTime), 0)
for _, member := range x.Members {
resp.Members = append(resp.Members, MsgAuditGroupChatMember{
MemberID: member.MemberID,
JoinTime: time.Unix(int64(member.JoinTime), 0),
})
}
return resp
}
type reqListUnassignedExternalContact struct {
// PageID 分页查询,要查询页号,从0开始
PageID uint32 `json:"page_id"`
// PageSize 每次返回的最大记录数,默认为1000,最大值为1000
PageSize uint32 `json:"page_size"`
// Cursor 分页查询游标,字符串类型,适用于数据量较大的情况,如果使用该参数则无需填写page_id,该参数由上一次调用返回
Cursor string `json:"cursor"`
}
var _ bodyer = reqListUnassignedExternalContact{}
func (x reqListUnassignedExternalContact) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}
type respListUnassignedExternalContact struct {
respCommon
Info []struct {
HandoverUserID string `json:"handover_userid"`
ExternalUserID string `json:"external_userid"`
DemissionTime int `json:"dimission_time"`
} `json:"info"`
IsLast bool `json:"is_last"`
NextCursor string `json:"next_cursor"`
}
func (x respListUnassignedExternalContact) intoExternalContactUnassignedList() (resp ExternalContactUnassignedList) {
list := make([]ExternalContactUnassigned, 0, len(x.Info))
for _, info := range x.Info {
list = append(list, ExternalContactUnassigned{
HandoverUserID: info.HandoverUserID,
ExternalUserID: info.ExternalUserID,
DemissionTime: time.Unix(int64(info.DemissionTime), 0),
})
}
resp.Info = list
resp.IsLast = x.IsLast
resp.NextCursor = x.NextCursor
return resp
}
type reqTransferExternalContact struct {
// ExternalUserID 外部联系人的userid,注意不是企业成员的帐号
ExternalUserID string `json:"external_userid"`
// HandoverUserID 原跟进成员的userid
HandoverUserID string `json:"handover_userid"`
// TakeoverUserID 接替成员的userid
TakeoverUserID string `json:"takeover_userid"`
// TransferSuccessMsg 转移成功后发给客户的消息,最多200个字符,不填则使用默认文案,目前只对在职成员分配客户的情况生效
TransferSuccessMsg string `json:"transfer_success_msg"`
}
var _ bodyer = reqTransferExternalContact{}
func (x reqTransferExternalContact) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}
type respTransferExternalContact struct {
respCommon
}
type reqGetTransferExternalContactResult struct {
// ExternalUserID 外部联系人的userid,注意不是企业成员的帐号
ExternalUserID string `json:"external_userid"`
// HandoverUserID 原跟进成员的userid
HandoverUserID string `json:"handover_userid"`
// TakeoverUserID 接替成员的userid
TakeoverUserID string `json:"takeover_userid"`
}
var _ bodyer = reqGetTransferExternalContactResult{}
func (x reqGetTransferExternalContactResult) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}
type respGetTransferExternalContactResult struct {
respCommon
Status uint8 `json:"status"`
TakeoverTime int `json:"takeover_time"`
}
func (x respGetTransferExternalContactResult) intoExternalContactTransferResult() ExternalContactTransferResult {
return ExternalContactTransferResult{
Status: ExternalContactTransferStatus(x.Status),
TakeoverTime: time.Unix(int64(x.TakeoverTime), 0),
}
}
type reqTransferGroupChatExternalContact struct {
// ChatIDList 需要转群主的客户群ID列表。取值范围: 1 ~ 100
ChatIDList []string `json:"chat_id_list"`
// NewOwner 新群主ID
NewOwner string `json:"new_owner"`
}
var _ bodyer = reqTransferGroupChatExternalContact{}
func (x reqTransferGroupChatExternalContact) intoBody() ([]byte, error) {
return marshalIntoJSONBody(x)
}
type respTransferGroupChatExternalContact struct {
respCommon
FailedChatList []ExternalContactGroupChatTransferFailed `json:"failed_chat_list"`
}
type reqOAGetTemplateDetail struct {