From e303974f10a0c6fe2e81655479a254833d9488b8 Mon Sep 17 00:00:00 2001 From: Tristan Brewster Date: Fri, 30 Sep 2022 15:17:48 -0600 Subject: [PATCH] fix #53: Implement `connected_accounts.delete` --- docs/classes/Seam.md | 19 ++++---- .../interfaces/AccessCodeCreateBaseRequest.md | 6 +-- .../AccessCodeCreateOngoingRequest.md | 6 +-- .../AccessCodeCreateScheduledRequest.md | 10 ++--- .../interfaces/AccessCodeUpdateBaseRequest.md | 4 +- .../ConnectedAccountsDeleteRequest.md | 44 +++++++++++++++++++ .../interfaces/ConnectedAccountsGetRequest.md | 14 ++++++ docs/interfaces/DevicesListRequest.md | 6 +-- docs/interfaces/EventsListRequest.md | 10 ++--- docs/modules.md | 23 +++++----- src/cli/commands/connected-accounts.ts | 35 +++++++++++++++ src/routes.ts | 7 +++ src/types/route-requests.ts | 8 +++- tests/routes.test.ts | 12 +++++ 14 files changed, 162 insertions(+), 42 deletions(-) create mode 100644 docs/interfaces/ConnectedAccountsDeleteRequest.md diff --git a/docs/classes/Seam.md b/docs/classes/Seam.md index 429bd464..7243c130 100644 --- a/docs/classes/Seam.md +++ b/docs/classes/Seam.md @@ -73,7 +73,7 @@ Routes.accessCodes #### Defined in -[src/routes.ts:222](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L222) +[src/routes.ts:223](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L223) ___ @@ -93,7 +93,7 @@ Routes.actionAttempts #### Defined in -[src/routes.ts:288](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L288) +[src/routes.ts:295](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L295) ___ @@ -125,7 +125,7 @@ Routes.connectWebviews #### Defined in -[src/routes.ts:196](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L196) +[src/routes.ts:197](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L197) ___ @@ -137,6 +137,7 @@ ___ | Name | Type | | :------ | :------ | +| `delete` | (`params`: [`ConnectedAccountsDeleteRequest`](../interfaces/ConnectedAccountsDeleteRequest.md)) => `Promise`<{ `ok`: ``true`` }\> | | `get` | (`params`: [`ConnectedAccountsGetRequest`](../interfaces/ConnectedAccountsGetRequest.md)) => `Promise`<[`ConnectedAccount`](../interfaces/ConnectedAccount.md)\> | | `list` | () => `Promise`<[`ConnectedAccount`](../interfaces/ConnectedAccount.md)[]\> | @@ -146,7 +147,7 @@ Routes.connectedAccounts #### Defined in -[src/routes.ts:269](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L269) +[src/routes.ts:270](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L270) ___ @@ -169,7 +170,7 @@ Routes.devices #### Defined in -[src/routes.ts:159](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L159) +[src/routes.ts:160](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L160) ___ @@ -189,7 +190,7 @@ Routes.events #### Defined in -[src/routes.ts:184](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L184) +[src/routes.ts:185](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L185) ___ @@ -212,7 +213,7 @@ Routes.locks #### Defined in -[src/routes.ts:124](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L124) +[src/routes.ts:125](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L125) ___ @@ -235,7 +236,7 @@ Routes.webhooks #### Defined in -[src/routes.ts:298](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L298) +[src/routes.ts:305](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L305) ___ @@ -257,7 +258,7 @@ Routes.workspaces #### Defined in -[src/routes.ts:108](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L108) +[src/routes.ts:109](https://github.com/seamapi/javascript/blob/main/src/routes.ts#L109) ## Methods diff --git a/docs/interfaces/AccessCodeCreateBaseRequest.md b/docs/interfaces/AccessCodeCreateBaseRequest.md index b8223ead..1189ad87 100644 --- a/docs/interfaces/AccessCodeCreateBaseRequest.md +++ b/docs/interfaces/AccessCodeCreateBaseRequest.md @@ -26,7 +26,7 @@ #### Defined in -[src/types/route-requests.ts:22](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L22) +[src/types/route-requests.ts:28](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L28) ___ @@ -36,7 +36,7 @@ ___ #### Defined in -[src/types/route-requests.ts:20](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L20) +[src/types/route-requests.ts:26](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L26) ___ @@ -46,4 +46,4 @@ ___ #### Defined in -[src/types/route-requests.ts:21](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L21) +[src/types/route-requests.ts:27](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L27) diff --git a/docs/interfaces/AccessCodeCreateOngoingRequest.md b/docs/interfaces/AccessCodeCreateOngoingRequest.md index 922d7369..b94f453f 100644 --- a/docs/interfaces/AccessCodeCreateOngoingRequest.md +++ b/docs/interfaces/AccessCodeCreateOngoingRequest.md @@ -28,7 +28,7 @@ #### Defined in -[src/types/route-requests.ts:22](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L22) +[src/types/route-requests.ts:28](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L28) ___ @@ -42,7 +42,7 @@ ___ #### Defined in -[src/types/route-requests.ts:20](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L20) +[src/types/route-requests.ts:26](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L26) ___ @@ -56,4 +56,4 @@ ___ #### Defined in -[src/types/route-requests.ts:21](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L21) +[src/types/route-requests.ts:27](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L27) diff --git a/docs/interfaces/AccessCodeCreateScheduledRequest.md b/docs/interfaces/AccessCodeCreateScheduledRequest.md index 26099986..ac34d028 100644 --- a/docs/interfaces/AccessCodeCreateScheduledRequest.md +++ b/docs/interfaces/AccessCodeCreateScheduledRequest.md @@ -30,7 +30,7 @@ #### Defined in -[src/types/route-requests.ts:22](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L22) +[src/types/route-requests.ts:28](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L28) ___ @@ -44,7 +44,7 @@ ___ #### Defined in -[src/types/route-requests.ts:20](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L20) +[src/types/route-requests.ts:26](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L26) ___ @@ -54,7 +54,7 @@ ___ #### Defined in -[src/types/route-requests.ts:31](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L31) +[src/types/route-requests.ts:37](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L37) ___ @@ -68,7 +68,7 @@ ___ #### Defined in -[src/types/route-requests.ts:21](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L21) +[src/types/route-requests.ts:27](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L27) ___ @@ -78,4 +78,4 @@ ___ #### Defined in -[src/types/route-requests.ts:30](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L30) +[src/types/route-requests.ts:36](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L36) diff --git a/docs/interfaces/AccessCodeUpdateBaseRequest.md b/docs/interfaces/AccessCodeUpdateBaseRequest.md index 67cfbc0f..15e2c5bb 100644 --- a/docs/interfaces/AccessCodeUpdateBaseRequest.md +++ b/docs/interfaces/AccessCodeUpdateBaseRequest.md @@ -17,7 +17,7 @@ #### Defined in -[src/types/route-requests.ts:40](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L40) +[src/types/route-requests.ts:46](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L46) ___ @@ -27,4 +27,4 @@ ___ #### Defined in -[src/types/route-requests.ts:39](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L39) +[src/types/route-requests.ts:45](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L45) diff --git a/docs/interfaces/ConnectedAccountsDeleteRequest.md b/docs/interfaces/ConnectedAccountsDeleteRequest.md new file mode 100644 index 00000000..06c845fc --- /dev/null +++ b/docs/interfaces/ConnectedAccountsDeleteRequest.md @@ -0,0 +1,44 @@ +[seamapi](../README.md) / [Exports](../modules.md) / ConnectedAccountsDeleteRequest + +# Interface: ConnectedAccountsDeleteRequest + +## Hierarchy + +- `ConnectedAccountBaseRequest` + + ↳ **`ConnectedAccountsDeleteRequest`** + +## Table of contents + +### Properties + +- [connected\_account\_id](ConnectedAccountsDeleteRequest.md#connected_account_id) +- [email](ConnectedAccountsDeleteRequest.md#email) + +## Properties + +### connected\_account\_id + +• `Optional` **connected\_account\_id**: `string` + +#### Inherited from + +ConnectedAccountBaseRequest.connected\_account\_id + +#### Defined in + +[src/types/route-requests.ts:9](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L9) + +___ + +### email + +• `Optional` **email**: `string` + +#### Inherited from + +ConnectedAccountBaseRequest.email + +#### Defined in + +[src/types/route-requests.ts:10](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L10) diff --git a/docs/interfaces/ConnectedAccountsGetRequest.md b/docs/interfaces/ConnectedAccountsGetRequest.md index 069b57d2..22af38c4 100644 --- a/docs/interfaces/ConnectedAccountsGetRequest.md +++ b/docs/interfaces/ConnectedAccountsGetRequest.md @@ -2,6 +2,12 @@ # Interface: ConnectedAccountsGetRequest +## Hierarchy + +- `ConnectedAccountBaseRequest` + + ↳ **`ConnectedAccountsGetRequest`** + ## Table of contents ### Properties @@ -15,6 +21,10 @@ • `Optional` **connected\_account\_id**: `string` +#### Inherited from + +ConnectedAccountBaseRequest.connected\_account\_id + #### Defined in [src/types/route-requests.ts:9](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L9) @@ -25,6 +35,10 @@ ___ • `Optional` **email**: `string` +#### Inherited from + +ConnectedAccountBaseRequest.email + #### Defined in [src/types/route-requests.ts:10](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L10) diff --git a/docs/interfaces/DevicesListRequest.md b/docs/interfaces/DevicesListRequest.md index 6b6c88e8..3fea3627 100644 --- a/docs/interfaces/DevicesListRequest.md +++ b/docs/interfaces/DevicesListRequest.md @@ -18,7 +18,7 @@ #### Defined in -[src/types/route-requests.ts:15](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L15) +[src/types/route-requests.ts:21](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L21) ___ @@ -28,7 +28,7 @@ ___ #### Defined in -[src/types/route-requests.ts:14](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L14) +[src/types/route-requests.ts:20](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L20) ___ @@ -38,4 +38,4 @@ ___ #### Defined in -[src/types/route-requests.ts:16](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L16) +[src/types/route-requests.ts:22](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L22) diff --git a/docs/interfaces/EventsListRequest.md b/docs/interfaces/EventsListRequest.md index c3a28c95..8d25cfe0 100644 --- a/docs/interfaces/EventsListRequest.md +++ b/docs/interfaces/EventsListRequest.md @@ -20,7 +20,7 @@ #### Defined in -[src/types/route-requests.ts:98](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L98) +[src/types/route-requests.ts:104](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L104) ___ @@ -30,7 +30,7 @@ ___ #### Defined in -[src/types/route-requests.ts:97](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L97) +[src/types/route-requests.ts:103](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L103) ___ @@ -40,7 +40,7 @@ ___ #### Defined in -[src/types/route-requests.ts:100](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L100) +[src/types/route-requests.ts:106](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L106) ___ @@ -50,7 +50,7 @@ ___ #### Defined in -[src/types/route-requests.ts:99](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L99) +[src/types/route-requests.ts:105](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L105) ___ @@ -60,4 +60,4 @@ ___ #### Defined in -[src/types/route-requests.ts:96](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L96) +[src/types/route-requests.ts:102](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L102) diff --git a/docs/modules.md b/docs/modules.md index e2916ae2..3111eb10 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -40,6 +40,7 @@ - [ConnectWebviewGetResponse](interfaces/ConnectWebviewGetResponse.md) - [ConnectWebviewsListResponse](interfaces/ConnectWebviewsListResponse.md) - [ConnectedAccount](interfaces/ConnectedAccount.md) +- [ConnectedAccountsDeleteRequest](interfaces/ConnectedAccountsDeleteRequest.md) - [ConnectedAccountsGetRequest](interfaces/ConnectedAccountsGetRequest.md) - [ConnectedAccountsGetResponse](interfaces/ConnectedAccountsGetResponse.md) - [ConnectedAccountsListResponse](interfaces/ConnectedAccountsListResponse.md) @@ -139,7 +140,7 @@ ___ #### Defined in -[src/types/route-requests.ts:34](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L34) +[src/types/route-requests.ts:40](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L40) ___ @@ -156,7 +157,7 @@ ___ #### Defined in -[src/types/route-requests.ts:57](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L57) +[src/types/route-requests.ts:63](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L63) ___ @@ -174,7 +175,7 @@ ___ #### Defined in -[src/types/route-requests.ts:62](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L62) +[src/types/route-requests.ts:68](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L68) ___ @@ -184,7 +185,7 @@ ___ #### Defined in -[src/types/route-requests.ts:43](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L43) +[src/types/route-requests.ts:49](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L49) ___ @@ -194,7 +195,7 @@ ___ #### Defined in -[src/types/route-requests.ts:53](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L53) +[src/types/route-requests.ts:59](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L59) ___ @@ -204,7 +205,7 @@ ___ #### Defined in -[src/types/route-requests.ts:48](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L48) +[src/types/route-requests.ts:54](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L54) ___ @@ -273,7 +274,7 @@ ___ #### Defined in -[src/types/route-requests.ts:83](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L83) +[src/types/route-requests.ts:89](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L89) ___ @@ -283,7 +284,7 @@ ___ #### Defined in -[src/types/route-requests.ts:68](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L68) +[src/types/route-requests.ts:74](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L74) ___ @@ -312,7 +313,7 @@ ___ #### Defined in -[src/types/route-requests.ts:76](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L76) +[src/types/route-requests.ts:82](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L82) ___ @@ -394,7 +395,7 @@ ___ #### Defined in -[src/types/route-requests.ts:91](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L91) +[src/types/route-requests.ts:97](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L97) ___ @@ -410,7 +411,7 @@ ___ #### Defined in -[src/types/route-requests.ts:87](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L87) +[src/types/route-requests.ts:93](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L93) ## Functions diff --git a/src/cli/commands/connected-accounts.ts b/src/cli/commands/connected-accounts.ts index 049450b0..11841013 100644 --- a/src/cli/commands/connected-accounts.ts +++ b/src/cli/commands/connected-accounts.ts @@ -52,6 +52,41 @@ const command: CommandModule = { ) } ) + .command( + "delete", + "delete a connected account", + (yargs) => { + return yargs + .option("connected-account-id", { + describe: "the connected account ID", + type: "string", + }) + .option("email", { + describe: "the email address of the connected account", + type: "string", + }) + .conflicts("connected-account-id", "email") + .check((argv) => { + if (!argv.connectedAccountId && !argv.email) { + throw new Error( + "Either --connected-account-id or --email is required" + ) + } + }) + }, + async (argv) => { + await executeCommand( + "connectedAccounts.delete", + [ + { + connected_account_id: argv.connectedAccountId, + email: argv.email, + }, + ], + argv + ) + } + ) }, handler: () => {}, } diff --git a/src/routes.ts b/src/routes.ts index 9e7fc94b..eafe533a 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -17,6 +17,7 @@ import { AccessCodeCreateOngoingRequest, ConnectWebviewCreateRequest, ConnectedAccountsGetRequest, + ConnectedAccountsDeleteRequest, DeviceUpdateRequest, DeviceGetRequest, DevicesListRequest, @@ -283,6 +284,12 @@ export abstract class Routes { params, } ), + delete: (params: ConnectedAccountsDeleteRequest) => + this.makeRequest({ + url: "/connected_accounts/delete", + method: "DELETE", + data: params, + }), } public readonly actionAttempts = { diff --git a/src/types/route-requests.ts b/src/types/route-requests.ts index 34d7a938..940340f9 100644 --- a/src/types/route-requests.ts +++ b/src/types/route-requests.ts @@ -5,11 +5,17 @@ export interface ConnectWebviewCreateRequest { accepted_providers: Provider[] } -export interface ConnectedAccountsGetRequest { +interface ConnectedAccountBaseRequest { connected_account_id?: string email?: string } +export interface ConnectedAccountsGetRequest + extends ConnectedAccountBaseRequest {} + +export interface ConnectedAccountsDeleteRequest + extends ConnectedAccountBaseRequest {} + export interface DevicesListRequest { connected_account_id?: string connect_webview_id?: string diff --git a/tests/routes.test.ts b/tests/routes.test.ts index ea94b0e8..4397c12c 100644 --- a/tests/routes.test.ts +++ b/tests/routes.test.ts @@ -217,3 +217,15 @@ test( }, "ConnectedAccount" ) +test( + testAPIMethod("connectedAccounts.delete"), + { + args: (seed) => [ + { + connected_account_id: seed.devices.augustLock.connectedAccountId, + }, + ], + modifiesState: true, + }, + "{}" +)