Skip to content

Commit

Permalink
feat: update api
Browse files Browse the repository at this point in the history
  • Loading branch information
maemual committed May 9, 2024
1 parent 75619d7 commit b4f7e79
Show file tree
Hide file tree
Showing 64 changed files with 12,519 additions and 2,189 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
## 安装

```shell
go get -u github.com/larksuite/oapi-sdk-go/[email protected].4
go get -u github.com/larksuite/oapi-sdk-go/[email protected].5
```

## API Client
Expand Down
320 changes: 159 additions & 161 deletions client.go

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions event/dispatcher/acs_v1_event_dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,31 @@ import (
"context"
"github.com/larksuite/oapi-sdk-go/v3/service/acs/v1"
)

// 新增门禁访问记录
//
// - 门禁设备识别用户成功后发送该事件给订阅应用。
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/acs-v1/access_record/events/created
func ( dispatcher * EventDispatcher ) OnP2AccessRecordCreatedV1(handler func(ctx context.Context, event *larkacs.P2AccessRecordCreatedV1) error) * EventDispatcher{
func (dispatcher *EventDispatcher) OnP2AccessRecordCreatedV1(handler func(ctx context.Context, event *larkacs.P2AccessRecordCreatedV1) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["acs.access_record.created_v1"]
if existed {
panic("event: multiple handler registrations for " + "acs.access_record.created_v1")
}
dispatcher.eventType2EventHandler["acs.access_record.created_v1"] = larkacs.NewP2AccessRecordCreatedV1Handler(handler)
return dispatcher
}

// 用户信息变更
//
// - 智能门禁用户特征值变化时,发送此事件。
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/acs-v1/user/events/updated
func ( dispatcher * EventDispatcher ) OnP2UserUpdatedV1(handler func(ctx context.Context, event *larkacs.P2UserUpdatedV1) error) * EventDispatcher{
func (dispatcher *EventDispatcher) OnP2UserUpdatedV1(handler func(ctx context.Context, event *larkacs.P2UserUpdatedV1) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["acs.user.updated_v1"]
if existed {
panic("event: multiple handler registrations for " + "acs.user.updated_v1")
}
dispatcher.eventType2EventHandler["acs.user.updated_v1"] = larkacs.NewP2UserUpdatedV1Handler(handler)
return dispatcher
}
}
30 changes: 18 additions & 12 deletions event/dispatcher/application_v6_event_dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,107 +17,113 @@ import (
"context"
"github.com/larksuite/oapi-sdk-go/v3/service/application/v6"
)

// 应用创建
//
// - 当企业内有新的应用被创建时推送此事件
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v6/application/events/created
func ( dispatcher * EventDispatcher ) OnP2ApplicationCreatedV6(handler func(ctx context.Context, event *larkapplication.P2ApplicationCreatedV6) error) * EventDispatcher{
func (dispatcher *EventDispatcher) OnP2ApplicationCreatedV6(handler func(ctx context.Context, event *larkapplication.P2ApplicationCreatedV6) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["application.application.created_v6"]
if existed {
panic("event: multiple handler registrations for " + "application.application.created_v6")
}
dispatcher.eventType2EventHandler["application.application.created_v6"] = larkapplication.NewP2ApplicationCreatedV6Handler(handler)
return dispatcher
}

// 应用审核
//
// - 通过订阅该事件,可接收应用审核(通过 / 拒绝)事件
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v6/application-app_version/events/audit
func ( dispatcher * EventDispatcher ) OnP2ApplicationAppVersionAuditV6(handler func(ctx context.Context, event *larkapplication.P2ApplicationAppVersionAuditV6) error) * EventDispatcher{
func (dispatcher *EventDispatcher) OnP2ApplicationAppVersionAuditV6(handler func(ctx context.Context, event *larkapplication.P2ApplicationAppVersionAuditV6) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["application.application.app_version.audit_v6"]
if existed {
panic("event: multiple handler registrations for " + "application.application.app_version.audit_v6")
}
dispatcher.eventType2EventHandler["application.application.app_version.audit_v6"] = larkapplication.NewP2ApplicationAppVersionAuditV6Handler(handler)
return dispatcher
}

// 申请发布应用
//
// - 通过订阅该事件,可接收应用提交发布申请事件
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v6/application-app_version/events/publish_apply
func ( dispatcher * EventDispatcher ) OnP2ApplicationAppVersionPublishApplyV6(handler func(ctx context.Context, event *larkapplication.P2ApplicationAppVersionPublishApplyV6) error) * EventDispatcher{
func (dispatcher *EventDispatcher) OnP2ApplicationAppVersionPublishApplyV6(handler func(ctx context.Context, event *larkapplication.P2ApplicationAppVersionPublishApplyV6) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["application.application.app_version.publish_apply_v6"]
if existed {
panic("event: multiple handler registrations for " + "application.application.app_version.publish_apply_v6")
}
dispatcher.eventType2EventHandler["application.application.app_version.publish_apply_v6"] = larkapplication.NewP2ApplicationAppVersionPublishApplyV6Handler(handler)
return dispatcher
}

// 撤回应用发布申请
//
// - 通过订阅该事件,可接收应用撤回发布申请事件
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v6/application-app_version/events/publish_revoke
func ( dispatcher * EventDispatcher ) OnP2ApplicationAppVersionPublishRevokeV6(handler func(ctx context.Context, event *larkapplication.P2ApplicationAppVersionPublishRevokeV6) error) * EventDispatcher{
func (dispatcher *EventDispatcher) OnP2ApplicationAppVersionPublishRevokeV6(handler func(ctx context.Context, event *larkapplication.P2ApplicationAppVersionPublishRevokeV6) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["application.application.app_version.publish_revoke_v6"]
if existed {
panic("event: multiple handler registrations for " + "application.application.app_version.publish_revoke_v6")
}
dispatcher.eventType2EventHandler["application.application.app_version.publish_revoke_v6"] = larkapplication.NewP2ApplicationAppVersionPublishRevokeV6Handler(handler)
return dispatcher
}

// 新增应用反馈
//
// - 当应用收到新反馈时,触发该事件
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v6/application-feedback/events/created
func ( dispatcher * EventDispatcher ) OnP2ApplicationFeedbackCreatedV6(handler func(ctx context.Context, event *larkapplication.P2ApplicationFeedbackCreatedV6) error) * EventDispatcher{
func (dispatcher *EventDispatcher) OnP2ApplicationFeedbackCreatedV6(handler func(ctx context.Context, event *larkapplication.P2ApplicationFeedbackCreatedV6) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["application.application.feedback.created_v6"]
if existed {
panic("event: multiple handler registrations for " + "application.application.feedback.created_v6")
}
dispatcher.eventType2EventHandler["application.application.feedback.created_v6"] = larkapplication.NewP2ApplicationFeedbackCreatedV6Handler(handler)
return dispatcher
}

// 反馈更新
//
// - 当反馈的处理状态被更新时,触发该事件
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v6/application-feedback/events/updated
func ( dispatcher * EventDispatcher ) OnP2ApplicationFeedbackUpdatedV6(handler func(ctx context.Context, event *larkapplication.P2ApplicationFeedbackUpdatedV6) error) * EventDispatcher{
func (dispatcher *EventDispatcher) OnP2ApplicationFeedbackUpdatedV6(handler func(ctx context.Context, event *larkapplication.P2ApplicationFeedbackUpdatedV6) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["application.application.feedback.updated_v6"]
if existed {
panic("event: multiple handler registrations for " + "application.application.feedback.updated_v6")
}
dispatcher.eventType2EventHandler["application.application.feedback.updated_v6"] = larkapplication.NewP2ApplicationFeedbackUpdatedV6Handler(handler)
return dispatcher
}
//
//
// -

// -
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v6/event/app-availability-scope-extended
func ( dispatcher * EventDispatcher ) OnP2ApplicationVisibilityAddedV6(handler func(ctx context.Context, event *larkapplication.P2ApplicationVisibilityAddedV6) error) * EventDispatcher{
func (dispatcher *EventDispatcher) OnP2ApplicationVisibilityAddedV6(handler func(ctx context.Context, event *larkapplication.P2ApplicationVisibilityAddedV6) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["application.application.visibility.added_v6"]
if existed {
panic("event: multiple handler registrations for " + "application.application.visibility.added_v6")
}
dispatcher.eventType2EventHandler["application.application.visibility.added_v6"] = larkapplication.NewP2ApplicationVisibilityAddedV6Handler(handler)
return dispatcher
}

// 机器人自定义菜单
//
// - 当用户点击类型为事件的机器人菜单时触发
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v6/bot/events/menu
func ( dispatcher * EventDispatcher ) OnP2BotMenuV6(handler func(ctx context.Context, event *larkapplication.P2BotMenuV6) error) * EventDispatcher{
func (dispatcher *EventDispatcher) OnP2BotMenuV6(handler func(ctx context.Context, event *larkapplication.P2BotMenuV6) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["application.bot.menu_v6"]
if existed {
panic("event: multiple handler registrations for " + "application.bot.menu_v6")
}
dispatcher.eventType2EventHandler["application.bot.menu_v6"] = larkapplication.NewP2BotMenuV6Handler(handler)
return dispatcher
}
}
9 changes: 4 additions & 5 deletions event/dispatcher/approval_v4_event_dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ import (
"context"
"github.com/larksuite/oapi-sdk-go/v3/service/approval/v4"
)
//
//
// -

// -
//
// - 事件描述文档链接:https://open.feishu.cn/document/ukTMukTMukTM/uIDO24iM4YjLygjN/event/custom-approval-event
func ( dispatcher * EventDispatcher ) OnP2ApprovalUpdatedV4(handler func(ctx context.Context, event *larkapproval.P2ApprovalUpdatedV4) error) * EventDispatcher{
func (dispatcher *EventDispatcher) OnP2ApprovalUpdatedV4(handler func(ctx context.Context, event *larkapproval.P2ApprovalUpdatedV4) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["approval.approval.updated_v4"]
if existed {
panic("event: multiple handler registrations for " + "approval.approval.updated_v4")
}
dispatcher.eventType2EventHandler["approval.approval.updated_v4"] = larkapproval.NewP2ApprovalUpdatedV4Handler(handler)
return dispatcher
}
}
14 changes: 9 additions & 5 deletions event/dispatcher/calendar_v4_event_dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,63 +17,67 @@ import (
"context"
"github.com/larksuite/oapi-sdk-go/v3/service/calendar/v4"
)

// 日历变更
//
// - 当订阅用户的日历列表有日历变动时触发此事件。
//
// - 应用首先需要调用上述接口建立订阅关系。应用收到该事件后,使用事件的 user_list 字段中的用户对应的 user_access_token 调用[获取日历列表](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/calendar-v4/calendar/list)接口拉取增量的变更数据
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/calendar-v4/calendar/events/changed
func ( dispatcher * EventDispatcher ) OnP2CalendarChangedV4(handler func(ctx context.Context, event *larkcalendar.P2CalendarChangedV4) error) * EventDispatcher{
func (dispatcher *EventDispatcher) OnP2CalendarChangedV4(handler func(ctx context.Context, event *larkcalendar.P2CalendarChangedV4) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["calendar.calendar.changed_v4"]
if existed {
panic("event: multiple handler registrations for " + "calendar.calendar.changed_v4")
}
dispatcher.eventType2EventHandler["calendar.calendar.changed_v4"] = larkcalendar.NewP2CalendarChangedV4Handler(handler)
return dispatcher
}

// ACL新建
//
// - 当被订阅的日历上有ACL被创建时触发此事件。
//
// - 特殊说明:应用首先需要调用上述接口建立订阅关系。
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/calendar-v4/calendar-acl/events/created
func ( dispatcher * EventDispatcher ) OnP2CalendarAclCreatedV4(handler func(ctx context.Context, event *larkcalendar.P2CalendarAclCreatedV4) error) * EventDispatcher{
func (dispatcher *EventDispatcher) OnP2CalendarAclCreatedV4(handler func(ctx context.Context, event *larkcalendar.P2CalendarAclCreatedV4) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["calendar.calendar.acl.created_v4"]
if existed {
panic("event: multiple handler registrations for " + "calendar.calendar.acl.created_v4")
}
dispatcher.eventType2EventHandler["calendar.calendar.acl.created_v4"] = larkcalendar.NewP2CalendarAclCreatedV4Handler(handler)
return dispatcher
}

// ACL移除
//
// - 当被订阅的日历上有ACL被删除时触发此事件。
//
// - 特殊说明:应用首先需要调用上述接口建立订阅关系。
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/calendar-v4/calendar-acl/events/deleted
func ( dispatcher * EventDispatcher ) OnP2CalendarAclDeletedV4(handler func(ctx context.Context, event *larkcalendar.P2CalendarAclDeletedV4) error) * EventDispatcher{
func (dispatcher *EventDispatcher) OnP2CalendarAclDeletedV4(handler func(ctx context.Context, event *larkcalendar.P2CalendarAclDeletedV4) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["calendar.calendar.acl.deleted_v4"]
if existed {
panic("event: multiple handler registrations for " + "calendar.calendar.acl.deleted_v4")
}
dispatcher.eventType2EventHandler["calendar.calendar.acl.deleted_v4"] = larkcalendar.NewP2CalendarAclDeletedV4Handler(handler)
return dispatcher
}

// 日程变更
//
// - 当被订阅的用户日历下有日程变更时触发此事件。
//
// - 应用首先需要调用[订阅日程变更事件接口](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/calendar-v4/calendar-event/subscription)建立订阅关系。应用收到该事件后,使用事件的 user_list 字段中的用户对应的 user_access_token 调用[获取日程列表](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/calendar-v4/calendar-event/list)接口拉取事件中 calendar_id 字段对应的日历下的日程数据
//
// - 事件描述文档链接:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/calendar-v4/calendar-event/events/changed
func ( dispatcher * EventDispatcher ) OnP2CalendarEventChangedV4(handler func(ctx context.Context, event *larkcalendar.P2CalendarEventChangedV4) error) * EventDispatcher{
func (dispatcher *EventDispatcher) OnP2CalendarEventChangedV4(handler func(ctx context.Context, event *larkcalendar.P2CalendarEventChangedV4) error) *EventDispatcher {
_, existed := dispatcher.eventType2EventHandler["calendar.calendar.event.changed_v4"]
if existed {
panic("event: multiple handler registrations for " + "calendar.calendar.event.changed_v4")
}
dispatcher.eventType2EventHandler["calendar.calendar.event.changed_v4"] = larkcalendar.NewP2CalendarEventChangedV4Handler(handler)
return dispatcher
}
}
Loading

0 comments on commit b4f7e79

Please sign in to comment.