Comparing version 1.2.0 to 1.2.1
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"license": "MIT", | ||
@@ -13,0 +13,0 @@ "main": "./dist/index.js", |
@@ -9,34 +9,44 @@ # Javascript / Typescript Seam API Library | ||
```ts | ||
import Seam from seamapi | ||
// Replace with | ||
// const Seam = require("seamapi") | ||
// if not using ES6 modules and/or TypeScript. | ||
import Seam from "seamapi"; | ||
const seam = new Seam() | ||
const seam = new Seam(); | ||
// Seam will automatically use the SEAM_API_KEY environment variable if you | ||
// don't provide an api_key to `new Seam()` | ||
// don't provide an apiKey to `new Seam()` | ||
const someLock = await seam.locks.list().devices[0] | ||
const someLockId = someLock.device_id | ||
(async () => { | ||
const { | ||
devices: [someLock], | ||
} = await seam.locks.list(); | ||
const someLockId = someLock.device_id; | ||
await seam.locks.lockDoor(someLockId) | ||
const { device: someLockedLock } = await seam.locks.get(someLockId) | ||
// someLockedLock.properties.locked === true | ||
await seam.locks.lockDoor(someLockId); | ||
const { device: someLockedLock } = await seam.locks.get(someLockId); | ||
// someLockedLock.properties.locked === true | ||
await seam.locks.unlockDoor(someLockId) | ||
await seam.locks.unlockDoor(someLockId); | ||
await seam.accessCodes.create(someLockId, { name: "Some Access Code", code: "1234" }) | ||
await seam.accessCodes.create(someLockId, { | ||
name: "Some Access Code", | ||
code: "1234", | ||
}); | ||
const accessCodeList = await seam.accessCodes.list(someLockId) | ||
console.log(accessCodeList) | ||
/* | ||
{ | ||
access_codes: [ | ||
{ | ||
access_code_id: "some-access-code-1", | ||
name: "Some Access Code", | ||
code: "1234", | ||
type: "ongoing", | ||
created_at: "2022-02-01T12:57:40.843Z", | ||
}, | ||
], | ||
} | ||
*/ | ||
const accessCodeList = await seam.accessCodes.list(someLockId); | ||
console.log(accessCodeList); | ||
/* | ||
{ | ||
access_codes: [ | ||
{ | ||
access_code_id: "some-access-code-1", | ||
name: "Some Access Code", | ||
code: "1234", | ||
type: "ongoing", | ||
created_at: "2022-02-01T12:57:40.843Z", | ||
}, | ||
], | ||
} | ||
*/ | ||
})(); | ||
``` | ||
@@ -43,0 +53,0 @@ |
25712
56