Skip to content

更新会议室预定限制

当更新会议室预定限制时,会触发该事件。

事件

项目
事件类型vc.reserve_config.updated_v1
支持的应用类型custom,isv
权限要求 订阅该事件所需的权限,开启其中任意一项权限即可订阅 开启任一权限即可vc:room 更新视频会议室信息 vc:room:readonly 获取视频会议室信息
字段权限要求> Tip: 该接口返回体中存在下列敏感字段,仅当开启对应的权限后才会返回;如果无需获取这些字段,则不建议申请 contact:user.employee_id:readonly 获取用户 user ID
推送方式Webhook

事件体

名称类型描述
schemastring事件模式
headerevent_header事件头
  └ event_idstring事件 ID
  └ event_typestring事件类型
  └ create_timestring事件创建时间戳(单位:毫秒)
  └ tokenstring事件 Token
  └ app_idstring应用 ID
  └ tenant_keystring租户 Key
event\--
  └ scope_idstring会议室或层级id
  └ scope_typeint1代表层级,2代表会议室
数据校验规则
- 取值范围:12
  └ approve_configapproval_config_event预定审批设置
    └ approval_switchint预定审批开关,0关闭,1打开
数据校验规则
- 取值范围:01
    └ approval_conditionint预定审批条件,0所有预定需要审批,1满足条件需审批
数据校验规则
- 取值范围:01
    └ meeting_durationfloat超过 meeting_duration小时需要审批
    └ approverssubscribe_user_event\[\]审批人列表
      └ user_iduser_id用户 ID
        └ union_idstring用户的 union id
        └ user_idstring用户的 user id
字段权限要求contact:user.employee_id:readonly 获取用户 user ID
        └ open_idstring用户的 open id
  └ time_configtime_config预定时间设置
    └ time_switchint预定时间开关:0 代表关闭,1 代表开启
数据校验规则
- 取值范围:01
    └ days_in_advanceint最早可提前 days_in_advance 预定会议室(单位:天,取值范围[1-730]) 说明:不填写时,默认更新为 365
    └ opening_hourstring开放当天可于 opening_hour 开始预定(单位:秒,取值范围[0,86400]) 说明: 1. 不填写时默认更新为 28800 2. 如果填写的值不是 60 的倍数,则自动会更新为离其最近的 60 整数倍的值。
    └ start_timestring每日可预定时间范围的开始时间(单位:秒,取值范围[0,86400]) 说明: 1. 不填写时,默认更新为 0 ,此时填写的 end_time 不得小于 30。 2. 当 start_time 与 end_time 均填写时, end_time 至少超过 start_time 30 。 3. 如果填写的值不是 60 的倍数,则自动会更新为离其最近的 60 整数倍的值。
    └ end_timestring每日可预定时间范围结束时间(单位:秒,取值范围[0,86400]) 说明: 1. 不填写时,默认更新为 86400 ,此时填写的 start_time 不得大于等于 86370 。 2. 当 start_time 与 end_time 均填写时, end_time 至少要超过 start_time 30。 3. 如果填写的值不是 60 的倍数,则自动会更新为离其最近的 60 整数倍的值。
    └ max_durationint单次会议室可预定时长上限(单位:小时,取值范围[1,99]) 说明:不填写时默认更新为 2
  └ reserve_scope_configreserve_scope_config_event预定范围设置
    └ allow_all_usersint可预定成员范围,0部分成员,1全部成员
数据校验规则
- 取值范围:01
    └ allow_userssubscribe_user_event\[\]可预定成员列表
      └ user_iduser_id用户 ID
        └ union_idstring用户的 union id
        └ user_idstring用户的 user id
字段权限要求contact:user.employee_id:readonly 获取用户 user ID
        └ open_idstring用户的 open id
    └ allow_deptssubscribe_department\[\]可预定部门列表
      └ department_idstring预定管理部门ID

事件体示例

