Skip to content

Commit

Permalink
Add device example (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x committed Apr 23, 2024
1 parent db05f63 commit b9baaa1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 23 additions & 0 deletions 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<Options> = async ({ deviceId, seam, logger }) => {
const device = await seam.devices.get({ device_id: deviceId })
logger.info({ device }, 'device')
}
3 changes: 2 additions & 1 deletion examples/index.ts
Expand Up @@ -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'
Expand All @@ -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']
Expand Down

0 comments on commit b9baaa1

Please sign in to comment.