@internxt/sdk 1.9.12 → 1.9.14
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.
- package/dist/drive/payments/index.d.ts +19 -1
- package/dist/drive/payments/index.js +23 -1
- package/dist/drive/payments/object-storage.d.ts +1 -1
- package/dist/drive/payments/types/tiers.d.ts +51 -0
- package/dist/drive/payments/types/tiers.js +12 -0
- package/dist/drive/payments/{types.d.ts → types/types.d.ts} +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/meet/index.d.ts +15 -0
- package/dist/meet/index.js +111 -0
- package/dist/meet/index.test.d.ts +1 -0
- package/dist/meet/index.test.js +265 -0
- package/dist/meet/types.d.ts +22 -0
- package/dist/meet/types.js +2 -0
- package/package.json +1 -1
- /package/dist/drive/payments/{types.js → types/types.js} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
|
|
2
|
-
import {
|
|
2
|
+
import { Tier } from './types/tiers';
|
|
3
|
+
import { AvailableProducts, CreateCheckoutSessionPayload, CreatedSubscriptionData, CreatePaymentSessionPayload, CustomerBillingInfo, DisplayPrice, FreeTrialAvailable, Invoice, InvoicePayload, PaymentMethod, ProductData, RedeemCodePayload, UpdateSubscriptionPaymentMethod, UserSubscription, UserType } from './types/types';
|
|
3
4
|
export declare class Payments {
|
|
4
5
|
private readonly client;
|
|
5
6
|
private readonly appDetails;
|
|
@@ -63,6 +64,23 @@ export declare class Payments {
|
|
|
63
64
|
* @returns an object containing available products
|
|
64
65
|
*/
|
|
65
66
|
checkUserAvailableProducts(): Promise<AvailableProducts>;
|
|
67
|
+
/**
|
|
68
|
+
* Gets product information based on the user's subscription tier.
|
|
69
|
+
*
|
|
70
|
+
* @param {UserType} [userType] - The type of user for which to query product information.
|
|
71
|
+
* If not specified, UserType.Individual will be used by default.
|
|
72
|
+
* @returns {Promise<Tier>} A promise that resolves with the product information
|
|
73
|
+
* available for the specified tier.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* // Get products for an individual user tier (default)
|
|
77
|
+
* const individualProducts = await getUserTier();
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* // Get products for a business user tier
|
|
81
|
+
* const businessProducts = await getUserTier(UserType.Business);
|
|
82
|
+
*/
|
|
83
|
+
getUserTier(userType?: UserType): Promise<Tier>;
|
|
66
84
|
/**
|
|
67
85
|
* Returns the needed headers for the module requests
|
|
68
86
|
* @private
|
|
@@ -50,7 +50,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
50
50
|
exports.Payments = void 0;
|
|
51
51
|
var headers_1 = require("../../shared/headers");
|
|
52
52
|
var client_1 = require("../../shared/http/client");
|
|
53
|
-
var types_1 = require("./types");
|
|
53
|
+
var types_1 = require("./types/types");
|
|
54
54
|
var Payments = /** @class */ (function () {
|
|
55
55
|
function Payments(apiUrl, appDetails, apiSecurity) {
|
|
56
56
|
this.client = client_1.HttpClient.create(apiUrl, apiSecurity.unauthorizedCallback);
|
|
@@ -204,6 +204,28 @@ var Payments = /** @class */ (function () {
|
|
|
204
204
|
Payments.prototype.checkUserAvailableProducts = function () {
|
|
205
205
|
return this.client.get('/products', this.headers());
|
|
206
206
|
};
|
|
207
|
+
/**
|
|
208
|
+
* Gets product information based on the user's subscription tier.
|
|
209
|
+
*
|
|
210
|
+
* @param {UserType} [userType] - The type of user for which to query product information.
|
|
211
|
+
* If not specified, UserType.Individual will be used by default.
|
|
212
|
+
* @returns {Promise<Tier>} A promise that resolves with the product information
|
|
213
|
+
* available for the specified tier.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* // Get products for an individual user tier (default)
|
|
217
|
+
* const individualProducts = await getUserTier();
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* // Get products for a business user tier
|
|
221
|
+
* const businessProducts = await getUserTier(UserType.Business);
|
|
222
|
+
*/
|
|
223
|
+
Payments.prototype.getUserTier = function (userType) {
|
|
224
|
+
var query = new URLSearchParams();
|
|
225
|
+
if (userType !== undefined)
|
|
226
|
+
query.set('tierType', userType);
|
|
227
|
+
return this.client.get("/products/tier?".concat(query.toString()), this.headers());
|
|
228
|
+
};
|
|
207
229
|
/**
|
|
208
230
|
* Returns the needed headers for the module requests
|
|
209
231
|
* @private
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
interface AntivirusFeatures {
|
|
2
|
+
enabled: boolean;
|
|
3
|
+
}
|
|
4
|
+
interface BackupsFeatures {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface DriveFeatures {
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
maxSpaceBytes: number;
|
|
10
|
+
workspaces: {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
minimumSeats: number;
|
|
13
|
+
maximumSeats: number;
|
|
14
|
+
maxSpaceBytesPerSeat: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
interface MeetFeatures {
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
paxPerCall: number;
|
|
20
|
+
}
|
|
21
|
+
interface MailFeatures {
|
|
22
|
+
enabled: boolean;
|
|
23
|
+
addressesPerUser: number;
|
|
24
|
+
}
|
|
25
|
+
export interface VpnFeatures {
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
featureId: string;
|
|
28
|
+
}
|
|
29
|
+
export declare enum Service {
|
|
30
|
+
Drive = "drive",
|
|
31
|
+
Backups = "backups",
|
|
32
|
+
Antivirus = "antivirus",
|
|
33
|
+
Meet = "meet",
|
|
34
|
+
Mail = "mail",
|
|
35
|
+
Vpn = "vpn"
|
|
36
|
+
}
|
|
37
|
+
export interface Tier {
|
|
38
|
+
id: string;
|
|
39
|
+
label: string;
|
|
40
|
+
productId: string;
|
|
41
|
+
billingType: 'subscription' | 'lifetime';
|
|
42
|
+
featuresPerService: {
|
|
43
|
+
[Service.Drive]: DriveFeatures;
|
|
44
|
+
[Service.Backups]: BackupsFeatures;
|
|
45
|
+
[Service.Antivirus]: AntivirusFeatures;
|
|
46
|
+
[Service.Meet]: MeetFeatures;
|
|
47
|
+
[Service.Mail]: MailFeatures;
|
|
48
|
+
[Service.Vpn]: VpnFeatures;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Service = void 0;
|
|
4
|
+
var Service;
|
|
5
|
+
(function (Service) {
|
|
6
|
+
Service["Drive"] = "drive";
|
|
7
|
+
Service["Backups"] = "backups";
|
|
8
|
+
Service["Antivirus"] = "antivirus";
|
|
9
|
+
Service["Meet"] = "meet";
|
|
10
|
+
Service["Mail"] = "mail";
|
|
11
|
+
Service["Vpn"] = "vpn";
|
|
12
|
+
})(Service = exports.Service || (exports.Service = {}));
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -33,3 +33,4 @@ exports.Network = __importStar(require("./network"));
|
|
|
33
33
|
exports.photos = __importStar(require("./photos"));
|
|
34
34
|
exports.Shared = __importStar(require("./shared"));
|
|
35
35
|
exports.Workspaces = __importStar(require("./workspaces"));
|
|
36
|
+
__exportStar(require("./meet"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ApiSecurity, ApiUrl, AppDetails } from '../shared';
|
|
2
|
+
import { CreateCallResponse, JoinCallPayload, JoinCallResponse, UsersInCallResponse } from './types';
|
|
3
|
+
export declare class Meet {
|
|
4
|
+
private readonly client;
|
|
5
|
+
private readonly appDetails;
|
|
6
|
+
private readonly apiSecurity?;
|
|
7
|
+
private constructor();
|
|
8
|
+
static client(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity?: ApiSecurity): Meet;
|
|
9
|
+
createCall(): Promise<CreateCallResponse>;
|
|
10
|
+
joinCall(callId: string, payload: JoinCallPayload): Promise<JoinCallResponse>;
|
|
11
|
+
leaveCall(callId: string): Promise<void>;
|
|
12
|
+
getCurrentUsersInCall(callId: string): Promise<UsersInCallResponse[]>;
|
|
13
|
+
private headersWithToken;
|
|
14
|
+
private basicHeaders;
|
|
15
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.Meet = void 0;
|
|
51
|
+
var headers_1 = require("../shared/headers");
|
|
52
|
+
var client_1 = require("../shared/http/client");
|
|
53
|
+
var Meet = /** @class */ (function () {
|
|
54
|
+
function Meet(apiUrl, appDetails, apiSecurity) {
|
|
55
|
+
this.client = client_1.HttpClient.create(apiUrl, apiSecurity === null || apiSecurity === void 0 ? void 0 : apiSecurity.unauthorizedCallback);
|
|
56
|
+
this.appDetails = appDetails;
|
|
57
|
+
this.apiSecurity = apiSecurity;
|
|
58
|
+
}
|
|
59
|
+
Meet.client = function (apiUrl, appDetails, apiSecurity) {
|
|
60
|
+
return new Meet(apiUrl, appDetails, apiSecurity);
|
|
61
|
+
};
|
|
62
|
+
Meet.prototype.createCall = function () {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
return [2 /*return*/, this.client.post('call', {}, this.headersWithToken())];
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
Meet.prototype.joinCall = function (callId, payload) {
|
|
70
|
+
var _a;
|
|
71
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
+
var headers;
|
|
73
|
+
return __generator(this, function (_b) {
|
|
74
|
+
headers = ((_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token) ? this.headersWithToken() : this.basicHeaders();
|
|
75
|
+
return [2 /*return*/, this.client.post("call/".concat(callId, "/users/join"), __assign({}, payload), headers)];
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
Meet.prototype.leaveCall = function (callId) {
|
|
80
|
+
var _a;
|
|
81
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
82
|
+
var headers;
|
|
83
|
+
return __generator(this, function (_b) {
|
|
84
|
+
headers = ((_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token) ? this.headersWithToken() : this.basicHeaders();
|
|
85
|
+
return [2 /*return*/, this.client.post("call/".concat(callId, "/users/leave"), {}, headers)];
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
Meet.prototype.getCurrentUsersInCall = function (callId) {
|
|
90
|
+
var _a;
|
|
91
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
+
var headers;
|
|
93
|
+
return __generator(this, function (_b) {
|
|
94
|
+
headers = ((_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token) ? this.headersWithToken() : this.basicHeaders();
|
|
95
|
+
return [2 /*return*/, this.client.get("call/".concat(callId, "/users"), headers)];
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
Meet.prototype.headersWithToken = function () {
|
|
100
|
+
var _a;
|
|
101
|
+
if (!((_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token)) {
|
|
102
|
+
throw new Error('Token is required for Meet operations');
|
|
103
|
+
}
|
|
104
|
+
return (0, headers_1.headersWithToken)(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token);
|
|
105
|
+
};
|
|
106
|
+
Meet.prototype.basicHeaders = function () {
|
|
107
|
+
return (0, headers_1.basicHeaders)(this.appDetails.clientName, this.appDetails.clientVersion);
|
|
108
|
+
};
|
|
109
|
+
return Meet;
|
|
110
|
+
}());
|
|
111
|
+
exports.Meet = Meet;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var sinon_1 = __importDefault(require("sinon"));
|
|
43
|
+
var headers_1 = require("../shared/headers");
|
|
44
|
+
var client_1 = require("../shared/http/client");
|
|
45
|
+
var index_1 = require("./index");
|
|
46
|
+
var httpClient = client_1.HttpClient.create('');
|
|
47
|
+
describe('Meet service tests', function () {
|
|
48
|
+
beforeEach(function () {
|
|
49
|
+
sinon_1.default.stub(client_1.HttpClient, 'create').returns(httpClient);
|
|
50
|
+
});
|
|
51
|
+
afterEach(function () {
|
|
52
|
+
sinon_1.default.restore();
|
|
53
|
+
});
|
|
54
|
+
describe('createCall method', function () {
|
|
55
|
+
it('should successfully create a call with token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var expectedResponse, _a, client, headers, postCall, response;
|
|
57
|
+
return __generator(this, function (_b) {
|
|
58
|
+
switch (_b.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
expectedResponse = {
|
|
61
|
+
token: 'call-token',
|
|
62
|
+
room: 'room-id',
|
|
63
|
+
paxPerCall: 10,
|
|
64
|
+
};
|
|
65
|
+
_a = clientAndHeadersWithToken(), client = _a.client, headers = _a.headers;
|
|
66
|
+
postCall = sinon_1.default.stub(httpClient, 'post').resolves(expectedResponse);
|
|
67
|
+
return [4 /*yield*/, client.createCall()];
|
|
68
|
+
case 1:
|
|
69
|
+
response = _b.sent();
|
|
70
|
+
// Assert
|
|
71
|
+
expect(postCall.firstCall.args).toEqual(['call', {}, headers]);
|
|
72
|
+
expect(response).toEqual(expectedResponse);
|
|
73
|
+
return [2 /*return*/];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}); });
|
|
77
|
+
it('should throw an error when token is missing', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
+
var client;
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
switch (_a.label) {
|
|
81
|
+
case 0:
|
|
82
|
+
client = clientAndHeadersWithoutToken().client;
|
|
83
|
+
// Act & Assert
|
|
84
|
+
return [4 /*yield*/, expect(client.createCall()).rejects.toThrow('Token is required for Meet operations')];
|
|
85
|
+
case 1:
|
|
86
|
+
// Act & Assert
|
|
87
|
+
_a.sent();
|
|
88
|
+
return [2 /*return*/];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}); });
|
|
92
|
+
});
|
|
93
|
+
describe('joinCall method', function () {
|
|
94
|
+
var callId = 'call-123';
|
|
95
|
+
var payload = {
|
|
96
|
+
name: 'John',
|
|
97
|
+
lastname: 'Doe',
|
|
98
|
+
anonymous: false,
|
|
99
|
+
};
|
|
100
|
+
var joinCallResponse = {
|
|
101
|
+
token: 'join-token',
|
|
102
|
+
room: 'room-id',
|
|
103
|
+
userId: 'user-123',
|
|
104
|
+
};
|
|
105
|
+
it('should join a call successfully with token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
|
+
var _a, client, headers, postCall, response;
|
|
107
|
+
return __generator(this, function (_b) {
|
|
108
|
+
switch (_b.label) {
|
|
109
|
+
case 0:
|
|
110
|
+
_a = clientAndHeadersWithToken(), client = _a.client, headers = _a.headers;
|
|
111
|
+
postCall = sinon_1.default.stub(httpClient, 'post').resolves(joinCallResponse);
|
|
112
|
+
return [4 /*yield*/, client.joinCall(callId, payload)];
|
|
113
|
+
case 1:
|
|
114
|
+
response = _b.sent();
|
|
115
|
+
// Assert
|
|
116
|
+
expect(postCall.firstCall.args).toEqual(["call/".concat(callId, "/users/join"), payload, headers]);
|
|
117
|
+
expect(response).toEqual(joinCallResponse);
|
|
118
|
+
return [2 /*return*/];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}); });
|
|
122
|
+
it('should join a call successfully without token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
123
|
+
var _a, client, headers, postCall, response;
|
|
124
|
+
return __generator(this, function (_b) {
|
|
125
|
+
switch (_b.label) {
|
|
126
|
+
case 0:
|
|
127
|
+
_a = clientAndHeadersWithoutToken(), client = _a.client, headers = _a.headers;
|
|
128
|
+
postCall = sinon_1.default.stub(httpClient, 'post').resolves(joinCallResponse);
|
|
129
|
+
return [4 /*yield*/, client.joinCall(callId, payload)];
|
|
130
|
+
case 1:
|
|
131
|
+
response = _b.sent();
|
|
132
|
+
// Assert
|
|
133
|
+
expect(postCall.firstCall.args[0]).toEqual("call/".concat(callId, "/users/join"));
|
|
134
|
+
expect(postCall.firstCall.args[1]).toEqual(payload);
|
|
135
|
+
expect(postCall.firstCall.args[2]).toEqual(headers);
|
|
136
|
+
expect(response).toEqual(joinCallResponse);
|
|
137
|
+
return [2 /*return*/];
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}); });
|
|
141
|
+
});
|
|
142
|
+
describe('getCurrentUsersInCall method', function () {
|
|
143
|
+
var callId = 'call-123';
|
|
144
|
+
var usersInCallResponse = [
|
|
145
|
+
{
|
|
146
|
+
userId: 'user-123',
|
|
147
|
+
name: 'John',
|
|
148
|
+
lastname: 'Doe',
|
|
149
|
+
anonymous: false,
|
|
150
|
+
avatar: 'avatar-url-1',
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
userId: 'user-456',
|
|
154
|
+
name: 'Jane',
|
|
155
|
+
lastname: 'Smith',
|
|
156
|
+
anonymous: true,
|
|
157
|
+
avatar: 'avatar-url-2',
|
|
158
|
+
},
|
|
159
|
+
];
|
|
160
|
+
it('should get current users in call successfully with token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
161
|
+
var _a, client, headers, getCall, response;
|
|
162
|
+
return __generator(this, function (_b) {
|
|
163
|
+
switch (_b.label) {
|
|
164
|
+
case 0:
|
|
165
|
+
_a = clientAndHeadersWithToken(), client = _a.client, headers = _a.headers;
|
|
166
|
+
getCall = sinon_1.default.stub(httpClient, 'get').resolves(usersInCallResponse);
|
|
167
|
+
return [4 /*yield*/, client.getCurrentUsersInCall(callId)];
|
|
168
|
+
case 1:
|
|
169
|
+
response = _b.sent();
|
|
170
|
+
// Assert
|
|
171
|
+
expect(getCall.firstCall.args).toEqual(["call/".concat(callId, "/users"), headers]);
|
|
172
|
+
expect(response).toEqual(usersInCallResponse);
|
|
173
|
+
return [2 /*return*/];
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}); });
|
|
177
|
+
it('should get current users in call successfully without token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
178
|
+
var _a, client, headers, getCall, response;
|
|
179
|
+
return __generator(this, function (_b) {
|
|
180
|
+
switch (_b.label) {
|
|
181
|
+
case 0:
|
|
182
|
+
_a = clientAndHeadersWithoutToken(), client = _a.client, headers = _a.headers;
|
|
183
|
+
getCall = sinon_1.default.stub(httpClient, 'get').resolves(usersInCallResponse);
|
|
184
|
+
return [4 /*yield*/, client.getCurrentUsersInCall(callId)];
|
|
185
|
+
case 1:
|
|
186
|
+
response = _b.sent();
|
|
187
|
+
// Assert
|
|
188
|
+
expect(getCall.firstCall.args[0]).toEqual("call/".concat(callId, "/users"));
|
|
189
|
+
expect(getCall.firstCall.args[1]).toEqual(headers);
|
|
190
|
+
expect(response).toEqual(usersInCallResponse);
|
|
191
|
+
return [2 /*return*/];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}); });
|
|
195
|
+
});
|
|
196
|
+
describe('leaveCall method', function () {
|
|
197
|
+
var callId = 'call-123';
|
|
198
|
+
it('should leave a call successfully with token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
199
|
+
var _a, client, headers, postCall;
|
|
200
|
+
return __generator(this, function (_b) {
|
|
201
|
+
switch (_b.label) {
|
|
202
|
+
case 0:
|
|
203
|
+
_a = clientAndHeadersWithToken(), client = _a.client, headers = _a.headers;
|
|
204
|
+
postCall = sinon_1.default.stub(httpClient, 'post').resolves();
|
|
205
|
+
// Act
|
|
206
|
+
return [4 /*yield*/, client.leaveCall(callId)];
|
|
207
|
+
case 1:
|
|
208
|
+
// Act
|
|
209
|
+
_b.sent();
|
|
210
|
+
// Assert
|
|
211
|
+
expect(postCall.firstCall.args).toEqual(["call/".concat(callId, "/users/leave"), {}, headers]);
|
|
212
|
+
return [2 /*return*/];
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}); });
|
|
216
|
+
it('should leave a call successfully without token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
217
|
+
var _a, client, headers, postCall;
|
|
218
|
+
return __generator(this, function (_b) {
|
|
219
|
+
switch (_b.label) {
|
|
220
|
+
case 0:
|
|
221
|
+
_a = clientAndHeadersWithoutToken(), client = _a.client, headers = _a.headers;
|
|
222
|
+
postCall = sinon_1.default.stub(httpClient, 'post').resolves();
|
|
223
|
+
// Act
|
|
224
|
+
return [4 /*yield*/, client.leaveCall(callId)];
|
|
225
|
+
case 1:
|
|
226
|
+
// Act
|
|
227
|
+
_b.sent();
|
|
228
|
+
// Assert
|
|
229
|
+
expect(postCall.firstCall.args[0]).toEqual("call/".concat(callId, "/users/leave"));
|
|
230
|
+
expect(postCall.firstCall.args[1]).toEqual({});
|
|
231
|
+
expect(postCall.firstCall.args[2]).toEqual(headers);
|
|
232
|
+
return [2 /*return*/];
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}); });
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
function clientAndHeadersWithToken(apiUrl, clientName, clientVersion, token) {
|
|
239
|
+
if (apiUrl === void 0) { apiUrl = ''; }
|
|
240
|
+
if (clientName === void 0) { clientName = 'c-name'; }
|
|
241
|
+
if (clientVersion === void 0) { clientVersion = '0.1'; }
|
|
242
|
+
if (token === void 0) { token = 'my-token'; }
|
|
243
|
+
var appDetails = {
|
|
244
|
+
clientName: clientName,
|
|
245
|
+
clientVersion: clientVersion,
|
|
246
|
+
};
|
|
247
|
+
var apiSecurity = {
|
|
248
|
+
token: token,
|
|
249
|
+
};
|
|
250
|
+
var client = index_1.Meet.client(apiUrl, appDetails, apiSecurity);
|
|
251
|
+
var headers = (0, headers_1.headersWithToken)(clientName, clientVersion, token);
|
|
252
|
+
return { client: client, headers: headers };
|
|
253
|
+
}
|
|
254
|
+
function clientAndHeadersWithoutToken(apiUrl, clientName, clientVersion) {
|
|
255
|
+
if (apiUrl === void 0) { apiUrl = ''; }
|
|
256
|
+
if (clientName === void 0) { clientName = 'c-name'; }
|
|
257
|
+
if (clientVersion === void 0) { clientVersion = '0.1'; }
|
|
258
|
+
var appDetails = {
|
|
259
|
+
clientName: clientName,
|
|
260
|
+
clientVersion: clientVersion,
|
|
261
|
+
};
|
|
262
|
+
var client = index_1.Meet.client(apiUrl, appDetails);
|
|
263
|
+
var headers = (0, headers_1.basicHeaders)(clientName, clientVersion);
|
|
264
|
+
return { client: client, headers: headers };
|
|
265
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface CreateCallResponse {
|
|
2
|
+
token: string;
|
|
3
|
+
room: string;
|
|
4
|
+
paxPerCall: number;
|
|
5
|
+
}
|
|
6
|
+
export interface JoinCallPayload {
|
|
7
|
+
name: string;
|
|
8
|
+
lastname: string;
|
|
9
|
+
anonymous: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface JoinCallResponse {
|
|
12
|
+
token: string;
|
|
13
|
+
room: string;
|
|
14
|
+
userId: string;
|
|
15
|
+
}
|
|
16
|
+
export interface UsersInCallResponse {
|
|
17
|
+
userId: string;
|
|
18
|
+
name: string;
|
|
19
|
+
lastname: string;
|
|
20
|
+
anonymous: boolean;
|
|
21
|
+
avatar: string;
|
|
22
|
+
}
|
package/package.json
CHANGED
|
File without changes
|