From 73452761f24e9aa0d02d9587d3fef76f8f07c8e4 Mon Sep 17 00:00:00 2001 From: Chuck MANCHUCK Reeves Date: Mon, 11 Sep 2023 19:19:08 +0000 Subject: [PATCH] refactor(meetings): version is now present in the api path Also included missing dependancy for proactive connect --- packages/meetings/__tests__/file.test.ts | 14 +++---- packages/meetings/__tests__/numbers.test.ts | 2 +- .../meetings/__tests__/recordings.test.ts | 8 ++-- packages/meetings/__tests__/room.test.ts | 28 ++++++------- packages/meetings/__tests__/theme.test.ts | 40 +++++++++---------- packages/meetings/lib/meetings.ts | 34 ++++++++-------- packages/proactive-connect/package.json | 1 + 7 files changed, 65 insertions(+), 62 deletions(-) diff --git a/packages/meetings/__tests__/file.test.ts b/packages/meetings/__tests__/file.test.ts index c76944ab..da1ffe8b 100644 --- a/packages/meetings/__tests__/file.test.ts +++ b/packages/meetings/__tests__/file.test.ts @@ -99,9 +99,9 @@ describe('Meetings > File uploads', () => { const { url, fields } = awsExpected; const awsUrl = new URL(url); scope - .get(`/meetings/themes/logos-upload-urls`) + .get(`/v1/meetings/themes/logos-upload-urls`) .reply(200, urlResponses) - .put(`/meetings/themes/${themeOne.themeId}/finalizeLogos`, { + .put(`/v1/meetings/themes/${themeOne.themeId}/finalizeLogos`, { keys: [fields.key], }) .reply(200, 'OK'); @@ -141,7 +141,7 @@ describe('Meetings > File uploads', () => { }); test('Will throw error when AWS fails', async () => { - scope.get(`/meetings/themes/logos-upload-urls`).reply(200, urlResponses); + scope.get(`/v1/meetings/themes/logos-upload-urls`).reply(200, urlResponses); const awsUrl = new URL(urlResponses[0].url); awsScope @@ -170,9 +170,9 @@ describe('Meetings > File uploads', () => { test('Will throw error when apply fails', async () => { scope - .get(`/meetings/themes/logos-upload-urls`) + .get(`/v1/meetings/themes/logos-upload-urls`) .reply(200, urlResponses) - .put(`/meetings/themes/${themeOne.themeId}/finalizeLogos`, { + .put(`/v1/meetings/themes/${themeOne.themeId}/finalizeLogos`, { keys: [urlResponses[0].fields.key], }) .reply(400, { @@ -198,9 +198,9 @@ describe('Meetings > File uploads', () => { test('Will throw error when apply fails with no message', async () => { scope - .get(`/meetings/themes/logos-upload-urls`) + .get(`/v1/meetings/themes/logos-upload-urls`) .reply(200, urlResponses) - .put(`/meetings/themes/${themeOne.themeId}/finalizeLogos`, { + .put(`/v1/meetings/themes/${themeOne.themeId}/finalizeLogos`, { keys: [urlResponses[0].fields.key], }) .reply(400); diff --git a/packages/meetings/__tests__/numbers.test.ts b/packages/meetings/__tests__/numbers.test.ts index 2902891c..153eb7f4 100644 --- a/packages/meetings/__tests__/numbers.test.ts +++ b/packages/meetings/__tests__/numbers.test.ts @@ -32,7 +32,7 @@ describe('Meetings > Numbers', () => { test('Can get recording by id', async () => { scope - .get(`/meetings/dial-in-numbers`) + .get(`/v1/meetings/dial-in-numbers`) .reply(200, [ Client.transformers.snakeCaseObjectKeys(dialInNumberOne), Client.transformers.snakeCaseObjectKeys(dialInNumberTwo), diff --git a/packages/meetings/__tests__/recordings.test.ts b/packages/meetings/__tests__/recordings.test.ts index 57379e3c..63356a28 100644 --- a/packages/meetings/__tests__/recordings.test.ts +++ b/packages/meetings/__tests__/recordings.test.ts @@ -33,7 +33,9 @@ describe('Meetings > Recordings', () => { }); test('Can get recording by id', async () => { - scope.get(`/meetings/recordings/my-awesome-recording`).reply(200, session); + scope + .get(`/v1/meetings/recordings/my-awesome-recording`) + .reply(200, session); expect(await client.getRecording('my-awesome-recording')).toEqual({ ...Client.transformers.camelCaseObjectKeys(session, true), @@ -44,7 +46,7 @@ describe('Meetings > Recordings', () => { }); test('Can get recordings for session', async () => { - scope.get(`/meetings/sessions/my-session`).reply(200, { + scope.get(`/v1/meetings/sessions/my-session`).reply(200, { _embedded: { recordings: [session], }, @@ -61,7 +63,7 @@ describe('Meetings > Recordings', () => { }); test('Can delete recording by id', async () => { - scope.delete(`/meetings/recordings/my-awesome-recording`).reply(204); + scope.delete(`/v1/meetings/recordings/my-awesome-recording`).reply(204); await client.deleteRecording('my-awesome-recording'); diff --git a/packages/meetings/__tests__/room.test.ts b/packages/meetings/__tests__/room.test.ts index ce9f1b61..d59894ea 100644 --- a/packages/meetings/__tests__/room.test.ts +++ b/packages/meetings/__tests__/room.test.ts @@ -25,7 +25,7 @@ describe('Meetings > Rooms', () => { }); test('Can get one page of data', async () => { - scope.get(`/meetings/rooms?`).reply(200, { + scope.get(`/v1/meetings/rooms?`).reply(200, { _embedded: [ { ...roomOne, @@ -34,7 +34,7 @@ describe('Meetings > Rooms', () => { ], _links: { self: { - href: `${BASE_URL}/meetings/rooms`, + href: `${BASE_URL}/v1/meetings/rooms`, }, }, page_size: 20, @@ -52,7 +52,7 @@ describe('Meetings > Rooms', () => { test('Can get two pages of data', async () => { scope - .get(`/meetings/rooms?page_size=1`) + .get(`/v1/meetings/rooms?page_size=1`) .reply(200, { _embedded: [ { @@ -62,16 +62,16 @@ describe('Meetings > Rooms', () => { ], _links: { self: { - href: `${BASE_URL}/meetings/rooms`, + href: `${BASE_URL}/v1/meetings/rooms`, }, next: { - href: `${BASE_URL}/meetings/rooms?start_id=42`, + href: `${BASE_URL}/v1/meetings/rooms?start_id=42`, }, }, page_size: 20, total_items: 1, }) - .get(`/meetings/rooms?page_size=1&start_id=42`) + .get(`/v1/meetings/rooms?page_size=1&start_id=42`) .reply(200, { _embedded: [ { @@ -81,7 +81,7 @@ describe('Meetings > Rooms', () => { ], _links: { self: { - href: `${BASE_URL}/meetings/rooms`, + href: `${BASE_URL}/v1/meetings/rooms`, }, }, page_size: 20, @@ -102,7 +102,7 @@ describe('Meetings > Rooms', () => { test('Will throw error when call fails', async () => { scope - .get(`/meetings/rooms?`) + .get(`/v1/meetings/rooms?`) .reply(200, { _embedded: [ { @@ -112,16 +112,16 @@ describe('Meetings > Rooms', () => { ], _links: { self: { - href: `${BASE_URL}/meetings/rooms`, + href: `${BASE_URL}/v1/meetings/rooms`, }, next: { - href: `${BASE_URL}/meetings/rooms?start_id=42`, + href: `${BASE_URL}/v1/meetings/rooms?start_id=42`, }, }, page_size: 20, total_items: 1, }) - .get(`/meetings/rooms?start_id=42`) + .get(`/v1/meetings/rooms?start_id=42`) .reply(401, { status: 401, error: 'Unauthorized', @@ -140,7 +140,7 @@ describe('Meetings > Rooms', () => { }); test('Can get room by id', async () => { - scope.get(`/meetings/rooms/my-awesome-room`).reply(200, { + scope.get(`/v1/meetings/rooms/my-awesome-room`).reply(200, { ...roomOne, _links: roomLinks, }); @@ -155,7 +155,7 @@ describe('Meetings > Rooms', () => { test('Can create room', async () => { scope .post( - `/meetings/rooms`, + `/v1/meetings/rooms`, pick( Client.transformers.snakeCaseObjectKeys(roomOne, true), client.ROOM_WRITE_KEYS, @@ -175,7 +175,7 @@ describe('Meetings > Rooms', () => { test('Can Update an existing room', async () => { scope - .patch(`/meetings/rooms/my-awesome-room`, { + .patch(`/v1/meetings/rooms/my-awesome-room`, { update_options: pick( Client.transformers.snakeCaseObjectKeys(roomOne, true), client.ROOM_WRITE_KEYS, diff --git a/packages/meetings/__tests__/theme.test.ts b/packages/meetings/__tests__/theme.test.ts index d746f6d4..2668a9a5 100644 --- a/packages/meetings/__tests__/theme.test.ts +++ b/packages/meetings/__tests__/theme.test.ts @@ -27,7 +27,7 @@ describe('Meetings > Themes', () => { }); test('Can get empty themes', async () => { - scope.get(`/meetings/themes`).reply(200, []); + scope.get(`/v1/meetings/themes`).reply(200, []); const results = []; for await (const room of client.getThemes()) { @@ -40,7 +40,7 @@ describe('Meetings > Themes', () => { test('Can get themes', async () => { scope - .get(`/meetings/themes`) + .get(`/v1/meetings/themes`) .reply(200, [ Client.transformers.snakeCaseObjectKeys(themeOne), Client.transformers.snakeCaseObjectKeys(themeTwo), @@ -57,7 +57,7 @@ describe('Meetings > Themes', () => { test('Can get theme', async () => { scope - .get(`/meetings/themes/my-theme`) + .get(`/v1/meetings/themes/my-theme`) .reply(200, Client.transformers.snakeCaseObjectKeys(themeOne)); expect(await client.getTheme('my-theme')).toEqual(themeOne); @@ -66,7 +66,7 @@ describe('Meetings > Themes', () => { test('Can delete theme', async () => { scope - .delete(`/meetings/themes/my-theme`) + .delete(`/v1/meetings/themes/my-theme`) .reply(200, Client.transformers.snakeCaseObjectKeys(themeOne)); await client.deleteTheme('my-theme'); @@ -75,7 +75,7 @@ describe('Meetings > Themes', () => { test('Can force delete theme', async () => { scope - .delete(`/meetings/themes/my-theme?force=true`) + .delete(`/v1/meetings/themes/my-theme?force=true`) .reply(200, Client.transformers.snakeCaseObjectKeys(themeOne)); await client.deleteTheme('my-theme', true); @@ -83,7 +83,7 @@ describe('Meetings > Themes', () => { }); test('Will throw when theme in use', async () => { - scope.delete(`/meetings/themes/my-theme`).reply(400, { + scope.delete(`/v1/meetings/themes/my-theme`).reply(400, { message: 'could not delete theme', name: 'BadRequestError', errors: [ @@ -101,7 +101,7 @@ describe('Meetings > Themes', () => { test('Will create a theme', async () => { scope .post( - `/meetings/themes`, + `/v1/meetings/themes`, pick( Client.transformers.snakeCaseObjectKeys(themeOne, true), client.THEME_WRITE_KEYS, @@ -115,7 +115,7 @@ describe('Meetings > Themes', () => { test('Will update a theme', async () => { scope - .patch(`/meetings/themes/my-theme`, { + .patch(`/v1/meetings/themes/my-theme`, { update_details: pick( Client.transformers.snakeCaseObjectKeys(themeOne, true), client.THEME_WRITE_KEYS, @@ -128,7 +128,7 @@ describe('Meetings > Themes', () => { }); test('Can get one page of theme rooms', async () => { - scope.get(`/meetings/themes/my-theme/rooms?`).reply(200, { + scope.get(`/v1/meetings/themes/my-theme/rooms?`).reply(200, { _embedded: [ { ...roomOne, @@ -137,7 +137,7 @@ describe('Meetings > Themes', () => { ], _links: { self: { - href: `${BASE_URL}/meetings/rooms`, + href: `${BASE_URL}/v1/meetings/rooms`, }, }, page_size: 20, @@ -155,7 +155,7 @@ describe('Meetings > Themes', () => { test('Can get two pages of theme rooms', async () => { scope - .get(`/meetings/themes/my-theme/rooms?page_size=1`) + .get(`/v1/meetings/themes/my-theme/rooms?page_size=1`) .reply(200, { _embedded: [ { @@ -165,16 +165,16 @@ describe('Meetings > Themes', () => { ], _links: { self: { - href: `${BASE_URL}/meetings/rooms`, + href: `${BASE_URL}/v1/meetings/rooms`, }, next: { - href: `${BASE_URL}/meetings/rooms?start_id=42`, + href: `${BASE_URL}/v1/meetings/rooms?start_id=42`, }, }, page_size: 20, total_items: 1, }) - .get(`/meetings/themes/my-theme/rooms?page_size=1&start_id=42`) + .get(`/v1/meetings/themes/my-theme/rooms?page_size=1&start_id=42`) .reply(200, { _embedded: [ { @@ -184,7 +184,7 @@ describe('Meetings > Themes', () => { ], _links: { self: { - href: `${BASE_URL}/meetings/rooms`, + href: `${BASE_URL}/v1/meetings/rooms`, }, }, page_size: 20, @@ -207,21 +207,21 @@ describe('Meetings > Themes', () => { test('Will throw error when call to theme rooms fails', async () => { scope - .get(`/meetings/themes/my-theme/rooms?`) + .get(`/v1/meetings/themes/my-theme/rooms?`) .reply(200, { _embedded: [roomOne], _links: { self: { - href: `${BASE_URL}/meetings/rooms`, + href: `${BASE_URL}/v1/meetings/rooms`, }, next: { - href: `${BASE_URL}/meetings/rooms?start_id=42`, + href: `${BASE_URL}/v1/meetings/rooms?start_id=42`, }, }, page_size: 20, total_items: 1, }) - .get(`/meetings/themes/my-theme/rooms?start_id=42`) + .get(`/v1/meetings/themes/my-theme/rooms?start_id=42`) .reply(401, { status: 401, error: 'Unauthorized', @@ -241,7 +241,7 @@ describe('Meetings > Themes', () => { test('Will set default theme', async () => { scope - .patch(`/meetings/applications`, { + .patch(`/v1/meetings/applications`, { update_details: { default_theme_id: 'my-theme', }, diff --git a/packages/meetings/lib/meetings.ts b/packages/meetings/lib/meetings.ts index 51070dc2..d7691446 100644 --- a/packages/meetings/lib/meetings.ts +++ b/packages/meetings/lib/meetings.ts @@ -93,7 +93,7 @@ export class Meetings extends Client { params: MeetingRoomParams = {}, ): Promise { const resp = await this.sendGetRequest( - `${this.config.meetingsHost}/meetings/rooms`, + `${this.config.meetingsHost}/v1/meetings/rooms`, Client.transformers.snakeCaseObjectKeys(params), ); @@ -102,7 +102,7 @@ export class Meetings extends Client { async getRoom(roomId: string): Promise { const resp = await this.sendGetRequest( - `${this.config.meetingsHost}/meetings/rooms/${roomId}`, + `${this.config.meetingsHost}/v1/meetings/rooms/${roomId}`, ); return apiRoomToSdk(resp.data); @@ -110,7 +110,7 @@ export class Meetings extends Client { async createRoom(room: MeetingRoom): Promise { const resp = await this.sendPostRequest( - `${this.config.meetingsHost}/meetings/rooms`, + `${this.config.meetingsHost}/v1/meetings/rooms`, pick( Client.transformers.snakeCaseObjectKeys(room, true), this.ROOM_WRITE_KEYS, @@ -122,7 +122,7 @@ export class Meetings extends Client { async updateRoom(roomId: string, room: MeetingRoom): Promise { const resp = await this.sendPatchRequest( - `${this.config.meetingsHost}/meetings/rooms/${roomId}`, + `${this.config.meetingsHost}/v1/meetings/rooms/${roomId}`, { update_options: pick( Client.transformers.snakeCaseObjectKeys(room, true), @@ -136,7 +136,7 @@ export class Meetings extends Client { async getRecording(recordingId: string): Promise { const resp = await this.sendGetRequest( - `${this.config.meetingsHost}/meetings/recordings/${recordingId}`, + `${this.config.meetingsHost}/v1/meetings/recordings/${recordingId}`, ); return apiRecordingToSdk(resp.data); @@ -146,7 +146,7 @@ export class Meetings extends Client { sessionId: string, ): AsyncGenerator { const resp = await this.sendGetRequest( - `${this.config.meetingsHost}/meetings/sessions/${sessionId}`, + `${this.config.meetingsHost}/v1/meetings/sessions/${sessionId}`, ); const recordings = (resp.data?._embedded?.recordings || []).map( @@ -158,7 +158,7 @@ export class Meetings extends Client { async deleteRecording(recordingId: string): Promise { await this.sendDeleteRequest( - `${this.config.meetingsHost}/meetings/recordings/${recordingId}`, + `${this.config.meetingsHost}/v1/meetings/recordings/${recordingId}`, ); } @@ -168,7 +168,7 @@ export class Meetings extends Client { undefined > { const resp = await this.sendGetRequest( - `${this.config.meetingsHost}/meetings/dial-in-numbers`, + `${this.config.meetingsHost}/v1/meetings/dial-in-numbers`, ); const numbers = (resp.data || []).map((number) => @@ -180,7 +180,7 @@ export class Meetings extends Client { async *getThemes(): AsyncGenerator { const resp = await this.sendGetRequest( - `${this.config.meetingsHost}/meetings/themes`, + `${this.config.meetingsHost}/v1/meetings/themes`, ); const themes = (resp.data || []).map((theme) => @@ -192,7 +192,7 @@ export class Meetings extends Client { async getTheme(themeId: string): Promise { const resp = await this.sendGetRequest( - `${this.config.meetingsHost}/meetings/themes/${themeId}`, + `${this.config.meetingsHost}/v1/meetings/themes/${themeId}`, ); return Client.transformers.camelCaseObjectKeys(resp.data); @@ -200,7 +200,7 @@ export class Meetings extends Client { async deleteTheme(themeId: string, force = false): Promise { await this.sendRequest({ - url: `${this.config.meetingsHost}/meetings/themes/${themeId}`, + url: `${this.config.meetingsHost}/v1/meetings/themes/${themeId}`, params: force ? { force: true } : null, method: HTTPMethods.DELETE, }); @@ -208,7 +208,7 @@ export class Meetings extends Client { async createTheme(theme: Theme): Promise { const resp = await this.sendPostRequest( - `${this.config.meetingsHost}/meetings/themes`, + `${this.config.meetingsHost}/v1/meetings/themes`, pick( Client.transformers.snakeCaseObjectKeys(theme, true), this.THEME_WRITE_KEYS, @@ -220,7 +220,7 @@ export class Meetings extends Client { async updateTheme(themeId: string, theme: Theme): Promise { const resp = await this.sendPatchRequest( - `${this.config.meetingsHost}/meetings/themes/${themeId}`, + `${this.config.meetingsHost}/v1/meetings/themes/${themeId}`, { update_details: pick( Client.transformers.snakeCaseObjectKeys(theme, true), @@ -261,7 +261,7 @@ export class Meetings extends Client { params: MeetingRoomParams = {}, ): Promise { const resp = await this.sendGetRequest( - `${this.config.meetingsHost}/meetings/themes/${themeId}/rooms`, + `${this.config.meetingsHost}/v1/meetings/themes/${themeId}/rooms`, Client.transformers.snakeCaseObjectKeys(params), ); @@ -270,7 +270,7 @@ export class Meetings extends Client { async setDefaultTheme(themeId: string): Promise { await this.sendPatchRequest( - `${this.config.meetingsHost}/meetings/applications`, + `${this.config.meetingsHost}/v1/meetings/applications`, { update_details: { default_theme_id: themeId, @@ -297,7 +297,7 @@ export class Meetings extends Client { let error; try { await this.sendPutRequest( - `${this.config.meetingsHost}/meetings/themes/${themeId}/finalizeLogos`, + `${this.config.meetingsHost}/v1/meetings/themes/${themeId}/finalizeLogos`, { keys: [urlResponse.fields.key], }, @@ -344,7 +344,7 @@ export class Meetings extends Client { protected async _getIconUploadUrl(logo: LogoType): Promise { const resp = await this.sendGetRequest( - `${this.config.meetingsHost}/meetings/themes/logos-upload-urls`, + `${this.config.meetingsHost}/v1/meetings/themes/logos-upload-urls`, ); const matchingUrl = (resp.data || []).filter( diff --git a/packages/proactive-connect/package.json b/packages/proactive-connect/package.json index 7a5d5ad5..97febe0a 100644 --- a/packages/proactive-connect/package.json +++ b/packages/proactive-connect/package.json @@ -28,6 +28,7 @@ }, "dependencies": { "@vonage/server-client": "^1.8.2", + "@vonage/vetch": "1.5.1", "form-data": "^4.0.0", "lodash.pick": "^4.4.0" },