@whereby.com/browser-sdk 2.0.0-alpha → 2.0.0-alpha2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/lib.cjs.js +5467 -0
  2. package/dist/lib.esm.js +5451 -0
  3. package/dist/types.d.ts +104 -0
  4. package/dist/v2-alpha2.js +105 -0
  5. package/package.json +6 -1
  6. package/.eslintrc +0 -23
  7. package/.github/actions/build/action.yml +0 -17
  8. package/.github/workflows/deploy.yml +0 -102
  9. package/.github/workflows/test.yml +0 -24
  10. package/.prettierignore +0 -7
  11. package/.prettierrc +0 -4
  12. package/.storybook/main.cjs +0 -16
  13. package/.storybook/preview.js +0 -9
  14. package/jest.config.js +0 -6
  15. package/rollup.config.js +0 -70
  16. package/src/lib/RoomConnection.ts +0 -516
  17. package/src/lib/RoomParticipant.ts +0 -77
  18. package/src/lib/__tests__/embed.unit.ts +0 -77
  19. package/src/lib/api/ApiClient.ts +0 -111
  20. package/src/lib/api/Credentials.ts +0 -45
  21. package/src/lib/api/HttpClient.ts +0 -95
  22. package/src/lib/api/MultipartHttpClient.ts +0 -53
  23. package/src/lib/api/OrganizationApiClient.ts +0 -64
  24. package/src/lib/api/Response.ts +0 -34
  25. package/src/lib/api/credentialsService/index.ts +0 -159
  26. package/src/lib/api/credentialsService/test/index.spec.ts +0 -181
  27. package/src/lib/api/deviceService/index.ts +0 -42
  28. package/src/lib/api/deviceService/tests/index.spec.ts +0 -74
  29. package/src/lib/api/extractUtils.ts +0 -160
  30. package/src/lib/api/index.ts +0 -8
  31. package/src/lib/api/localStorageWrapper/index.ts +0 -15
  32. package/src/lib/api/models/Account.ts +0 -48
  33. package/src/lib/api/models/Meeting.ts +0 -42
  34. package/src/lib/api/models/Organization.ts +0 -186
  35. package/src/lib/api/models/Room.ts +0 -44
  36. package/src/lib/api/models/account/EmbeddedFreeTierStatus.ts +0 -34
  37. package/src/lib/api/models/tests/Account.spec.ts +0 -128
  38. package/src/lib/api/models/tests/Organization.spec.ts +0 -161
  39. package/src/lib/api/models/tests/Room.spec.ts +0 -74
  40. package/src/lib/api/modules/AbstractStore.ts +0 -18
  41. package/src/lib/api/modules/ChromeStorageStore.ts +0 -44
  42. package/src/lib/api/modules/LocalStorageStore.ts +0 -57
  43. package/src/lib/api/modules/tests/ChromeStorageStore.spec.ts +0 -67
  44. package/src/lib/api/modules/tests/LocalStorageStore.spec.ts +0 -79
  45. package/src/lib/api/modules/tests/__mocks__/storage.ts +0 -24
  46. package/src/lib/api/organizationService/index.ts +0 -284
  47. package/src/lib/api/organizationService/tests/index.spec.ts +0 -781
  48. package/src/lib/api/organizationServiceCache/index.ts +0 -28
  49. package/src/lib/api/organizationServiceCache/tests/index.spec.ts +0 -101
  50. package/src/lib/api/parameterAssertUtils.ts +0 -166
  51. package/src/lib/api/roomService/index.ts +0 -310
  52. package/src/lib/api/roomService/tests/index.spec.ts +0 -668
  53. package/src/lib/api/test/ApiClient.spec.ts +0 -139
  54. package/src/lib/api/test/HttpClient.spec.ts +0 -120
  55. package/src/lib/api/test/MultipartHttpClient.spec.ts +0 -145
  56. package/src/lib/api/test/OrganizationApiClient.spec.ts +0 -132
  57. package/src/lib/api/test/extractUtils.spec.ts +0 -357
  58. package/src/lib/api/test/helpers.ts +0 -41
  59. package/src/lib/api/test/parameterAssertUtils.spec.ts +0 -265
  60. package/src/lib/api/types.ts +0 -6
  61. package/src/lib/embed.ts +0 -172
  62. package/src/lib/index.ts +0 -3
  63. package/src/lib/react/VideoElement.tsx +0 -16
  64. package/src/lib/react/index.ts +0 -3
  65. package/src/lib/react/useLocalMedia.ts +0 -25
  66. package/src/lib/react/useRoomConnection.ts +0 -92
  67. package/src/lib/reducer.ts +0 -142
  68. package/src/stories/custom-ui.stories.tsx +0 -133
  69. package/src/stories/prebuilt-ui.stories.tsx +0 -131
  70. package/src/stories/styles.css +0 -74
  71. package/src/types.d.ts +0 -175
  72. package/tsconfig.json +0 -30
