seamapi/seam

本包最新版本(v2.26.0)没有提供许可证信息。


README

使用Seam的简单API控制锁、灯和其他物联网设备。

查看文档或以下用法。

用法

$seam = new Seam\SeamClient("YOUR_API_KEY");

# Create a Connect Webview to login to a provider
$connect_webview = $seam->connect_webviews->create(
  accepted_providers: ["august"]
);

print "Please Login at this url: " . $connect_webview->url;

# Poll until connect webview is completed
while (true) {
  $connect_webview = $seam->connect_webviews->get(
    $connect_webview->connect_webview_id
  );
  if ($connect_webview->status == "authorized") {
    break;
  } else {
    sleep(1);
  }
}

$connected_account = $seam->connected_accounts->get(
  $connect_webview->connected_account_id
);

print "Looks like you connected with " .
  json_encode($connected_account->user_identifier);

$devices = $seam->devices->list(
  connected_account_id: $connected_account->connected_account_id
);

print "You have " . count($devices) . " devices";

$device_id = $devices[0]->device_id;

# Lock a Door
$seam->locks->lock_door($device_id);

$updated_device = $seam->devices->get($device_id);
$updated_device->properties->locked; // true

# Unlock a Door
$seam->locks->unlock_door($device_id);
$updated_device->properties->locked; // false

# Create an access code on a device
$access_code = $seam->access_codes->create(
  device_id: $device_id,
  code: "1234",
  name: "Test Code"
);

# Check the status of an access code
$access_code->status; // 'setting' (it will go to 'set' when active on the device)

$seam->access_codes->delete($access_code->access_code_id);

安装

要安装自动生成的SDK的最新版本,运行

composer require seamapi/seam

如果您想安装我们之前的手写版本,运行

composer require seamapi/seam:1.1

开发设置

  1. 运行 yarn install 以安装 prettier 以进行格式化
  2. 安装composer
  3. 在此目录中运行 composer install
  4. 运行 composer exec phpunit tests

要运行特定的测试文件,执行 composer exec phpunit tests/MyTest.php

运行测试

您需要将 SEAM_API_KEY 导出为沙盒工作区的API密钥。