brueggern/crestron-fusion-handler

此包最新版本(v0.0.5)没有可用的许可证信息。

从 Crestron Fusion API 获取数据

v0.0.5 2019-05-16 19:39 UTC

This package is auto-updated.

Last update: 2024-09-17 08:26:38 UTC


README

Crestron Fusion Handler 可以使用 Crestron Fusion REST API 获取所有房间或预约。

创建处理器

首先,您需要创建一个新的处理器对象,并根据您的 API 是否启用了身份验证设置相应的认证参数。

$handler = new CrestronFusionHandler('https://123.45.67.89/fusion/apiservice');
$handler->setAuth('some-token', 'some-user');

获取房间

获取所有房间。

$roomsCollection = $handler->getRooms();

获取预约

获取特定房间的预约。

$rooms = new CFCollection();
$rooms->addItem(new CFRoom(['id' => '41746b03-1803-4d65-84eb-06815688c780']));
$appointmentsCollection = $handler->getAppointments(new DateTime(), $rooms);

集合

返回的是集合对象而不是数组。更多详细信息,请参阅 src/CFCollection.php

$collection = new CFCollection();
$collection->addItem('Room One', 'room1');
$collection->addItem('Room Two, 'room2');

$name = $collection->getItem('room1');
// $name => Room One

$collection->deleteItem('room2');
// or
$collection->deleteItem(1);

$array = $collection->get();
// Returns an array

$mergedCollection = $collection1->append($collection2)//
// Append all items of a collection to another collection

开发 / 测试 / 代码检查

composer install
cp tests/.env.testing.example tests/.env.testing

composer run test:online
composer run test:offline
composer run lint

备注

在未来的版本中,还应该能够更新实体,如房间、预约等。