@internxt/sdk 1.15.14 → 1.16.1
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/auth/index.js +180 -262
- package/dist/auth/types.js +2 -22
- package/dist/drive/backups/index.js +34 -32
- package/dist/drive/payments/index.d.ts +2 -32
- package/dist/drive/payments/index.js +75 -179
- package/dist/drive/payments/object-storage.js +34 -36
- package/dist/drive/payments/types/types.d.ts +6 -0
- package/dist/drive/referrals/index.js +19 -17
- package/dist/drive/share/index.js +168 -235
- package/dist/drive/storage/index.js +213 -302
- package/dist/drive/trash/index.js +40 -84
- package/dist/drive/users/index.js +95 -140
- package/dist/mail/index.d.ts +124 -2
- package/dist/mail/index.js +170 -16
- package/dist/mail/types.d.ts +50 -0
- package/dist/mail/types.js +6 -0
- package/dist/meet/index.js +31 -99
- package/dist/misc/location/index.js +10 -50
- package/dist/network/download.js +38 -107
- package/dist/network/errors/codes.js +8 -24
- package/dist/network/errors/context.js +9 -26
- package/dist/network/errors/download.js +6 -24
- package/dist/network/errors/upload.js +21 -48
- package/dist/network/index.js +120 -277
- package/dist/network/types.js +3 -4
- package/dist/network/upload.js +63 -133
- package/dist/payments/checkout.d.ts +1 -1
- package/dist/payments/checkout.js +56 -69
- package/dist/payments/types/index.d.ts +0 -3
- package/dist/send/send.js +17 -27
- package/dist/shared/headers/index.js +56 -42
- package/dist/shared/http/client.js +95 -207
- package/dist/shared/http/retryWithBackoff.js +36 -110
- package/dist/shared/types/errors.js +37 -51
- package/dist/workspaces/index.js +224 -264
- package/package.json +14 -15
- package/dist/mail/api.d.ts +0 -126
- package/dist/mail/api.js +0 -288
- package/dist/mail/crypto.d.ts +0 -66
- package/dist/mail/crypto.js +0 -156
- package/dist/mail/mail.d.ts +0 -162
- package/dist/mail/mail.js +0 -382
package/dist/auth/types.js
CHANGED
|
@@ -1,26 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.UserAccessError = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function UserAccessError() {
|
|
22
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
-
}
|
|
24
|
-
return UserAccessError;
|
|
25
|
-
}(Error));
|
|
4
|
+
class UserAccessError extends Error {
|
|
5
|
+
}
|
|
26
6
|
exports.UserAccessError = UserAccessError;
|
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Backups = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const client_1 = require("../../shared/http/client");
|
|
5
|
+
const headers_1 = require("../../shared/headers");
|
|
6
|
+
class Backups {
|
|
7
|
+
client;
|
|
8
|
+
appDetails;
|
|
9
|
+
apiSecurity;
|
|
10
|
+
static client(apiUrl, appDetails, apiSecurity) {
|
|
11
|
+
return new Backups(apiUrl, appDetails, apiSecurity);
|
|
12
|
+
}
|
|
13
|
+
constructor(apiUrl, appDetails, apiSecurity) {
|
|
8
14
|
this.client = client_1.HttpClient.create(apiUrl, apiSecurity.unauthorizedCallback, apiSecurity.retryOptions);
|
|
9
15
|
this.appDetails = appDetails;
|
|
10
16
|
this.apiSecurity = apiSecurity;
|
|
11
17
|
}
|
|
12
|
-
Backups.client = function (apiUrl, appDetails, apiSecurity) {
|
|
13
|
-
return new Backups(apiUrl, appDetails, apiSecurity);
|
|
14
|
-
};
|
|
15
18
|
/**
|
|
16
19
|
* @deprecated Use `getBackupDevices` instead.
|
|
17
20
|
* This method uses the old drive backend, while `getBackupDevices` uses the new drive backend.
|
|
18
21
|
*/
|
|
19
|
-
|
|
22
|
+
getAllDevices() {
|
|
20
23
|
return this.client.get('/backup/device', this.headers());
|
|
21
|
-
}
|
|
24
|
+
}
|
|
22
25
|
/**
|
|
23
26
|
* Retrieves the list of backup devices associated with the user's account.
|
|
24
27
|
*
|
|
25
28
|
* @returns {Promise<Device[]>} A promise that resolves to an array of Devices.
|
|
26
29
|
*/
|
|
27
|
-
|
|
30
|
+
getBackupDevices() {
|
|
28
31
|
return this.client.get('/backup/devices', this.headers());
|
|
29
|
-
}
|
|
32
|
+
}
|
|
30
33
|
/**
|
|
31
34
|
* Retrieves a list of all devices represented as folders.
|
|
32
35
|
*
|
|
@@ -36,57 +39,57 @@ var Backups = /** @class */ (function () {
|
|
|
36
39
|
*
|
|
37
40
|
* @returns {Promise<DriveFolderData[]>} A promise that resolves to an array of DriveFolderData.
|
|
38
41
|
*/
|
|
39
|
-
|
|
42
|
+
getAllDevicesAsFolder() {
|
|
40
43
|
return this.client.get('/backup/deviceAsFolder', this.headers());
|
|
41
|
-
}
|
|
44
|
+
}
|
|
42
45
|
/**
|
|
43
46
|
* Retrieves all backups associated with a specific device identified by its mac ID.
|
|
44
47
|
*
|
|
45
48
|
* @param mac - The mac ID of the device for which backups are to be retrieved.
|
|
46
49
|
* @returns A promise that resolves to an array of DeviceBackups.
|
|
47
50
|
*/
|
|
48
|
-
|
|
49
|
-
return this.client.get(
|
|
50
|
-
}
|
|
51
|
+
getAllBackups(mac) {
|
|
52
|
+
return this.client.get(`/backup/${mac}`, this.headers());
|
|
53
|
+
}
|
|
51
54
|
/**
|
|
52
55
|
* Deletes a backup by its ID.
|
|
53
56
|
*
|
|
54
57
|
* @param backupId - The unique identifier of the backup to be deleted.
|
|
55
58
|
* @returns A promise that resolves when the backup is successfully deleted.
|
|
56
59
|
*/
|
|
57
|
-
|
|
58
|
-
return this.client.delete(
|
|
59
|
-
}
|
|
60
|
+
deleteBackup(backupId) {
|
|
61
|
+
return this.client.delete(`/backup/${backupId}`, this.headers());
|
|
62
|
+
}
|
|
60
63
|
/**
|
|
61
64
|
* @deprecated Use `deleteBackupDevice` instead.
|
|
62
65
|
* This method uses the old drive backend, while `deleteBackupDevice` uses the new drive backend.
|
|
63
66
|
*/
|
|
64
|
-
|
|
65
|
-
return this.client.delete(
|
|
66
|
-
}
|
|
67
|
+
deleteDevice(deviceId) {
|
|
68
|
+
return this.client.delete(`/backup/device/${deviceId}`, this.headers());
|
|
69
|
+
}
|
|
67
70
|
/**
|
|
68
71
|
* Deletes a backup device by its ID.
|
|
69
72
|
*
|
|
70
73
|
* @param deviceId - The unique identifier of the device to be deleted.
|
|
71
74
|
* @returns A promise that resolves when the device is successfully deleted.
|
|
72
75
|
*/
|
|
73
|
-
|
|
74
|
-
return this.client.delete(
|
|
75
|
-
}
|
|
76
|
+
deleteBackupDevice(deviceId) {
|
|
77
|
+
return this.client.delete(`/backup/devices/${deviceId}`, this.headers());
|
|
78
|
+
}
|
|
76
79
|
/**
|
|
77
80
|
* Deletes a backup device by its folder ID.
|
|
78
81
|
*
|
|
79
82
|
* @param folderId - The unique identifier of the folder to be deleted.
|
|
80
83
|
* @returns A promise that resolves when the device is successfully deleted.
|
|
81
84
|
*/
|
|
82
|
-
|
|
83
|
-
return this.client.delete(
|
|
84
|
-
}
|
|
85
|
+
deleteBackupDeviceAsFolder(folderId) {
|
|
86
|
+
return this.client.delete(`/backup/deviceAsFolder/${folderId}`, this.headers());
|
|
87
|
+
}
|
|
85
88
|
/**
|
|
86
89
|
* Returns the needed headers for the module requests
|
|
87
90
|
* @private
|
|
88
91
|
*/
|
|
89
|
-
|
|
92
|
+
headers() {
|
|
90
93
|
return (0, headers_1.headersWithToken)({
|
|
91
94
|
clientName: this.appDetails.clientName,
|
|
92
95
|
clientVersion: this.appDetails.clientVersion,
|
|
@@ -95,7 +98,6 @@ var Backups = /** @class */ (function () {
|
|
|
95
98
|
desktopToken: this.appDetails.desktopHeader,
|
|
96
99
|
customHeaders: this.appDetails.customHeaders,
|
|
97
100
|
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
}());
|
|
101
|
+
}
|
|
102
|
+
}
|
|
101
103
|
exports.Backups = Backups;
|
|
@@ -1,50 +1,23 @@
|
|
|
1
1
|
import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
|
|
2
2
|
import { Tier } from './types/tiers';
|
|
3
|
-
import { AvailableProducts,
|
|
3
|
+
import { AvailableProducts, CouponCodeData, CustomerBillingInfo, DisplayPrice, Invoice, InvoicePayload, PaymentMethod, RedeemCodePayload, UpdateSubscriptionPaymentMethod, UserSubscription, UserType } from './types/types';
|
|
4
4
|
export declare class Payments {
|
|
5
5
|
private readonly client;
|
|
6
6
|
private readonly appDetails;
|
|
7
7
|
private readonly apiSecurity;
|
|
8
8
|
static client(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity: ApiSecurity): Payments;
|
|
9
9
|
private constructor();
|
|
10
|
-
createCustomer(name: string, email: string, country?: string, companyVatId?: string): Promise<{
|
|
11
|
-
customerId: string;
|
|
12
|
-
token: string;
|
|
13
|
-
}>;
|
|
14
|
-
createSubscription(customerId: string, priceId: string, token: string, quantity: number, currency?: string, promoCodeId?: string): Promise<CreatedSubscriptionData>;
|
|
15
|
-
createPaymentIntent(customerId: string, amount: number, planId: string, token: string, currency?: string, promoCodeName?: string): Promise<{
|
|
16
|
-
clientSecret: string;
|
|
17
|
-
id: string;
|
|
18
|
-
invoiceStatus?: string;
|
|
19
|
-
}>;
|
|
20
|
-
/**
|
|
21
|
-
* Fetches the existing products and its details
|
|
22
|
-
*/
|
|
23
|
-
getProducts(): Promise<ProductData[]>;
|
|
24
|
-
/**
|
|
25
|
-
* Creates and returns a new session identifier for the client to go to payment platform
|
|
26
|
-
* @param payload
|
|
27
|
-
*/
|
|
28
|
-
createSession(payload: CreatePaymentSessionPayload): Promise<{
|
|
29
|
-
id: string;
|
|
30
|
-
}>;
|
|
31
10
|
getSetupIntent(userType?: UserType): Promise<{
|
|
32
11
|
clientSecret: string;
|
|
33
12
|
}>;
|
|
34
13
|
getDefaultPaymentMethod(userType?: UserType): Promise<PaymentMethod>;
|
|
35
14
|
getInvoices({ subscriptionId, userType, startingAfter, limit, }: InvoicePayload): Promise<Invoice[]>;
|
|
36
|
-
isCouponUsedByUser({ couponCode }: {
|
|
37
|
-
couponCode: string;
|
|
38
|
-
}): Promise<{
|
|
39
|
-
couponUsed: boolean;
|
|
40
|
-
}>;
|
|
41
15
|
getPromoCodesUsedByUser(): Promise<{
|
|
42
16
|
usedCoupons: string[];
|
|
43
17
|
}>;
|
|
44
18
|
getUserSubscription(userType?: UserType): Promise<UserSubscription>;
|
|
19
|
+
fetchPromotionCodeByName(priceId: string, promotionCodeName: string): Promise<CouponCodeData>;
|
|
45
20
|
getPrices(currency?: string, userType?: UserType): Promise<DisplayPrice[]>;
|
|
46
|
-
requestPreventCancellation(): Promise<FreeTrialAvailable>;
|
|
47
|
-
preventCancellation(): Promise<void>;
|
|
48
21
|
applyRedeemCode(payload: RedeemCodePayload): Promise<void>;
|
|
49
22
|
updateSubscriptionPaymentMethod(payload: UpdateSubscriptionPaymentMethod): Promise<void | Error>;
|
|
50
23
|
updateSubscriptionPrice({ priceId, couponCode, userType, }: {
|
|
@@ -58,9 +31,6 @@ export declare class Payments {
|
|
|
58
31
|
}>;
|
|
59
32
|
updateWorkspaceMembers(workspaceId: string, subscriptionId: string, updatedSeats: number): Promise<unknown>;
|
|
60
33
|
cancelSubscription(userType?: UserType): Promise<void>;
|
|
61
|
-
createCheckoutSession(payload: CreateCheckoutSessionPayload): Promise<{
|
|
62
|
-
sessionId: string;
|
|
63
|
-
}>;
|
|
64
34
|
updateCustomerBillingInfo(payload: CustomerBillingInfo): Promise<void>;
|
|
65
35
|
/**
|
|
66
36
|
* Gets the available products from the user
|
|
@@ -1,125 +1,35 @@
|
|
|
1
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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
-
return g.next = verb(0), g["throw"] = verb(1), g["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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
3
|
exports.Payments = void 0;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
4
|
+
const headers_1 = require("../../shared/headers");
|
|
5
|
+
const client_1 = require("../../shared/http/client");
|
|
6
|
+
const types_1 = require("./types/types");
|
|
7
|
+
class Payments {
|
|
8
|
+
client;
|
|
9
|
+
appDetails;
|
|
10
|
+
apiSecurity;
|
|
11
|
+
static client(apiUrl, appDetails, apiSecurity) {
|
|
12
|
+
return new Payments(apiUrl, appDetails, apiSecurity);
|
|
13
|
+
}
|
|
14
|
+
constructor(apiUrl, appDetails, apiSecurity) {
|
|
56
15
|
this.client = client_1.HttpClient.create(apiUrl, apiSecurity.unauthorizedCallback, apiSecurity.retryOptions);
|
|
57
16
|
this.appDetails = appDetails;
|
|
58
17
|
this.apiSecurity = apiSecurity;
|
|
59
18
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
63
|
-
Payments.prototype.createCustomer = function (name, email, country, companyVatId) {
|
|
64
|
-
return this.client.post('/create-customer', { name: name, email: email, country: country, companyVatId: companyVatId }, this.headers());
|
|
65
|
-
};
|
|
66
|
-
Payments.prototype.createSubscription = function (customerId, priceId, token, quantity, currency, promoCodeId) {
|
|
67
|
-
return this.client.post('/create-subscription', {
|
|
68
|
-
customerId: customerId,
|
|
69
|
-
priceId: priceId,
|
|
70
|
-
token: token,
|
|
71
|
-
quantity: quantity,
|
|
72
|
-
currency: currency,
|
|
73
|
-
promoCodeId: promoCodeId,
|
|
74
|
-
}, this.headers());
|
|
75
|
-
};
|
|
76
|
-
Payments.prototype.createPaymentIntent = function (customerId, amount, planId, token, currency, promoCodeName) {
|
|
77
|
-
var query = new URLSearchParams();
|
|
78
|
-
query.set('customerId', customerId);
|
|
79
|
-
query.set('amount', String(amount));
|
|
80
|
-
query.set('planId', planId);
|
|
81
|
-
query.set('token', token);
|
|
82
|
-
if (currency !== undefined)
|
|
83
|
-
query.set('currency', currency);
|
|
84
|
-
if (promoCodeName !== undefined)
|
|
85
|
-
query.set('promoCodeName', promoCodeName);
|
|
86
|
-
return this.client.get("/payment-intent?".concat(query.toString()), this.headers());
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Fetches the existing products and its details
|
|
90
|
-
*/
|
|
91
|
-
Payments.prototype.getProducts = function () {
|
|
92
|
-
return this.client.get('/v3/stripe/products', this.headers());
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Creates and returns a new session identifier for the client to go to payment platform
|
|
96
|
-
* @param payload
|
|
97
|
-
*/
|
|
98
|
-
Payments.prototype.createSession = function (payload) {
|
|
99
|
-
return this.client.post('/v2/stripe/session', {
|
|
100
|
-
test: payload.test,
|
|
101
|
-
lifetime_tier: payload.lifetime_tier,
|
|
102
|
-
mode: payload.mode,
|
|
103
|
-
priceId: payload.priceId,
|
|
104
|
-
successUrl: payload.successUrl,
|
|
105
|
-
canceledUrl: payload.canceledUrl,
|
|
106
|
-
}, this.headers());
|
|
107
|
-
};
|
|
108
|
-
Payments.prototype.getSetupIntent = function (userType) {
|
|
109
|
-
var query = new URLSearchParams();
|
|
19
|
+
getSetupIntent(userType) {
|
|
20
|
+
const query = new URLSearchParams();
|
|
110
21
|
if (userType)
|
|
111
22
|
query.set('userType', userType);
|
|
112
|
-
return this.client.get(
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
23
|
+
return this.client.get(`/setup-intent?${query.toString()}`, this.headers());
|
|
24
|
+
}
|
|
25
|
+
getDefaultPaymentMethod(userType) {
|
|
26
|
+
const query = new URLSearchParams();
|
|
116
27
|
if (userType)
|
|
117
28
|
query.set('userType', userType);
|
|
118
|
-
return this.client.get(
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
var query = new URLSearchParams();
|
|
29
|
+
return this.client.get(`/default-payment-method?${query.toString()}`, this.headers());
|
|
30
|
+
}
|
|
31
|
+
getInvoices({ subscriptionId, userType = types_1.UserType.Individual, startingAfter, limit, }) {
|
|
32
|
+
const query = new URLSearchParams();
|
|
123
33
|
if (subscriptionId !== undefined)
|
|
124
34
|
query.set('subscription', subscriptionId);
|
|
125
35
|
if (startingAfter !== undefined)
|
|
@@ -128,85 +38,72 @@ var Payments = /** @class */ (function () {
|
|
|
128
38
|
query.set('userType', userType);
|
|
129
39
|
if (limit !== undefined)
|
|
130
40
|
query.set('limit', limit.toString());
|
|
131
|
-
return this.client.get(
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
var couponCode = _a.couponCode;
|
|
135
|
-
var query = new URLSearchParams();
|
|
136
|
-
if (couponCode !== undefined)
|
|
137
|
-
query.set('code', couponCode);
|
|
138
|
-
return this.client.get("/coupon-in-use?".concat(query.toString()), this.headers());
|
|
139
|
-
};
|
|
140
|
-
Payments.prototype.getPromoCodesUsedByUser = function () {
|
|
41
|
+
return this.client.get(`/invoices?${query.toString()}`, this.headers());
|
|
42
|
+
}
|
|
43
|
+
getPromoCodesUsedByUser() {
|
|
141
44
|
return this.client.get('/customer/redeemed-promotion-codes', this.headers());
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
45
|
+
}
|
|
46
|
+
getUserSubscription(userType) {
|
|
47
|
+
const query = new URLSearchParams();
|
|
145
48
|
if (userType)
|
|
146
49
|
query.set('userType', userType);
|
|
147
|
-
return this.client.get(
|
|
148
|
-
|
|
50
|
+
return this.client.get(`/subscriptions?${query.toString()}`, this.headers()).catch((err) => {
|
|
51
|
+
const error = err;
|
|
149
52
|
if (error.status === 404)
|
|
150
53
|
return { type: 'free' };
|
|
151
54
|
else
|
|
152
55
|
throw err;
|
|
153
56
|
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
};
|
|
174
|
-
Payments.prototype.applyRedeemCode = function (payload) {
|
|
57
|
+
}
|
|
58
|
+
async fetchPromotionCodeByName(priceId, promotionCodeName) {
|
|
59
|
+
const promotionCode = await this.client.get(`/promo-code-by-name?priceId=${priceId}&promotionCode=${promotionCodeName}`, this.headers());
|
|
60
|
+
return {
|
|
61
|
+
codeId: promotionCode.codeId,
|
|
62
|
+
codeName: promotionCodeName,
|
|
63
|
+
amountOff: promotionCode.amountOff,
|
|
64
|
+
percentOff: promotionCode.percentOff,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
async getPrices(currency, userType) {
|
|
68
|
+
const query = new URLSearchParams();
|
|
69
|
+
if (currency !== undefined)
|
|
70
|
+
query.set('currency', currency);
|
|
71
|
+
if (userType)
|
|
72
|
+
query.set('userType', userType);
|
|
73
|
+
return this.client.get(`/prices?${query.toString()}`, this.headers());
|
|
74
|
+
}
|
|
75
|
+
applyRedeemCode(payload) {
|
|
175
76
|
return this.client.post('/licenses', { code: payload.code, provider: payload.provider }, this.headers());
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return this.client.post('/subscriptions/update-payment-method',
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
Payments.prototype.updateWorkspaceMembers = function (workspaceId, subscriptionId, updatedSeats) {
|
|
77
|
+
}
|
|
78
|
+
updateSubscriptionPaymentMethod(payload) {
|
|
79
|
+
return this.client.post('/subscriptions/update-payment-method', { ...payload }, this.headers());
|
|
80
|
+
}
|
|
81
|
+
updateSubscriptionPrice({ priceId, couponCode, userType, }) {
|
|
82
|
+
return this.client.put('/subscriptions', { price_id: priceId, couponCode: couponCode, userType }, this.headers());
|
|
83
|
+
}
|
|
84
|
+
updateWorkspaceMembers(workspaceId, subscriptionId, updatedSeats) {
|
|
185
85
|
return this.client.patch('/business/subscription', {
|
|
186
|
-
workspaceId
|
|
187
|
-
subscriptionId
|
|
86
|
+
workspaceId,
|
|
87
|
+
subscriptionId,
|
|
188
88
|
workspaceUpdatedSeats: updatedSeats,
|
|
189
89
|
}, this.headers());
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
90
|
+
}
|
|
91
|
+
cancelSubscription(userType) {
|
|
92
|
+
const query = new URLSearchParams();
|
|
193
93
|
if (userType)
|
|
194
94
|
query.set('userType', userType);
|
|
195
|
-
return this.client.delete(
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return this.client.
|
|
199
|
-
}
|
|
200
|
-
Payments.prototype.updateCustomerBillingInfo = function (payload) {
|
|
201
|
-
return this.client.patch('/billing', __assign({}, payload), this.headers());
|
|
202
|
-
};
|
|
95
|
+
return this.client.delete(`/subscriptions?${query.toString()}`, this.headers());
|
|
96
|
+
}
|
|
97
|
+
updateCustomerBillingInfo(payload) {
|
|
98
|
+
return this.client.patch('/billing', { ...payload }, this.headers());
|
|
99
|
+
}
|
|
203
100
|
/**
|
|
204
101
|
* Gets the available products from the user
|
|
205
102
|
* @returns an object containing available products
|
|
206
103
|
*/
|
|
207
|
-
|
|
104
|
+
checkUserAvailableProducts() {
|
|
208
105
|
return this.client.get('/products', this.headers());
|
|
209
|
-
}
|
|
106
|
+
}
|
|
210
107
|
/**
|
|
211
108
|
* Gets product information based on the user's subscription tier.
|
|
212
109
|
*
|
|
@@ -223,17 +120,17 @@ var Payments = /** @class */ (function () {
|
|
|
223
120
|
* // Get products for a business user tier
|
|
224
121
|
* const businessProducts = await getUserTier(UserType.Business);
|
|
225
122
|
*/
|
|
226
|
-
|
|
227
|
-
|
|
123
|
+
getUserTier(userType) {
|
|
124
|
+
const query = new URLSearchParams();
|
|
228
125
|
if (userType !== undefined)
|
|
229
126
|
query.set('tierType', userType);
|
|
230
|
-
return this.client.get(
|
|
231
|
-
}
|
|
127
|
+
return this.client.get(`/products/tier?${query.toString()}`, this.headers());
|
|
128
|
+
}
|
|
232
129
|
/**
|
|
233
130
|
* Returns the needed headers for the module requests
|
|
234
131
|
* @private
|
|
235
132
|
*/
|
|
236
|
-
|
|
133
|
+
headers() {
|
|
237
134
|
return (0, headers_1.headersWithToken)({
|
|
238
135
|
clientName: this.appDetails.clientName,
|
|
239
136
|
clientVersion: this.appDetails.clientVersion,
|
|
@@ -242,7 +139,6 @@ var Payments = /** @class */ (function () {
|
|
|
242
139
|
desktopToken: this.appDetails.desktopHeader,
|
|
243
140
|
customHeaders: this.appDetails.customHeaders,
|
|
244
141
|
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
}());
|
|
142
|
+
}
|
|
143
|
+
}
|
|
248
144
|
exports.Payments = Payments;
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ObjectStorage = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const headers_1 = require("../../shared/headers");
|
|
5
|
+
const client_1 = require("../../shared/http/client");
|
|
6
|
+
class ObjectStorage {
|
|
7
|
+
client;
|
|
8
|
+
appDetails;
|
|
9
|
+
static client(apiUrl, appDetails) {
|
|
10
|
+
return new ObjectStorage(apiUrl, appDetails);
|
|
11
|
+
}
|
|
12
|
+
constructor(apiUrl, appDetails) {
|
|
8
13
|
this.client = client_1.HttpClient.create(apiUrl);
|
|
9
14
|
this.appDetails = appDetails;
|
|
10
15
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
ObjectStorage.prototype.getObjectStoragePlanById = function (priceId, currency) {
|
|
15
|
-
var query = new URLSearchParams();
|
|
16
|
+
getObjectStoragePlanById(priceId, currency) {
|
|
17
|
+
const query = new URLSearchParams();
|
|
16
18
|
query.set('planId', priceId);
|
|
17
19
|
if (currency !== undefined) {
|
|
18
20
|
query.set('currency', currency);
|
|
19
21
|
}
|
|
20
|
-
return this.client.get(
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var query = new URLSearchParams();
|
|
22
|
+
return this.client.get(`/object-storage/price?${query.toString()}`, this.headers());
|
|
23
|
+
}
|
|
24
|
+
getObjectStorageCustomerId({ customerName, email, country, postalCode, companyVatId, }) {
|
|
25
|
+
const query = new URLSearchParams();
|
|
25
26
|
query.set('customerName', customerName);
|
|
26
27
|
query.set('email', email);
|
|
27
28
|
query.set('postalCode', postalCode);
|
|
@@ -29,36 +30,33 @@ var ObjectStorage = /** @class */ (function () {
|
|
|
29
30
|
if (companyVatId !== undefined) {
|
|
30
31
|
query.set('companyVatId', companyVatId);
|
|
31
32
|
}
|
|
32
|
-
return this.client.get(
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
var customerId = _a.customerId, priceId = _a.priceId, currency = _a.currency, token = _a.token, promoCodeId = _a.promoCodeId;
|
|
33
|
+
return this.client.get(`/object-storage/customer?${query.toString()}`, this.headers());
|
|
34
|
+
}
|
|
35
|
+
createObjectStorageSubscription({ customerId, priceId, currency, token, promoCodeId, }) {
|
|
36
36
|
return this.client.post('/object-storage/subscription', {
|
|
37
|
-
customerId
|
|
38
|
-
priceId
|
|
39
|
-
currency
|
|
40
|
-
token
|
|
41
|
-
promoCodeId
|
|
37
|
+
customerId,
|
|
38
|
+
priceId,
|
|
39
|
+
currency,
|
|
40
|
+
token,
|
|
41
|
+
promoCodeId,
|
|
42
42
|
}, this.headers());
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var customerId = _a.customerId, token = _a.token, _b = _a.currency, currency = _b === void 0 ? 'eur' : _b, priceId = _a.priceId, paymentMethod = _a.paymentMethod;
|
|
43
|
+
}
|
|
44
|
+
paymentMethodVerification({ customerId, token, currency = 'eur', priceId, paymentMethod, }) {
|
|
46
45
|
return this.client.post('/payment-method-verification', {
|
|
47
|
-
customerId
|
|
48
|
-
token
|
|
49
|
-
currency
|
|
50
|
-
priceId
|
|
51
|
-
paymentMethod
|
|
46
|
+
customerId,
|
|
47
|
+
token,
|
|
48
|
+
currency,
|
|
49
|
+
priceId,
|
|
50
|
+
paymentMethod,
|
|
52
51
|
}, this.headers());
|
|
53
|
-
}
|
|
54
|
-
|
|
52
|
+
}
|
|
53
|
+
headers() {
|
|
55
54
|
return (0, headers_1.basicHeaders)({
|
|
56
55
|
clientName: this.appDetails.clientName,
|
|
57
56
|
clientVersion: this.appDetails.clientVersion,
|
|
58
57
|
desktopToken: this.appDetails.desktopHeader,
|
|
59
58
|
customHeaders: this.appDetails.customHeaders,
|
|
60
59
|
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
}());
|
|
60
|
+
}
|
|
61
|
+
}
|
|
64
62
|
exports.ObjectStorage = ObjectStorage;
|