From b9baaa1fc7a393404e62f7b11536c250362c252b Mon Sep 17 00:00:00 2001 From: Evan Sosenko Date: Tue, 23 Apr 2024 16:20:16 -0700 Subject: [PATCH] Add device example (#79) --- examples/device.ts | 23 +++++++++++++++++++++++ examples/index.ts | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 examples/device.ts diff --git a/examples/device.ts b/examples/device.ts new file mode 100644 index 0000000..ab0d345 --- /dev/null +++ b/examples/device.ts @@ -0,0 +1,23 @@ +import type { Builder, Command, Describe } from 'landlubber' + +import type { Handler } from './index.js' + +interface Options { + deviceId: string +} + +export const command: Command = 'device deviceId' + +export const describe: Describe = 'Get device' + +export const builder: Builder = { + deviceId: { + type: 'string', + describe: 'Device id of lock to unlock', + }, +} + +export const handler: Handler = async ({ deviceId, seam, logger }) => { + const device = await seam.devices.get({ device_id: deviceId }) + logger.info({ device }, 'device') +} diff --git a/examples/index.ts b/examples/index.ts index 54e5dc3..d8c08b5 100755 --- a/examples/index.ts +++ b/examples/index.ts @@ -12,6 +12,7 @@ import landlubber, { import { Seam } from 'seam' +import * as device from './device.js' import * as devices from './devices.js' import * as lock from './lock.js' import * as unlock from './unlock.js' @@ -24,7 +25,7 @@ interface ClientContext { seam: Seam } -const commands = [devices, lock, unlock] +const commands = [device, devices, lock, unlock] const createAppContext: MiddlewareFunction = async (argv) => { const apiKey = argv['api-key']