@@ -1,28 +0,0 @@
1
- import { assertInstanceOf, assertString } from "../parameterAssertUtils";
2
- import OrganizationService from "../organizationService/index";
3
- import Organization from "../models/Organization";
4
-
5
- export default class OrganizationServiceCache {
6
- private _organizationService: OrganizationService;
7
- private _subdomain: string;
8
- private _organizationPromise: Promise<Organization | null> | null;
9
-
10
- constructor({ organizationService, subdomain }: { organizationService: OrganizationService; subdomain: string }) {
11
- assertInstanceOf(organizationService, OrganizationService);
12
- assertString(subdomain, "subdomain");
13
- this._organizationService = organizationService;
14
- this._subdomain = subdomain;
15
- this._organizationPromise = null;
16
- }
17
-
18
- initOrganization(): Promise<void> {
19
- return this.fetchOrganization().then(() => undefined);
20
- }
21
-
22
- fetchOrganization(): Promise<Organization | null> {
23
- if (!this._organizationPromise) {
24
- this._organizationPromise = this._organizationService.getOrganizationBySubdomain(this._subdomain);
25
- }
26
- return this._organizationPromise;
27
- }
28
- }
@@ -1,101 +0,0 @@
1
- // @ts-nocheck
2
- import ApiClient from "../../ApiClient";
3
- import OrganizationServiceCache from "../index";
4
- import OrganizationService from "../../organizationService";
5
- import Organization from "../../models/Organization";
6
- import { itShouldThrowIfInvalid } from "../../test/helpers";
7
-
8
- jest.mock("../../organizationService");
9
-
10
- describe("OrganizationServiceCache", () => {
11
- let apiClient: jest.Mocked<ApiClient>;
12
- let organizationService: OrganizationService;
13
- let organizationServiceCache: OrganizationServiceCache;
14
- let subdomain: string | undefined;
15
- let organization: Organization;
16
-
17
- beforeEach(() => {
18
- subdomain = "someOrganization";
19
- const permissions = {};
20
- const limits = {
21
- maxNumberOfClaimedRooms: null,
22
- };
23
- apiClient = new ApiClient() as jest.Mocked<ApiClient>;
24
-
25
- organization = new Organization({
26
- organizationId: "1",
27
- organizationName: "some-name",
28
- subdomain: "someOrganization",
29
- permissions,
30
- limits,
31
- });
32
- organizationService = new OrganizationService({ apiClient });
33
- organizationService.getOrganizationBySubdomain.mockResolvedValue(organization);
34
- organizationServiceCache = new OrganizationServiceCache({
35
- subdomain,
36
- organizationService,
37
- });
38
- });
39
-
40
- describe("constructor", () => {
41
- itShouldThrowIfInvalid(
42
- "subdomain",
43
- () =>
44
- new OrganizationServiceCache({
45
- subdomain: undefined,
46
- organizationService,
47
- })
48
- );
49
-
50
- itShouldThrowIfInvalid(
51
- "organizationService",
52
- () =>
53
- new OrganizationServiceCache({
54
- subdomain,
55
- organizationService: undefined,
56
- })
57
- );
58
- });
59
-
60
- describe("initOrganization", () => {
61
- it("should do nothing", async () => {
62
- await organizationServiceCache.initOrganization();
63
-
64
- expect(organizationService.getOrganizationBySubdomain).toBeCalledWith(subdomain);
65
- });
66
-
67
- it("should resolve with undefined", async () => {
68
- const result = await organizationServiceCache.initOrganization();
69
-
70
- expect(result).toBeUndefined();
71
- });
72
- });
73
-
74
- describe("fetchOrganization", () => {
75
- describe("when cache is uninitialized", () => {
76
- it("should fetch the organization state", async () => {
77
- await organizationServiceCache.fetchOrganization();
78
-
79
- expect(organizationService.getOrganizationBySubdomain).toBeCalledWith(subdomain);
80
- });
81
- });
82
-
83
- describe("when organization has been fetched once", () => {
84
- beforeEach(() => {
85
- return organizationServiceCache.fetchOrganization();
86
- });
87
-
88
- it("should do nothing", async () => {
89
- organizationServiceCache.fetchOrganization();
90
-
91
- expect(organizationService.getOrganizationBySubdomain).toBeCalledWith(subdomain);
92
- });
93
- });
94
-
95
- it("should return the organization returned from the organizationService", async () => {
96
- const result = await organizationServiceCache.fetchOrganization();
97
-
98
- expect(result).toEqual(organization);
99
- });
100
- });
101
- });
@@ -1,166 +0,0 @@
1
- import assert from "assert";
2
-
3
- /**
4
- * Asserts that value is truthy.
5
- *
6
- * @param value - The value to check.
7
- * @param {string} parameterName - The name of the parameter.
8
- */
9
- export function assertTruthy(value: unknown, parameterName: string): unknown {
10
- assert.ok(value, `${parameterName} is required`);
11
- return value;
12
- }
13
-
14
- /**
15
- * Asserts that value is a number.
16
- *
17
- * @param value - The value to check.
18
- * @param {string} parameterName - The name of the parameter.
19
- */
20
- export function assertBoolean(value: unknown, parameterName: string): boolean {
21
- assert.ok(typeof value === "boolean", `${parameterName}<boolean> is required`);
22
- return value;
23
- }
24
-
25
- /**
26
- * Asserts that value is a number.
27
- *
28
- * @param value - The value to check.
29
- * @param {string} parameterName - The name of the parameter.
30
- */
31
- export function assertNumber(value: unknown, parameterName: string): number {
32
- assert.ok(typeof value === "number", `${parameterName}<number> is required`);
33
- return value;
34
- }
35
-
36
- /**
37
- * Asserts that value is a string.
38
- *
39
- * @param value - The value to check.
40
- * @param {string} parameterName - The name of the parameter.
41
- */
42
- export function assertString(value: unknown, parameterName: string): string {
43
- assert.ok(typeof value === "string", `${parameterName}<string> is required`);
44
- return value;
45
- }
46
-
47
- /**
48
- * Asserts that value is of the provided type.
49
- *
50
- * @param value - The value to check.
51
- * @param type - The type that value should be.
52
- * @param {string} [parameterName] - The name of the parameter.
53
- */
54
- export function assertInstanceOf<T>(value: unknown, type: new (any: any) => T, parameterName?: string): T {
55
- const resolvedParameterName = parameterName || type.name[0].toLowerCase() + type.name.substring(1);
56
- assert.ok(value instanceof type, `${resolvedParameterName}<${type.name}> is required`);
57
- return value;
58
- }
59
-
60
- /**
61
- * Asserts that the provided room name is a valid roomName.
62
- *
63
- * @param roomName - The roomName to check.
64
- * @param {string} [parameterName="roomName"] - The name of the parameter.
65
- */
66
- export function assertRoomName(roomName: unknown, parameterName = "roomName"): string {
67
- assertString(roomName, parameterName);
68
- assert.equal(typeof roomName === "string" && roomName[0], "/", `${parameterName} must begin with a '/'`);
69
- return roomName as string;
70
- }
71
-
72
- /**
73
- * Asserts that the provided array is a valid array.
74
- *
75
- * @param array - The array to check.
76
- * @param {string} [parameterName] - The name of the parameter.
77
- */
78
- export function assertArray(array: unknown, parameterName: string): Array<unknown> {
79
- assert.ok(Array.isArray(array), `${parameterName}<array> is required`);
80
- return array as Array<unknown>;
81
- }
82
-
83
- /**
84
- * Asserts that value is one of the values provided in an array
85
- *
86
- * @param value - The value to check.
87
- * @param allowedValues - An array of allowed values
88
- * @param {string} parameterName - The name of the parameter.
89
- */
90
- export function assertOneOf<T>(value: T, allowedValues: Array<unknown>, parameterName: string): T {
91
- assertTruthy(value, "value");
92
- assertArray(allowedValues, "allowedValues");
93
-
94
- const isAllowed = allowedValues.includes(value);
95
- if (!isAllowed) {
96
- throw new Error(`${parameterName}<string> must be one of the following: ${allowedValues.join(", ")}`);
97
- }
98
-
99
- return value;
100
- }
101
-
102
- /**
103
- * Asserts that the provided reference is of the provided primitive type.
104
- *
105
- * @param {*} ref - The reference (variable or constant) to test.
106
- * @param {string} type - The expected primitive type.
107
- * @param {string} name - The name of the reference, will be used in the error message.
108
- * @param {string} [message] - A custom message to use when the assertion fails.
109
- */
110
- export function assertType(ref: unknown, type: string, name: string, message?: string): void {
111
- assert.ok(typeof name === "string", "name must be of type string");
112
- const errorMessage = message || `${name} must be of type ${type}`;
113
- assert.ok(ref !== null && typeof ref === type, errorMessage);
114
- }
115
-
116
- /**
117
- * Asserts that the provided reference is a record.
118
- *
119
- * @param {*} ref - The reference (variable or constant) to test.
120
- * @param {string} name - The name of the reference, will be used in the error message.
121
- */
122
- export function assertRecord(ref: unknown, name: string): Record<string, unknown> {
123
- if (ref === null || ref === undefined || typeof ref !== "object" || Array.isArray(ref)) {
124
- throw new Error(`${name} must be a record. ${JSON.stringify(ref)}`);
125
- }
126
-
127
- return ref as Record<string, unknown>;
128
- }
129
-
130
- /**
131
- * Asserts that the provided reference is either null or of the provided primitive type.
132
- *
133
- * @param {*} ref - The reference (variable or constant) to test.
134
- * @param {string} type - The expected primitive type.
135
- * @param {string} name - The name of the reference, will be used in the error message.
136
- * @param {string} [message] - A custom message to use when the assertion fails.
137
- */
138
- export function assertNullOrType(ref: unknown, type: string, name: string, message?: string): void {
139
- assertString(name, "name");
140
- const errorMessage = message || `${name} must be null or of type ${type}`;
141
- assert.ok(ref === null || typeof ref === type, errorMessage);
142
- }
143
-
144
- /**
145
- * Asserts that the provided reference is either null or a boolean.
146
- *
147
- * @param {*} ref - The reference (variable or constant) to test.
148
- * @param {string} name - The name of the reference, will be used in the error message.
149
- * @param {string} [message] - A custom message to use when the assertion fails.
150
- */
151
- export function assertNullOrBoolean(ref: unknown, name: string, message?: string): void {
152
- assertString(name, "name");
153
- assertNullOrType(ref, "boolean", name, message);
154
- }
155
-
156
- /**
157
- * Asserts that the provided reference is either null or a string.
158
- *
159
- * @param {*} ref - The reference (variable or constant) to test.
160
- * @param {string} name - The name of the reference, will be used in the error message.
161
- * @param {string} [message] - A custom message to use when the assertion fails.
162
- */
163
- export function assertNullOrString(ref: unknown, name: string, message?: string): void {
164
- assertString(name, "name");
165
- assertNullOrType(ref, "string", name, message);
166
- }
@@ -1,310 +0,0 @@
1
- // @ts-nocheck
2
- import Room from "../models/Room";
3
- import {
4
- assertInstanceOf,
5
- assertRoomName,
6
- assertString,
7
- assertArray,
8
- assertOneOf,
9
- assertNumber,
10
- } from "../parameterAssertUtils";
11
- import OrganizationApiClient from "../OrganizationApiClient";
12
- import Meeting from "../models/Meeting";
13
-
14
- function createRoomUrl(roomName, path = "") {
15
- const encodedDisplayName = encodeURIComponent(roomName.substring(1));
16
- return `/room/${encodedDisplayName}${path}`;
17
- }
18
-
19
- /**
20
- * Service for talking to the Room related APIs
21
- */
22
- export default class RoomService {
23
- /**
24
- * @param {object} organizationApiClient (required)
25
- */
26
- constructor({ organizationApiClient }) {
27
- this._organizationApiClient = assertInstanceOf(organizationApiClient, OrganizationApiClient);
28
- }
29
-
30
- /**
31
- * Gets the list of visited rooms
32
- *
33
- * @param {Object} args
34
- * @param {Array<string>} [types=["team"]] - The type of rooms that should be fetched.
35
- * @param {Array<string>} [fields=["meeting"]] - The fields of room that should be fetched.
36
- * @returns {Promise<array>} - It will resolve with an array.
37
- */
38
- getRooms({ types, fields = [] } = {}) {
39
- assertArray(types, "types");
40
- assertArray(fields, "fields");
41
- return this._organizationApiClient
42
- .request("/room", {
43
- method: "GET",
44
- params: { types: types.join(","), fields: fields.join(","), includeOnlyLegacyRoomType: "false" },
45
- })
46
- .then(({ data }) => data.rooms.map((room) => new Room(room)));
47
- }
48
-
49
- /**
50
- * Gets the specified room.
51
- *
52
- * Currently information is implicitly alluded to via the servers
53
- * `/room/roomName` response. This method patches the data
54
- * tempoarily, until the day it comes back from the server.
55
- *
56
- * @returns {Promise<Room>} - It will resolve with the Room.
57
- */
58
- getRoom({ roomName, fields }: { roomName: string; fields?: Array<string> }): Promise<Room> {
59
- assertRoomName(roomName);
60
-
61
- const encodedDisplayName = encodeURIComponent(roomName.substring(1));
62
-
63
- return this._organizationApiClient
64
- .request(`/rooms/${encodedDisplayName}`, {
65
- method: "GET",
66
- params: { includeOnlyLegacyRoomType: "false", ...(fields && { fields: fields.join(",") }) },
67
- })
68
- .then(
69
- ({ data }) =>
70
- new Room(
71
- Object.assign({}, data, {
72
- roomName,
73
- ...(data.meeting && { meeting: Meeting.fromJson(data.meeting) }),
74
- })
75
- )
76
- )
77
- .catch((response) => {
78
- if (response.status === 404) {
79
- return new Room({
80
- roomName,
81
- isClaimed: false,
82
- mode: "normal",
83
- product: {
84
- categoryName: "personal_free",
85
- },
86
- type: "personal",
87
- legacyRoomType: "free",
88
- });
89
- }
90
-
91
- if (response.status === 400 && response.data.error === "Banned room") {
92
- return new Room({ roomName, isBanned: true });
93
- }
94
-
95
- // Either server error or something else.
96
- throw new Error(response.data ? response.data.error : "Could not fetch room information");
97
- });
98
- }
99
-
100
- /**
101
- * Claims the specified room.
102
- *
103
- * @param {Object} args
104
- * @param {String} args.roomName - The roomName to claim
105
- * @param {String} args.type - The type of room to claim
106
- * @param {String} args.mode - The optional mode of room to claim
107
- * @param {[Boolean]} args.isLocked - The optional lock status of room to claim
108
- * @returns {Promise} - It will resolve with undefined.
109
- */
110
- claimRoom({ roomName, type, mode, isLocked }) {
111
- assertRoomName(roomName);
112
- assertString(type, "type");
113
-
114
- return this._organizationApiClient
115
- .request("/room/claim", {
116
- method: "POST",
117
- data: {
118
- roomName,
119
- type,
120
- ...(typeof mode === "string" && { mode }),
121
- ...(typeof isLocked === "boolean" && { isLocked }),
122
- },
123
- })
124
- .then(() => undefined)
125
- .catch((response) => {
126
- throw new Error(response.data.error || "Failed to claim room");
127
- });
128
- }
129
-
130
- /**
131
- * Unclaims the specified room.
132
- *
133
- * @param {string} roomName - the room name to unclaim.
134
- * @returns {Promise.<undefined>} - It will resolve with undefined.
135
- */
136
- unclaimRoom(roomName) {
137
- assertRoomName(roomName);
138
- const encodedDisplayName = encodeURIComponent(roomName.substring(1));
139
-
140
- return this._organizationApiClient
141
- .request(`/room/${encodedDisplayName}`, {
142
- method: "DELETE",
143
- })
144
- .then(() => undefined);
145
- }
146
-
147
- /**
148
- * Changes the name of the room
149
- *
150
- * @param {Object} args
151
- * @param {string} args.roomName - The name of the room to rename
152
- * @param {string} args.newRoomName - The new name
153
- * @returns {Promise<undefined>} - It will resolve if the room was renamed, reject for all other cases
154
- */
155
- renameRoom({ roomName, newRoomName }) {
156
- assertRoomName(roomName);
157
- assertString(newRoomName, "newRoomName");
158
-
159
- const encodedRoomName = encodeURIComponent(roomName.substring(1));
160
- return this._organizationApiClient
161
-
162
- .request(`/room/${encodedRoomName}/roomName`, {
163
- method: "PUT",
164
- data: { newRoomName },
165
- })
166
- .then(() => undefined);
167
- }
168
-
169
- /**
170
- * Changes the room mode (experimental)
171
- *
172
- * @param {string} roomName - The name of the room to change mode of
173
- * @param {string} mode - The name of mode to set, currently only "group" is supported
174
- * @returns {Promise<undefined>} - It will resolve if mode was changed, rejects for all other cases
175
- */
176
- changeMode({ roomName, mode }) {
177
- assertRoomName(roomName);
178
- assertString(mode, "mode");
179
-
180
- const encodedDisplayName = encodeURIComponent(roomName.substring(1));
181
- return this._organizationApiClient
182
-
183
- .request(`/room/${encodedDisplayName}/mode`, {
184
- method: "PUT",
185
- data: { mode },
186
- })
187
- .then(() => undefined);
188
- }
189
-
190
- /**
191
- * Updates the room prefs
192
- *
193
- * @param {string} roomName - The name of the room to change mode of
194
- * @param {object} preferences - The prefs you want to update and their values
195
- * @returns {Promise<undefined>} - It will resolve if updated, rejects for all other cases
196
- */
197
- updatePreferences({ roomName, preferences }) {
198
- assertRoomName(roomName);
199
- assertInstanceOf(preferences, Object, "preferences");
200
-
201
- const encodedDisplayName = encodeURIComponent(roomName.substring(1));
202
- return this._organizationApiClient
203
- .request(`/room/${encodedDisplayName}/preferences`, {
204
- method: "PATCH",
205
- data: preferences,
206
- })
207
- .then(() => undefined);
208
- }
209
-
210
- /**
211
- * Updates the protected room prefs
212
- *
213
- * @param {string} roomName - The name of the room to change mode of
214
- * @param {object} preferences - The protected prefs you want to update and their values
215
- * @returns {Promise<undefined>} - It will resolve if updated, rejects for all other cases
216
- */
217
- updateProtectedPreferences({ roomName, preferences }) {
218
- assertRoomName(roomName);
219
- assertInstanceOf(preferences, Object, "preferences");
220
-
221
- const encodedDisplayName = encodeURIComponent(roomName.substring(1));
222
- return this._organizationApiClient
223
- .request(`/room/${encodedDisplayName}/protected-preferences`, {
224
- method: "PATCH",
225
- data: preferences,
226
- })
227
- .then(() => undefined);
228
- }
229
-
230
- getRoomPermissions(roomName, { roomKey } = {}) {
231
- assertRoomName(roomName);
232
-
233
- return this._organizationApiClient
234
- .request(createRoomUrl(roomName, "/permissions"), {
235
- method: "GET",
236
- ...(roomKey && { headers: { "X-Whereby-Room-Key": roomKey } }),
237
- })
238
- .then((response) => {
239
- const { permissions, limits } = response.data;
240
- return {
241
- permissions,
242
- limits,
243
- };
244
- });
245
- }
246
-
247
- /**
248
- * Gets the specified room metrics
249
- *
250
- * @param {Object} args
251
- * @param {string} args.roomName - The name of the room to get metrics from.
252
- * @param {string} args.metrics - Comma-separated list of metrics to include.
253
- * @param {string} args.from (optional) - Start time (inclusive) to count from in
254
- * ISO format. Defaults to counting from the start of time.
255
- * @param {string} args.to (optional) - End time (exclusive) to count up to in
256
- * ISO format. Defaults to counting up to the current time.
257
- * @returns {Promise<Object>} - It will resolve with the requested metrics.
258
- */
259
- getRoomMetrics({ roomName, metrics, from, to }) {
260
- assertRoomName(roomName);
261
- assertString(metrics, "metrics");
262
-
263
- return this._organizationApiClient
264
- .request(createRoomUrl(roomName, "/metrics"), {
265
- method: "GET",
266
- params: { metrics, from, to },
267
- })
268
- .then((response) => response.data);
269
- }
270
-
271
- /**
272
- * Changes the room type
273
- *
274
- * @param {Object} args
275
- * @param {string} args.roomName - The name of the room to change mode of
276
- * @param {"personal" | "personal_xl"} args.type - Room type that should be set
277
- * @returns {Promise<undefined>} - It will resolve if type was changed, rejects for all other cases
278
- */
279
- changeType({ roomName, type }) {
280
- assertRoomName(roomName);
281
- assertOneOf(type, ["personal", "personal_xl"], "type");
282
-
283
- const encodedDisplayName = encodeURIComponent(roomName.substring(1));
284
- return this._organizationApiClient
285
-
286
- .request(`/room/${encodedDisplayName}/type`, {
287
- method: "PUT",
288
- data: { type },
289
- })
290
- .then(() => undefined);
291
- }
292
-
293
- /** Gets a Forest campaign social image
294
- *
295
- * @param {Object} args
296
- * @param {string} args.roomName - The name of the room to get metrics from.
297
- * @param {number} args.count - Number to be displayed in the image as tree count.
298
- * @returns {Promise<string>} - It will resolve with the image url.
299
- */
300
- getForestSocialImage({ roomName, count }) {
301
- assertRoomName(roomName);
302
- assertNumber(count, "count");
303
-
304
- return this._organizationApiClient
305
- .request(createRoomUrl(roomName, `/forest-social-image/${count}`), {
306
- method: "GET",
307
- })
308
- .then((response) => response.data.imageUrl);
309
- }
310
- }