json
{
    "schema": "2.0",
    "header": {
        "event_id": "5e3702a84e847582be8db7fb73283c02",
        "event_type": "vc.reserve_config.updated_v1",
        "create_time": "1608725989000",
        "token": "rvaYgkND1GOiu5MM0E1rncYC6PLtF7JV",
        "app_id": "cli_9f5343c580712544",
        "tenant_key": "2ca1d211f64f6438"
    },
    "event": {
        "scope_id": "omm_3c5dd7e09bac0c1758fcf9511bd1a771",
        "scope_type": 2,
        "approve_config": {
            "approval_switch": 0,
            "approval_condition": 0,
            "meeting_duration": 1,
            "approvers": [
                {
                    "user_id": {
                        "union_id": "on_8ed6aa67826108097d9ee143816345",
                        "user_id": "e33ggbyz",
                        "open_id": "ou_84aad35d084aa403a838cf73ee18467"
                    }
                }
            ]
        },
        "time_config": {
            "time_switch": 1,
            "days_in_advance": 30,
            "opening_hour": "27900",
            "start_time": "0",
            "end_time": "86400",
            "max_duration": 24
        },
        "reserve_scope_config": {
            "allow_all_users": 1,
            "allow_users": [
                {
                    "user_id": {
                        "union_id": "on_8ed6aa67826108097d9ee143816345",
                        "user_id": "e33ggbyz",
                        "open_id": "ou_84aad35d084aa403a838cf73ee18467"
                    }
                }
            ],
            "allow_depts": [
                {
                    "department_id": "od-47d8b570b0a011e9679a755efcc5f61a"
                }
            ]
        }
    }
}

事件订阅示例代码

事件订阅流程可参考:事件订阅概述,新手入门可参考:教程

订阅方式

长连接方式(推荐):无需发布到公网地址,在本地开发环境中即可接收事件回调,且无需处理加解密逻辑。 发送至开发者服务器:需要提供服务器公网地址。

package main

import (
	"context"
	"fmt"

	larkcore "github.com/larksuite/oapi-sdk-go/v3/core"
	larkevent "github.com/larksuite/oapi-sdk-go/v3/event"
	"github.com/larksuite/oapi-sdk-go/v3/event/dispatcher"
	"github.com/larksuite/oapi-sdk-go/v3/service/vc/v1"
	larkws "github.com/larksuite/oapi-sdk-go/v3/ws"
)

// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/golang-sdk-guide/preparations
func main() {
	// 注册事件 Register event
	eventHandler := dispatcher.NewEventDispatcher("", "").
		OnP2ReserveConfigUpdatedV1(func(ctx context.Context, event *larkvc.P2ReserveConfigUpdatedV1) error {
			fmt.Printf("[ OnP2ReserveConfigUpdatedV1 access ], data: %s\n", larkcore.Prettify(event))
			return nil
		})

	// 构建 client Build client
	cli := larkws.NewClient("YOUR_APP_ID", "YOUR_APP_SECRET",
		larkws.WithEventHandler(eventHandler),
		larkws.WithLogLevel(larkcore.LogLevelDebug),
	)

	// 建立长连接 Establish persistent connection
	err := cli.Start(context.Background())

	if err != nil {
		panic(err)
	}
}
# SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/python--sdk/preparations-before-development
import lark_oapi as lark


def do_p2_vc_reserve_config_updated_v1(data: lark.vc.v1.P2VcReserveConfigUpdatedV1) -> None:
    print(f'[ do_p2_vc_reserve_config_updated_v1 access ], data: {lark.JSON.marshal(data, indent=4)}')

# 注册事件 Register event
event_handler = lark.EventDispatcherHandler.builder("", "") \
    .register_p2_vc_reserve_config_updated_v1(do_p2_vc_reserve_config_updated_v1) \
    .build()


def main():
    # 构建 client Build client
    cli = lark.ws.Client("APP_ID", "APP_SECRET",
                        event_handler=event_handler, log_level=lark.LogLevel.DEBUG)
    # 建立长连接 Establish persistent connection
    cli.start()

if __name__ == "__main__":
    main()
package com.example.sample;

import com.lark.oapi.core.utils.Jsons;
import com.lark.oapi.service.vc.VcService;
import com.lark.oapi.service.vc.v1.model.P2ReserveConfigUpdatedV1;
import com.lark.oapi.event.EventDispatcher;
import com.lark.oapi.ws.Client;

// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/java-sdk-guide/preparations
public class Sample {
    // 注册事件 Register event
    private static final EventDispatcher EVENT_HANDLER = EventDispatcher.newBuilder("", "")
            .onP2ReserveConfigUpdatedV1(new VcService.P2ReserveConfigUpdatedV1Handler() {
                @Override
                public void handle(P2ReserveConfigUpdatedV1 event) throws Exception {
                    System.out.printf("[ onP2ReserveConfigUpdatedV1 access ], data: %s\n", Jsons.DEFAULT.toJson(event.getEvent()));
                }
            })
            .build();

