forked from larksuite/oapi-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 2
/
contact_event_dispatch.go
215 lines (200 loc) · 12.3 KB
/
contact_event_dispatch.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
// Package dispatcher code generated by oapi sdk gen
/*
* MIT License
*
* Copyright (c) 2022 Lark Technologies Pte. Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package dispatcher
import (
"context"
"github.com/Yucheng123/oapi-sdk-go/v3/service/contact/v3"
)
// 成员字段变更
//
// - 通过该事件订阅成员字段变更。old_object 展示更新字段的原始值。
//
// - 触发事件的动作有「打开/关闭」开关、「增加/删除」成员字段。
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/custom_attr_event/events/updated
func (dispatcher *EventDispatcher) OnP2CustomAttrEventUpdatedV3(handler func(ctx context.Context, event *larkcontact.P2CustomAttrEventUpdatedV3) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["contact.custom_attr_event.updated_v3"]
if existed {
panic("event: multiple handler registrations for " + "contact.custom_attr_event.updated_v3")
}
dispatcher.eventType2EventHandler["contact.custom_attr_event.updated_v3"] = larkcontact.NewP2CustomAttrEventUpdatedV3Handler(handler)
return dispatcher
}
// 部门被创建
//
// - 创建通讯录部门时发送该事件给订阅应用。
//
// - 只有当应用拥有被改动字段的数据权限时,才会接收到事件。具体的数据权限与字段的关系请参考[应用权限](https://open.feishu.cn/document/ukTMukTMukTM/uQjN3QjL0YzN04CN2cDN),或查看事件体参数列表的字段描述。
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/department/events/created
func (dispatcher *EventDispatcher) OnP2DepartmentCreatedV3(handler func(ctx context.Context, event *larkcontact.P2DepartmentCreatedV3) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["contact.department.created_v3"]
if existed {
panic("event: multiple handler registrations for " + "contact.department.created_v3")
}
dispatcher.eventType2EventHandler["contact.department.created_v3"] = larkcontact.NewP2DepartmentCreatedV3Handler(handler)
return dispatcher
}
// 部门被删除
//
// - 订阅这一事件可以获得被删除部门的信息。
//
// - 只有当应用拥有被改动字段的数据权限时,才会接收到事件。具体的数据权限与字段的关系请参考[应用权限](https://open.feishu.cn/document/ukTMukTMukTM/uQjN3QjL0YzN04CN2cDN),或查看事件体参数列表的字段描述。
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/department/events/deleted
func (dispatcher *EventDispatcher) OnP2DepartmentDeletedV3(handler func(ctx context.Context, event *larkcontact.P2DepartmentDeletedV3) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["contact.department.deleted_v3"]
if existed {
panic("event: multiple handler registrations for " + "contact.department.deleted_v3")
}
dispatcher.eventType2EventHandler["contact.department.deleted_v3"] = larkcontact.NewP2DepartmentDeletedV3Handler(handler)
return dispatcher
}
// 部门信息被修改
//
// - 通过该事件订阅部门更新。`old_object`只展示被更新字段的原始值。应用身份访问通讯录的权限为历史版本,不推荐申请。
//
// - 只有当应用拥有被改动字段的数据权限时,才会接收到事件。具体的数据权限与字段的关系请参考[应用权限](https://open.feishu.cn/document/ukTMukTMukTM/uQjN3QjL0YzN04CN2cDN),或查看事件体参数列表的字段描述。
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/department/events/updated
func (dispatcher *EventDispatcher) OnP2DepartmentUpdatedV3(handler func(ctx context.Context, event *larkcontact.P2DepartmentUpdatedV3) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["contact.department.updated_v3"]
if existed {
panic("event: multiple handler registrations for " + "contact.department.updated_v3")
}
dispatcher.eventType2EventHandler["contact.department.updated_v3"] = larkcontact.NewP2DepartmentUpdatedV3Handler(handler)
return dispatcher
}
// 启用人员类型事件
//
// - 启用人员类型会发出对应事件。
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/employee_type_enum/events/actived
func (dispatcher *EventDispatcher) OnP2EmployeeTypeEnumActivedV3(handler func(ctx context.Context, event *larkcontact.P2EmployeeTypeEnumActivedV3) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["contact.employee_type_enum.actived_v3"]
if existed {
panic("event: multiple handler registrations for " + "contact.employee_type_enum.actived_v3")
}
dispatcher.eventType2EventHandler["contact.employee_type_enum.actived_v3"] = larkcontact.NewP2EmployeeTypeEnumActivedV3Handler(handler)
return dispatcher
}
// 新建人员类型事件
//
// - 新建人员类型会发出对应事件。
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/employee_type_enum/events/created
func (dispatcher *EventDispatcher) OnP2EmployeeTypeEnumCreatedV3(handler func(ctx context.Context, event *larkcontact.P2EmployeeTypeEnumCreatedV3) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["contact.employee_type_enum.created_v3"]
if existed {
panic("event: multiple handler registrations for " + "contact.employee_type_enum.created_v3")
}
dispatcher.eventType2EventHandler["contact.employee_type_enum.created_v3"] = larkcontact.NewP2EmployeeTypeEnumCreatedV3Handler(handler)
return dispatcher
}
// 停用人员类型事件
//
// - 停用人员类型会发出对应事件。
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/employee_type_enum/events/deactivated
func (dispatcher *EventDispatcher) OnP2EmployeeTypeEnumDeactivatedV3(handler func(ctx context.Context, event *larkcontact.P2EmployeeTypeEnumDeactivatedV3) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["contact.employee_type_enum.deactivated_v3"]
if existed {
panic("event: multiple handler registrations for " + "contact.employee_type_enum.deactivated_v3")
}
dispatcher.eventType2EventHandler["contact.employee_type_enum.deactivated_v3"] = larkcontact.NewP2EmployeeTypeEnumDeactivatedV3Handler(handler)
return dispatcher
}
// 删除人员类型事件
//
// - 删除人员类型会发出对应事件。
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/employee_type_enum/events/deleted
func (dispatcher *EventDispatcher) OnP2EmployeeTypeEnumDeletedV3(handler func(ctx context.Context, event *larkcontact.P2EmployeeTypeEnumDeletedV3) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["contact.employee_type_enum.deleted_v3"]
if existed {
panic("event: multiple handler registrations for " + "contact.employee_type_enum.deleted_v3")
}
dispatcher.eventType2EventHandler["contact.employee_type_enum.deleted_v3"] = larkcontact.NewP2EmployeeTypeEnumDeletedV3Handler(handler)
return dispatcher
}
// 修改人员类型名称事件
//
// - 修改人员类型名称会发出对应事件。
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/employee_type_enum/events/updated
func (dispatcher *EventDispatcher) OnP2EmployeeTypeEnumUpdatedV3(handler func(ctx context.Context, event *larkcontact.P2EmployeeTypeEnumUpdatedV3) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["contact.employee_type_enum.updated_v3"]
if existed {
panic("event: multiple handler registrations for " + "contact.employee_type_enum.updated_v3")
}
dispatcher.eventType2EventHandler["contact.employee_type_enum.updated_v3"] = larkcontact.NewP2EmployeeTypeEnumUpdatedV3Handler(handler)
return dispatcher
}
// 通讯录范围权限被更新
//
// - 当应用通讯录范围权限发生变更时,订阅这个事件的应用会收到事件。
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/scope/events/updated
func (dispatcher *EventDispatcher) OnP2ScopeUpdatedV3(handler func(ctx context.Context, event *larkcontact.P2ScopeUpdatedV3) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["contact.scope.updated_v3"]
if existed {
panic("event: multiple handler registrations for " + "contact.scope.updated_v3")
}
dispatcher.eventType2EventHandler["contact.scope.updated_v3"] = larkcontact.NewP2ScopeUpdatedV3Handler(handler)
return dispatcher
}
// 员工入职
//
// - 通过该事件订阅员工入职。
//
// - 只有当应用拥有被改动字段的数据权限时,才会接收到事件。具体的数据权限与字段的关系请参考[应用权限](https://open.feishu.cn/document/ukTMukTMukTM/uQjN3QjL0YzN04CN2cDN),或查看事件体参数列表的字段描述。
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/user/events/created
func (dispatcher *EventDispatcher) OnP2UserCreatedV3(handler func(ctx context.Context, event *larkcontact.P2UserCreatedV3) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["contact.user.created_v3"]
if existed {
panic("event: multiple handler registrations for " + "contact.user.created_v3")
}
dispatcher.eventType2EventHandler["contact.user.created_v3"] = larkcontact.NewP2UserCreatedV3Handler(handler)
return dispatcher
}
// 员工离职
//
// - 通过该事件订阅员工离职。应用身份访问通讯录的权限为历史版本,不推荐申请。
//
// - 只有当应用拥有被改动字段的数据权限时,才会接收到事件。具体的数据权限与字段的关系请参考[应用权限](https://open.feishu.cn/document/ukTMukTMukTM/uQjN3QjL0YzN04CN2cDN),或查看事件体参数列表的字段描述。
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/user/events/deleted
func (dispatcher *EventDispatcher) OnP2UserDeletedV3(handler func(ctx context.Context, event *larkcontact.P2UserDeletedV3) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["contact.user.deleted_v3"]
if existed {
panic("event: multiple handler registrations for " + "contact.user.deleted_v3")
}
dispatcher.eventType2EventHandler["contact.user.deleted_v3"] = larkcontact.NewP2UserDeletedV3Handler(handler)
return dispatcher
}
// 员工变更
//
// - 通过该事件订阅员工变更。old_object中只展示更新的字段的原始值。
//
// - 只有当应用拥有被改动字段的数据权限时,才会接收到事件。具体的数据权限与字段的关系请参考[应用权限](https://open.feishu.cn/document/ukTMukTMukTM/uQjN3QjL0YzN04CN2cDN),或查看事件体参数列表的字段描述。
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/user/events/updated
func (dispatcher *EventDispatcher) OnP2UserUpdatedV3(handler func(ctx context.Context, event *larkcontact.P2UserUpdatedV3) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["contact.user.updated_v3"]
if existed {
panic("event: multiple handler registrations for " + "contact.user.updated_v3")
}
dispatcher.eventType2EventHandler["contact.user.updated_v3"] = larkcontact.NewP2UserUpdatedV3Handler(handler)
return dispatcher
}