@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.
Files changed (42) hide show
  1. package/dist/auth/index.js +180 -262
  2. package/dist/auth/types.js +2 -22
  3. package/dist/drive/backups/index.js +34 -32
  4. package/dist/drive/payments/index.d.ts +2 -32
  5. package/dist/drive/payments/index.js +75 -179
  6. package/dist/drive/payments/object-storage.js +34 -36
  7. package/dist/drive/payments/types/types.d.ts +6 -0
  8. package/dist/drive/referrals/index.js +19 -17
  9. package/dist/drive/share/index.js +168 -235
  10. package/dist/drive/storage/index.js +213 -302
  11. package/dist/drive/trash/index.js +40 -84
  12. package/dist/drive/users/index.js +95 -140
  13. package/dist/mail/index.d.ts +124 -2
  14. package/dist/mail/index.js +170 -16
  15. package/dist/mail/types.d.ts +50 -0
  16. package/dist/mail/types.js +6 -0
  17. package/dist/meet/index.js +31 -99
  18. package/dist/misc/location/index.js +10 -50
  19. package/dist/network/download.js +38 -107
  20. package/dist/network/errors/codes.js +8 -24
  21. package/dist/network/errors/context.js +9 -26
  22. package/dist/network/errors/download.js +6 -24
  23. package/dist/network/errors/upload.js +21 -48
  24. package/dist/network/index.js +120 -277
  25. package/dist/network/types.js +3 -4
  26. package/dist/network/upload.js +63 -133
  27. package/dist/payments/checkout.d.ts +1 -1
  28. package/dist/payments/checkout.js +56 -69
  29. package/dist/payments/types/index.d.ts +0 -3
  30. package/dist/send/send.js +17 -27
  31. package/dist/shared/headers/index.js +56 -42
  32. package/dist/shared/http/client.js +95 -207
  33. package/dist/shared/http/retryWithBackoff.js +36 -110
  34. package/dist/shared/types/errors.js +37 -51
  35. package/dist/workspaces/index.js +224 -264
  36. package/package.json +14 -15
  37. package/dist/mail/api.d.ts +0 -126
  38. package/dist/mail/api.js +0 -288
  39. package/dist/mail/crypto.d.ts +0 -66
  40. package/dist/mail/crypto.js +0 -156
  41. package/dist/mail/mail.d.ts +0 -162
  42. package/dist/mail/mail.js +0 -382