    public static void main(String[] args) {
        // 构建 client Build client
        Client client = new Client.Builder("APP_ID", "APP_SECRET")
                .eventHandler(EVENT_HANDLER)
                .build();
        // 建立长连接 Establish persistent connection
        client.start();
    }
}
// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/nodejs-sdk/preparation-before-development
import * as Lark from '@larksuiteoapi/node-sdk';
const baseConfig = {
    appId: 'APP_ID',
    appSecret: 'APP_SECRET'
}
// 构建 client Build client
const wsClient = new Lark.WSClient(baseConfig);
// 建立长连接 Establish persistent connection
wsClient.start({
    // 注册事件 Register event
    eventDispatcher: new Lark.EventDispatcher({}).register({
        'vc.reserve_config.updated_v1': async (data) => {
            console.log(data);
        }
    })
});
package main

import (
	"context"
	"fmt"
	"net/http"

	larkcore "github.com/larksuite/oapi-sdk-go/v3/core"
	"github.com/larksuite/oapi-sdk-go/v3/core/httpserverext"
	larkevent "github.com/larksuite/oapi-sdk-go/v3/event"
	"github.com/larksuite/oapi-sdk-go/v3/event/dispatcher"
	"github.com/larksuite/oapi-sdk-go/v3/service/vc/v1"
)

// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/golang-sdk-guide/preparations
func main() {
	// 注册事件 Register event
	eventHandler := dispatcher.NewEventDispatcher("", "").
		OnP2ReserveConfigUpdatedV1(func(ctx context.Context, event *larkvc.P2ReserveConfigUpdatedV1) error {
			fmt.Printf("[ OnP2ReserveConfigUpdatedV1 access ], data: %s\n", larkcore.Prettify(event))
			return nil
		})

	// 创建路由处理器 Create route handler
	http.HandleFunc("/webhook/event", httpserverext.NewEventHandlerFunc(handler, larkevent.WithLogLevel(larkcore.LogLevelDebug)))

	err := http.ListenAndServe(":7777", nil)

	if err != nil {
		panic(err)
	}
}
# SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/python--sdk/preparations-before-development
from flask import Flask
from lark_oapi.adapter.flask import *
import lark_oapi as lark

app = Flask(__name__)


def do_p2_vc_reserve_config_updated_v1(data: lark.vc.v1.P2VcReserveConfigUpdatedV1) -> None:
    print(f'[ do_p2_vc_reserve_config_updated_v1 access ], data: {lark.JSON.marshal(data, indent=4)}')

# 注册事件 Register event
event_handler = lark.EventDispatcherHandler.builder("", "") \
    .register_p2_vc_reserve_config_updated_v1(do_p2_vc_reserve_config_updated_v1) \
    .build()


# 创建路由处理器 Create route handler
@app.route("/webhook/event", methods=["POST"])
def event():
    resp = event_handler.do(parse_req())
    return parse_resp(resp)

if __name__ == "__main__":
    app.run(port=7777)
package com.lark.oapi.sample.event;

import com.lark.oapi.core.utils.Jsons;
import com.lark.oapi.service.vc.VcService;
import com.lark.oapi.service.vc.v1.model.P2ReserveConfigUpdatedV1;
import com.lark.oapi.sdk.servlet.ext.ServletAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/java-sdk-guide/preparations
@RestController
public class EventController {

    // 注册事件 Register event
    private static final EventDispatcher EVENT_HANDLER = EventDispatcher.newBuilder("verificationToken", "encryptKey")
            .onP2ReserveConfigUpdatedV1(new VcService.P2ReserveConfigUpdatedV1Handler() {
                @Override
                public void handle(P2ReserveConfigUpdatedV1 event) throws Exception {
                    System.out.printf("[ onP2ReserveConfigUpdatedV1 access ], data: %s\n", Jsons.DEFAULT.toJson(event.getEvent()));
                }
            })
            .build();

    // 注入 ServletAdapter 实例 Inject ServletAdapter instance
    @Autowired
    private ServletAdapter servletAdapter;

    // 创建路由处理器 Create route handler
    @RequestMapping("/webhook/event")
    public void event(HttpServletRequest request, HttpServletResponse response)
            throws Throwable {
        // 回调扩展包提供的事件回调处理器 Callback handler provided by the extension package
        servletAdapter.handleEvent(request, response, EVENT_DISPATCHER);
    }
}
// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/nodejs-sdk/preparation-before-development
import http from 'http';
import * as lark from '@larksuiteoapi/node-sdk';

// 注册事件 Register event
const eventDispatcher = new lark.EventDispatcher({
    encryptKey: '',
    verificationToken: '',
}).register({
    'vc.reserve_config.updated_v1': async (data) => {
        console.log(data);
        return 'success';
    },
});

const server = http.createServer();
// 创建路由处理器 Create route handler
server.on('request', lark.adaptDefault('/webhook/event', eventDispatcher));
server.listen(3000);

内容来源:飞书开放平台 · 自动爬取整理