@@ -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
- var UserAccessError = /** @class */ (function (_super) {
20
- __extends(UserAccessError, _super);
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
- var client_1 = require("../../shared/http/client");
5
- var headers_1 = require("../../shared/headers");
6
- var Backups = /** @class */ (function () {
7
- function Backups(apiUrl, appDetails, apiSecurity) {
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
- Backups.prototype.getAllDevices = function () {
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
- Backups.prototype.getBackupDevices = function () {
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
- Backups.prototype.getAllDevicesAsFolder = function () {
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
- Backups.prototype.getAllBackups = function (mac) {
49
- return this.client.get("/backup/".concat(mac), this.headers());
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
- Backups.prototype.deleteBackup = function (backupId) {
58
- return this.client.delete("/backup/".concat(backupId), this.headers());
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
- Backups.prototype.deleteDevice = function (deviceId) {
65
- return this.client.delete("/backup/device/".concat(deviceId), this.headers());
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
- Backups.prototype.deleteBackupDevice = function (deviceId) {
74
- return this.client.delete("/backup/devices/".concat(deviceId), this.headers());
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
- Backups.prototype.deleteBackupDeviceAsFolder = function (folderId) {
83
- return this.client.delete("/backup/deviceAsFolder/".concat(folderId), this.headers());
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
- Backups.prototype.headers = function () {
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
- return Backups;
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, CreateCheckoutSessionPayload, CreatedSubscriptionData, CreatePaymentSessionPayload, CustomerBillingInfo, DisplayPrice, FreeTrialAvailable, Invoice, InvoicePayload, PaymentMethod, ProductData, RedeemCodePayload, UpdateSubscriptionPaymentMethod, UserSubscription, UserType } from './types/types';
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
- var headers_1 = require("../../shared/headers");
52
- var client_1 = require("../../shared/http/client");
53
- var types_1 = require("./types/types");
54
- var Payments = /** @class */ (function () {
55
- function Payments(apiUrl, appDetails, apiSecurity) {
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
- Payments.client = function (apiUrl, appDetails, apiSecurity) {
61
- return new Payments(apiUrl, appDetails, apiSecurity);
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("/setup-intent?".concat(query.toString()), this.headers());
113
- };
114
- Payments.prototype.getDefaultPaymentMethod = function (userType) {
115
- var query = new URLSearchParams();
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("/default-payment-method?".concat(query.toString()), this.headers());
119
- };
120
- Payments.prototype.getInvoices = function (_a) {
121
- var subscriptionId = _a.subscriptionId, _b = _a.userType, userType = _b === void 0 ? types_1.UserType.Individual : _b, startingAfter = _a.startingAfter, limit = _a.limit;
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("/invoices?".concat(query.toString()), this.headers());
132
- };
133
- Payments.prototype.isCouponUsedByUser = function (_a) {
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
- Payments.prototype.getUserSubscription = function (userType) {
144
- var query = new URLSearchParams();
45
+ }
46
+ getUserSubscription(userType) {
47
+ const query = new URLSearchParams();
145
48
  if (userType)
146
49
  query.set('userType', userType);
147
- return this.client.get("/subscriptions?".concat(query.toString()), this.headers()).catch(function (err) {
148
- var error = err;
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
- Payments.prototype.getPrices = function (currency, userType) {
156
- return __awaiter(this, void 0, void 0, function () {
157
- var query;
158
- return __generator(this, function (_a) {
159
- query = new URLSearchParams();
160
- if (currency !== undefined)
161
- query.set('currency', currency);
162
- if (userType)
163
- query.set('userType', userType);
164
- return [2 /*return*/, this.client.get("/prices?".concat(query.toString()), this.headers())];
165
- });
166
- });
167
- };
168
- Payments.prototype.requestPreventCancellation = function () {
169
- return this.client.get('/request-prevent-cancellation', this.headers());
170
- };
171
- Payments.prototype.preventCancellation = function () {
172
- return this.client.put('/prevent-cancellation', {}, this.headers());
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
- Payments.prototype.updateSubscriptionPaymentMethod = function (payload) {
178
- return this.client.post('/subscriptions/update-payment-method', __assign({}, payload), this.headers());
179
- };
180
- Payments.prototype.updateSubscriptionPrice = function (_a) {
181
- var priceId = _a.priceId, couponCode = _a.couponCode, userType = _a.userType;
182
- return this.client.put('/subscriptions', { price_id: priceId, couponCode: couponCode, userType: userType }, this.headers());
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: workspaceId,
187
- subscriptionId: subscriptionId,
86
+ workspaceId,
87
+ subscriptionId,
188
88
  workspaceUpdatedSeats: updatedSeats,
189
89
  }, this.headers());
190
- };
191
- Payments.prototype.cancelSubscription = function (userType) {
192
- var query = new URLSearchParams();
90
+ }
91
+ cancelSubscription(userType) {
92
+ const query = new URLSearchParams();
193
93
  if (userType)
194
94
  query.set('userType', userType);
195
- return this.client.delete("/subscriptions?".concat(query.toString()), this.headers());
196
- };
197
- Payments.prototype.createCheckoutSession = function (payload) {
198
- return this.client.post('/checkout-session', __assign({}, payload), this.headers());
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
- Payments.prototype.checkUserAvailableProducts = function () {
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
- Payments.prototype.getUserTier = function (userType) {
227
- var query = new URLSearchParams();
123
+ getUserTier(userType) {
124
+ const query = new URLSearchParams();
228
125
  if (userType !== undefined)
229
126
  query.set('tierType', userType);
230
- return this.client.get("/products/tier?".concat(query.toString()), this.headers());
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
- Payments.prototype.headers = function () {
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
- return Payments;
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
- var headers_1 = require("../../shared/headers");
5
- var client_1 = require("../../shared/http/client");
6
- var ObjectStorage = /** @class */ (function () {
7
- function ObjectStorage(apiUrl, appDetails) {
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
- ObjectStorage.client = function (apiUrl, appDetails) {
12
- return new ObjectStorage(apiUrl, appDetails);
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("/object-storage/price?".concat(query.toString()), this.headers());
21
- };
22
- ObjectStorage.prototype.getObjectStorageCustomerId = function (_a) {
23
- var customerName = _a.customerName, email = _a.email, country = _a.country, postalCode = _a.postalCode, companyVatId = _a.companyVatId;
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("/object-storage/customer?".concat(query.toString()), this.headers());
33
- };
34
- ObjectStorage.prototype.createObjectStorageSubscription = function (_a) {
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: customerId,
38
- priceId: priceId,
39
- currency: currency,
40
- token: token,
41
- promoCodeId: promoCodeId,
37
+ customerId,
38
+ priceId,
39
+ currency,
40
+ token,
41
+ promoCodeId,
42
42
  }, this.headers());
43
- };
44
- ObjectStorage.prototype.paymentMethodVerification = function (_a) {
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: customerId,
48
- token: token,
49
- currency: currency,
50
- priceId: priceId,
51
- paymentMethod: paymentMethod,
46
+ customerId,
47
+ token,
48
+ currency,
49
+ priceId,
50
+ paymentMethod,
52
51
  }, this.headers());
53
- };
54
- ObjectStorage.prototype.headers = function () {
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
- return ObjectStorage;
63
- }());
60
+ }
61
+ }
64
62
  exports.ObjectStorage = ObjectStorage;
@@ -200,3 +200,9 @@ export type AvailableProducts = {
200
200
  backups: boolean;
201
201
  };
202
202
  };
203
+ export interface CouponCodeData {
204
+ codeId: string;
205
+ codeName: string;
206
+ amountOff?: number;
207
+ percentOff?: number;
208
+ }