@frontegg/rest-api 2.10.59 → 2.10.62
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/CHANGELOG.md +6 -0
- package/dist/es2015/fetch.d.ts +1 -1
- package/dist/es2015/fetch.js +14 -6
- package/dist/es2015/fetch.js.map +1 -1
- package/dist/es2015/interfaces.d.ts +1 -1
- package/dist/es2015/subscriptions/interfaces.d.ts +8 -1
- package/dist/es2015/subscriptions/interfaces.js.map +1 -1
- package/dist/es2015/subscriptions/managedSubscriptions.d.ts +13 -1
- package/dist/es2015/subscriptions/managedSubscriptions.js +28 -1
- package/dist/es2015/subscriptions/managedSubscriptions.js.map +1 -1
- package/dist/fetch.d.ts +1 -1
- package/dist/fetch.js +13 -5
- package/dist/fetch.js.map +1 -1
- package/dist/interfaces.d.ts +1 -1
- package/dist/subscriptions/interfaces.d.ts +8 -1
- package/dist/subscriptions/interfaces.js.map +1 -1
- package/dist/subscriptions/managedSubscriptions.d.ts +13 -1
- package/dist/subscriptions/managedSubscriptions.js +31 -1
- package/dist/subscriptions/managedSubscriptions.js.map +1 -1
- package/dist/umd/index.js +43 -5
- package/package.json +1 -1
- package/src/fetch.ts +15 -8
- package/src/interfaces.ts +1 -1
- package/src/subscriptions/interfaces.ts +19 -5
- package/src/subscriptions/managedSubscriptions.ts +42 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [2.10.62](https://github.com/frontegg/typescript-rest-api/compare/v2.10.61...v2.10.62) (2022-04-19)
|
|
6
|
+
|
|
7
|
+
### [2.10.61](https://github.com/frontegg/typescript-rest-api/compare/v2.10.60...v2.10.61) (2022-02-27)
|
|
8
|
+
|
|
9
|
+
### [2.10.60](https://github.com/frontegg/typescript-rest-api/compare/v2.10.59...v2.10.60) (2022-02-24)
|
|
10
|
+
|
|
5
11
|
### [2.10.59](https://github.com/frontegg/typescript-rest-api/compare/v2.10.58...v2.10.59) (2022-02-24)
|
|
6
12
|
|
|
7
13
|
### [2.10.58](https://github.com/frontegg/typescript-rest-api/compare/v2.10.57...v2.10.58) (2022-02-22)
|
package/dist/es2015/fetch.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ interface RequestOptions {
|
|
|
9
9
|
headers?: Record<string, string>;
|
|
10
10
|
credentials?: RequestCredentials;
|
|
11
11
|
}
|
|
12
|
-
export declare function getBaseUrl(context: ContextOptions): string;
|
|
12
|
+
export declare function getBaseUrl(context: ContextOptions, url: string): string;
|
|
13
13
|
export declare const Get: (url: string, params?: any, opts?: Omit<RequestOptions, "method" | "url"> | undefined) => Promise<any>;
|
|
14
14
|
export declare const Post: (url: string, body?: any, opts?: Omit<RequestOptions, "method" | "url"> | undefined) => Promise<any>;
|
|
15
15
|
export declare const Patch: (url: string, body?: any, opts?: Omit<RequestOptions, "method" | "url"> | undefined) => Promise<any>;
|
package/dist/es2015/fetch.js
CHANGED
|
@@ -8,9 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { ContextHolder } from './ContextHolder';
|
|
11
|
-
import { FronteggApiError } from
|
|
12
|
-
export function getBaseUrl(context) {
|
|
13
|
-
let baseUrl
|
|
11
|
+
import { FronteggApiError } from './error';
|
|
12
|
+
export function getBaseUrl(context, url) {
|
|
13
|
+
let baseUrl;
|
|
14
|
+
if (typeof context.baseUrl === 'function') {
|
|
15
|
+
baseUrl = context.baseUrl(url);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
baseUrl = context.baseUrl;
|
|
19
|
+
}
|
|
14
20
|
const prefix = context.urlPrefix || 'frontegg';
|
|
15
21
|
if (!baseUrl.endsWith('/')) {
|
|
16
22
|
baseUrl += '/';
|
|
@@ -22,7 +28,7 @@ export function getBaseUrl(context) {
|
|
|
22
28
|
}
|
|
23
29
|
function prepareUrl(context, url, params) {
|
|
24
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const baseUrl = getBaseUrl(context);
|
|
31
|
+
const baseUrl = getBaseUrl(context, url);
|
|
26
32
|
const paramsToSend = yield buildQueryParams(context, params);
|
|
27
33
|
let finalUrl = url.startsWith('http') ? url : `${baseUrl}${url}`;
|
|
28
34
|
const hasKeys = Object.keys(paramsToSend).length > 0;
|
|
@@ -99,7 +105,8 @@ const sendRequest = (opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
99
105
|
});
|
|
100
106
|
if (response.status === 302) {
|
|
101
107
|
window.location.href = yield response.text();
|
|
102
|
-
return new Promise(() => {
|
|
108
|
+
return new Promise(() => {
|
|
109
|
+
});
|
|
103
110
|
}
|
|
104
111
|
if (!response.ok) {
|
|
105
112
|
if (response.status === 413) {
|
|
@@ -110,7 +117,8 @@ const sendRequest = (opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
110
117
|
errorMessage = yield response.text();
|
|
111
118
|
errorMessage = JSON.parse(errorMessage);
|
|
112
119
|
}
|
|
113
|
-
catch (e) {
|
|
120
|
+
catch (e) {
|
|
121
|
+
}
|
|
114
122
|
if (errorMessage.errors) {
|
|
115
123
|
errorMessage = errorMessage.errors.join(', ');
|
|
116
124
|
}
|
package/dist/es2015/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/fetch.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAa3C,MAAM,UAAU,UAAU,CAAC,OAAuB;
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/fetch.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,aAAa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A6C,EAAE,EAAE;IACnG,OAAA,WAAW,iBACT,GAAG,EACH,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,kBAAkB,EAC/B,IAAI,IACD,IAAI,EACP,CAAA;EAAA,CAAC;AAEL,MAAM,CAAC,MAAM,KAAK,GAAG,CAAO,GAAW,EAAE,IAAU,EAAE,IAA6C,EAAE,EAAE;IACpG,OAAA,WAAW,iBACT,GAAG,EACH,MAAM,EAAE,OAAO,EACf,WAAW,EAAE,kBAAkB,EAC/B,IAAI,IACD,IAAI,EACP,CAAA;EAAA,CAAC;AAEL,MAAM,CAAC,MAAM,GAAG,GAAG,CAAO,GAAW,EAAE,IAAU,EAAE,IAA6C,EAAE,EAAE;IAClG,OAAA,WAAW,iBACT,GAAG,EACH,MAAM,EAAE,KAAK,EACb,WAAW,EAAE,kBAAkB,EAC/B,IAAI,IACD,IAAI,EACP,CAAA;EAAA,CAAC;AAEL,MAAM,CAAC,MAAM,MAAM,GAAG,CAAO,GAAW,EAAE,IAAU,EAAE,IAA6C,EAAE,EAAE;IACrG,OAAA,WAAW,iBACT,GAAG,EACH,MAAM,EAAE,QAAQ,EAChB,WAAW,EAAE,kBAAkB,EAC/B,IAAI,IACD,IAAI,EACP,CAAA;EAAA,CAAC;AAEL,MAAM,CAAC,MAAM,YAAY,GAAG,CAAO,GAAW,EAAE,IAAU,EAAE,MAAY,EAAE,IAAU,EAAE,EAAE;IACtF,OAAA,WAAW,iBACT,GAAG,EACH,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,kBAAkB,EAC/B,YAAY,EAAE,MAAM,EACpB,IAAI;QACJ,MAAM,IACH,IAAI,EACP,CAAA;EAAA,CAAC"}
|
|
@@ -12,7 +12,7 @@ export interface KeyValuePair {
|
|
|
12
12
|
}
|
|
13
13
|
export declare type LogLevel = 'warn' | 'error';
|
|
14
14
|
export interface ContextOptions {
|
|
15
|
-
baseUrl: string;
|
|
15
|
+
baseUrl: string | ((url: string) => string);
|
|
16
16
|
clientId?: string;
|
|
17
17
|
tokenResolver?: () => Promise<string> | string;
|
|
18
18
|
additionalQueryParamsResolver?: () => Promise<KeyValuePair[]> | KeyValuePair[];
|
|
@@ -22,8 +22,11 @@ export interface ISubscriptionResponse {
|
|
|
22
22
|
currentPeriodEnd: string;
|
|
23
23
|
status: ISubscriptionStatus;
|
|
24
24
|
cancellation: ISubscriptionCancellationResponse | null;
|
|
25
|
-
items: ISubscriptionItemResponse[];
|
|
26
25
|
trialEnd?: string;
|
|
26
|
+
plan: ISubscriptionPlanResponse;
|
|
27
|
+
}
|
|
28
|
+
export interface ISubscriptionPlanResponse {
|
|
29
|
+
slug: string;
|
|
27
30
|
}
|
|
28
31
|
export interface ISubscriptionCancellationResponse {
|
|
29
32
|
policy: ISubscriptionCancellationPolicy;
|
|
@@ -119,3 +122,7 @@ export interface IUpdateSubscriptionRequest {
|
|
|
119
122
|
paymentMethodId: string;
|
|
120
123
|
planId: string;
|
|
121
124
|
}
|
|
125
|
+
export interface IUpdateManagedSubscriptionRequest {
|
|
126
|
+
paymentMethodId: string;
|
|
127
|
+
planId: string;
|
|
128
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/subscriptions/interfaces.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/subscriptions/interfaces.ts"],"names":[],"mappings":"AAOA,cAAc,+BAA+B,CAAC"}
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
import { ISubscriptionResponse } from "./interfaces";
|
|
1
|
+
import { ISubscriptionResponse, IUpdateManagedSubscriptionRequest } from "./interfaces";
|
|
2
2
|
export declare function getManagedSubscription(subscriptionId: string): Promise<ISubscriptionResponse>;
|
|
3
3
|
export declare function getManagedSubscriptions(): Promise<ISubscriptionResponse[]>;
|
|
4
|
+
/**
|
|
5
|
+
* Cancel tenant subscription
|
|
6
|
+
*/
|
|
7
|
+
export declare function cancelManagedSubscription(subscriptionId: string): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Renew tenant subscription
|
|
10
|
+
*/
|
|
11
|
+
export declare function renewManagedSubscription(subscriptionId: string): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Upgrade/Downgrade tenant subscription plan
|
|
14
|
+
*/
|
|
15
|
+
export declare function updateManagedSubscription(subscriptionId: string, { paymentMethodId, planId }: IUpdateManagedSubscriptionRequest): Promise<void>;
|
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { Get } from "../fetch";
|
|
10
|
+
import { Get, Put } from "../fetch";
|
|
11
11
|
import { urls } from "../constants";
|
|
12
12
|
export function getManagedSubscription(subscriptionId) {
|
|
13
13
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -21,4 +21,31 @@ export function getManagedSubscriptions() {
|
|
|
21
21
|
return Get(`${urls.subscriptions.managedSubscriptions.v1}`);
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Cancel tenant subscription
|
|
26
|
+
*/
|
|
27
|
+
export function cancelManagedSubscription(subscriptionId) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
console.debug("cancelManagedSubscription()", { subscriptionId });
|
|
30
|
+
return Put(`${urls.subscriptions.managedSubscriptions.v1}/${subscriptionId}/cancellations/`, {});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Renew tenant subscription
|
|
35
|
+
*/
|
|
36
|
+
export function renewManagedSubscription(subscriptionId) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
console.debug("renewManagedSubscription()", { subscriptionId });
|
|
39
|
+
return Put(`${urls.subscriptions.managedSubscriptions.v1}/${subscriptionId}/renewals/`, {});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Upgrade/Downgrade tenant subscription plan
|
|
44
|
+
*/
|
|
45
|
+
export function updateManagedSubscription(subscriptionId, { paymentMethodId, planId }) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
console.debug("updateManagedSubscription()", { subscriptionId });
|
|
48
|
+
return Put(`${urls.subscriptions.managedSubscriptions.v1}/${subscriptionId}`, { paymentMethodId, planId });
|
|
49
|
+
});
|
|
50
|
+
}
|
|
24
51
|
//# sourceMappingURL=managedSubscriptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managedSubscriptions.js","sourceRoot":"","sources":["../../../src/subscriptions/managedSubscriptions.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"managedSubscriptions.js","sourceRoot":"","sources":["../../../src/subscriptions/managedSubscriptions.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,MAAM,UAAgB,sBAAsB,CAAC,cAAsB;;QAC/D,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,EAAC,cAAc,EAAC,CAAC,CAAC;QAC5D,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE,IAAI,cAAc,EAAE,CAAC,CAAA;IACjF,CAAC;CAAA;AAED,MAAM,UAAgB,uBAAuB;;QACzC,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC3C,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE,EAAE,CAAC,CAAA;IAC/D,CAAC;CAAA;AAED;;GAEG;AACH,MAAM,UAAgB,yBAAyB,CAC7C,cAAsB;;QAEpB,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QACjE,OAAO,GAAG,CACR,GAAG,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE,IAAI,cAAc,iBAAiB,EAChF,EAAE,CACH,CAAC;IACN,CAAC;CAAA;AAED;;GAEG;AACH,MAAM,UAAgB,wBAAwB,CAC5C,cAAsB;;QAEpB,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QAChE,OAAO,GAAG,CACR,GAAG,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE,IAAI,cAAc,YAAY,EAC3E,EAAE,CACH,CAAC;IACN,CAAC;CAAA;AAED;;GAEG;AACH,MAAM,UAAgB,yBAAyB,CAC7C,cAAsB,EACtB,EAAE,eAAe,EAAE,MAAM,EAAqC;;QAE5D,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QACjE,OAAO,GAAG,CACR,GAAG,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE,IAAI,cAAc,EAAE,EACjE,EAAE,eAAe,EAAE,MAAM,EAAE,CAC5B,CAAC;IACN,CAAC;CAAA"}
|
package/dist/fetch.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ interface RequestOptions {
|
|
|
9
9
|
headers?: Record<string, string>;
|
|
10
10
|
credentials?: RequestCredentials;
|
|
11
11
|
}
|
|
12
|
-
export declare function getBaseUrl(context: ContextOptions): string;
|
|
12
|
+
export declare function getBaseUrl(context: ContextOptions, url: string): string;
|
|
13
13
|
export declare const Get: (url: string, params?: any, opts?: Omit<RequestOptions, "method" | "url"> | undefined) => Promise<any>;
|
|
14
14
|
export declare const Post: (url: string, body?: any, opts?: Omit<RequestOptions, "method" | "url"> | undefined) => Promise<any>;
|
|
15
15
|
export declare const Patch: (url: string, body?: any, opts?: Omit<RequestOptions, "method" | "url"> | undefined) => Promise<any>;
|
package/dist/fetch.js
CHANGED
|
@@ -12,8 +12,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.PostDownload = exports.Delete = exports.Put = exports.Patch = exports.Post = exports.Get = exports.getBaseUrl = void 0;
|
|
13
13
|
const ContextHolder_1 = require("./ContextHolder");
|
|
14
14
|
const error_1 = require("./error");
|
|
15
|
-
function getBaseUrl(context) {
|
|
16
|
-
let baseUrl
|
|
15
|
+
function getBaseUrl(context, url) {
|
|
16
|
+
let baseUrl;
|
|
17
|
+
if (typeof context.baseUrl === 'function') {
|
|
18
|
+
baseUrl = context.baseUrl(url);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
baseUrl = context.baseUrl;
|
|
22
|
+
}
|
|
17
23
|
const prefix = context.urlPrefix || 'frontegg';
|
|
18
24
|
if (!baseUrl.endsWith('/')) {
|
|
19
25
|
baseUrl += '/';
|
|
@@ -26,7 +32,7 @@ function getBaseUrl(context) {
|
|
|
26
32
|
exports.getBaseUrl = getBaseUrl;
|
|
27
33
|
function prepareUrl(context, url, params) {
|
|
28
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const baseUrl = getBaseUrl(context);
|
|
35
|
+
const baseUrl = getBaseUrl(context, url);
|
|
30
36
|
const paramsToSend = yield buildQueryParams(context, params);
|
|
31
37
|
let finalUrl = url.startsWith('http') ? url : `${baseUrl}${url}`;
|
|
32
38
|
const hasKeys = Object.keys(paramsToSend).length > 0;
|
|
@@ -103,7 +109,8 @@ const sendRequest = (opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
103
109
|
});
|
|
104
110
|
if (response.status === 302) {
|
|
105
111
|
window.location.href = yield response.text();
|
|
106
|
-
return new Promise(() => {
|
|
112
|
+
return new Promise(() => {
|
|
113
|
+
});
|
|
107
114
|
}
|
|
108
115
|
if (!response.ok) {
|
|
109
116
|
if (response.status === 413) {
|
|
@@ -114,7 +121,8 @@ const sendRequest = (opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
114
121
|
errorMessage = yield response.text();
|
|
115
122
|
errorMessage = JSON.parse(errorMessage);
|
|
116
123
|
}
|
|
117
|
-
catch (e) {
|
|
124
|
+
catch (e) {
|
|
125
|
+
}
|
|
118
126
|
if (errorMessage.errors) {
|
|
119
127
|
errorMessage = errorMessage.errors.join(', ');
|
|
120
128
|
}
|
package/dist/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAgD;AAEhD,mCAA2C;AAa3C,SAAgB,UAAU,CAAC,OAAuB;
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAgD;AAEhD,mCAA2C;AAa3C,SAAgB,UAAU,CAAC,OAAuB,EAAE,GAAW;IAC7D,IAAI,OAAO,CAAC;IACZ,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE;QACzC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;KAChC;SAAM;QACL,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;KAC3B;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,IAAI,UAAU,CAAC;IAC/C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC1B,OAAO,IAAI,GAAG,CAAC;KAChB;IACD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAC7B,OAAO,IAAI,MAAM,CAAC;KACnB;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAfD,gCAeC;AAED,SAAe,UAAU,CAAC,OAAuB,EAAE,GAAW,EAAE,MAAY;;QAC1E,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,EAAE,GAAG,C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,EAAE,QAAQ,EAChB,WAAW,EAAE,kBAAkB,EAC/B,IAAI,IACD,IAAI,EACP,CAAA;EAAA,CAAC;AAPQ,QAAA,MAAM,UAOd;AAEE,MAAM,YAAY,GAAG,CAAO,GAAW,EAAE,IAAU,EAAE,MAAY,EAAE,IAAU,EAAE,EAAE;IACtF,OAAA,WAAW,iBACT,GAAG,EACH,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,kBAAkB,EAC/B,YAAY,EAAE,MAAM,EACpB,IAAI;QACJ,MAAM,IACH,IAAI,EACP,CAAA;EAAA,CAAC;AATQ,QAAA,YAAY,gBASpB"}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface KeyValuePair {
|
|
|
12
12
|
}
|
|
13
13
|
export declare type LogLevel = 'warn' | 'error';
|
|
14
14
|
export interface ContextOptions {
|
|
15
|
-
baseUrl: string;
|
|
15
|
+
baseUrl: string | ((url: string) => string);
|
|
16
16
|
clientId?: string;
|
|
17
17
|
tokenResolver?: () => Promise<string> | string;
|
|
18
18
|
additionalQueryParamsResolver?: () => Promise<KeyValuePair[]> | KeyValuePair[];
|
|
@@ -22,8 +22,11 @@ export interface ISubscriptionResponse {
|
|
|
22
22
|
currentPeriodEnd: string;
|
|
23
23
|
status: ISubscriptionStatus;
|
|
24
24
|
cancellation: ISubscriptionCancellationResponse | null;
|
|
25
|
-
items: ISubscriptionItemResponse[];
|
|
26
25
|
trialEnd?: string;
|
|
26
|
+
plan: ISubscriptionPlanResponse;
|
|
27
|
+
}
|
|
28
|
+
export interface ISubscriptionPlanResponse {
|
|
29
|
+
slug: string;
|
|
27
30
|
}
|
|
28
31
|
export interface ISubscriptionCancellationResponse {
|
|
29
32
|
policy: ISubscriptionCancellationPolicy;
|
|
@@ -119,3 +122,7 @@ export interface IUpdateSubscriptionRequest {
|
|
|
119
122
|
paymentMethodId: string;
|
|
120
123
|
planId: string;
|
|
121
124
|
}
|
|
125
|
+
export interface IUpdateManagedSubscriptionRequest {
|
|
126
|
+
paymentMethodId: string;
|
|
127
|
+
planId: string;
|
|
128
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/subscriptions/interfaces.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/subscriptions/interfaces.ts"],"names":[],"mappings":";;;;;;;;;;;;AAOA,gEAA8C"}
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
import { ISubscriptionResponse } from "./interfaces";
|
|
1
|
+
import { ISubscriptionResponse, IUpdateManagedSubscriptionRequest } from "./interfaces";
|
|
2
2
|
export declare function getManagedSubscription(subscriptionId: string): Promise<ISubscriptionResponse>;
|
|
3
3
|
export declare function getManagedSubscriptions(): Promise<ISubscriptionResponse[]>;
|
|
4
|
+
/**
|
|
5
|
+
* Cancel tenant subscription
|
|
6
|
+
*/
|
|
7
|
+
export declare function cancelManagedSubscription(subscriptionId: string): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Renew tenant subscription
|
|
10
|
+
*/
|
|
11
|
+
export declare function renewManagedSubscription(subscriptionId: string): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Upgrade/Downgrade tenant subscription plan
|
|
14
|
+
*/
|
|
15
|
+
export declare function updateManagedSubscription(subscriptionId: string, { paymentMethodId, planId }: IUpdateManagedSubscriptionRequest): Promise<void>;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getManagedSubscriptions = exports.getManagedSubscription = void 0;
|
|
12
|
+
exports.updateManagedSubscription = exports.renewManagedSubscription = exports.cancelManagedSubscription = exports.getManagedSubscriptions = exports.getManagedSubscription = void 0;
|
|
13
13
|
const fetch_1 = require("../fetch");
|
|
14
14
|
const constants_1 = require("../constants");
|
|
15
15
|
function getManagedSubscription(subscriptionId) {
|
|
@@ -26,4 +26,34 @@ function getManagedSubscriptions() {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
exports.getManagedSubscriptions = getManagedSubscriptions;
|
|
29
|
+
/**
|
|
30
|
+
* Cancel tenant subscription
|
|
31
|
+
*/
|
|
32
|
+
function cancelManagedSubscription(subscriptionId) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
console.debug("cancelManagedSubscription()", { subscriptionId });
|
|
35
|
+
return fetch_1.Put(`${constants_1.urls.subscriptions.managedSubscriptions.v1}/${subscriptionId}/cancellations/`, {});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
exports.cancelManagedSubscription = cancelManagedSubscription;
|
|
39
|
+
/**
|
|
40
|
+
* Renew tenant subscription
|
|
41
|
+
*/
|
|
42
|
+
function renewManagedSubscription(subscriptionId) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
console.debug("renewManagedSubscription()", { subscriptionId });
|
|
45
|
+
return fetch_1.Put(`${constants_1.urls.subscriptions.managedSubscriptions.v1}/${subscriptionId}/renewals/`, {});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
exports.renewManagedSubscription = renewManagedSubscription;
|
|
49
|
+
/**
|
|
50
|
+
* Upgrade/Downgrade tenant subscription plan
|
|
51
|
+
*/
|
|
52
|
+
function updateManagedSubscription(subscriptionId, { paymentMethodId, planId }) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
console.debug("updateManagedSubscription()", { subscriptionId });
|
|
55
|
+
return fetch_1.Put(`${constants_1.urls.subscriptions.managedSubscriptions.v1}/${subscriptionId}`, { paymentMethodId, planId });
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.updateManagedSubscription = updateManagedSubscription;
|
|
29
59
|
//# sourceMappingURL=managedSubscriptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managedSubscriptions.js","sourceRoot":"","sources":["../../src/subscriptions/managedSubscriptions.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"managedSubscriptions.js","sourceRoot":"","sources":["../../src/subscriptions/managedSubscriptions.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,oCAAoC;AACpC,4CAAoC;AAEpC,SAAsB,sBAAsB,CAAC,cAAsB;;QAC/D,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,EAAC,cAAc,EAAC,CAAC,CAAC;QAC5D,OAAO,WAAG,CAAC,GAAG,gBAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE,IAAI,cAAc,EAAE,CAAC,CAAA;IACjF,CAAC;CAAA;AAHD,wDAGC;AAED,SAAsB,uBAAuB;;QACzC,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC3C,OAAO,WAAG,CAAC,GAAG,gBAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE,EAAE,CAAC,CAAA;IAC/D,CAAC;CAAA;AAHD,0DAGC;AAED;;GAEG;AACH,SAAsB,yBAAyB,CAC7C,cAAsB;;QAEpB,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QACjE,OAAO,WAAG,CACR,GAAG,gBAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE,IAAI,cAAc,iBAAiB,EAChF,EAAE,CACH,CAAC;IACN,CAAC;CAAA;AARD,8DAQC;AAED;;GAEG;AACH,SAAsB,wBAAwB,CAC5C,cAAsB;;QAEpB,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QAChE,OAAO,WAAG,CACR,GAAG,gBAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE,IAAI,cAAc,YAAY,EAC3E,EAAE,CACH,CAAC;IACN,CAAC;CAAA;AARD,4DAQC;AAED;;GAEG;AACH,SAAsB,yBAAyB,CAC7C,cAAsB,EACtB,EAAE,eAAe,EAAE,MAAM,EAAqC;;QAE5D,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QACjE,OAAO,WAAG,CACR,GAAG,gBAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE,IAAI,cAAc,EAAE,EACjE,EAAE,eAAe,EAAE,MAAM,EAAE,CAC5B,CAAC;IACN,CAAC;CAAA;AATD,8DASC"}
|
package/dist/umd/index.js
CHANGED
|
@@ -116,8 +116,14 @@
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
function getBaseUrl(context) {
|
|
120
|
-
let baseUrl
|
|
119
|
+
function getBaseUrl(context, url) {
|
|
120
|
+
let baseUrl;
|
|
121
|
+
if (typeof context.baseUrl === 'function') {
|
|
122
|
+
baseUrl = context.baseUrl(url);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
baseUrl = context.baseUrl;
|
|
126
|
+
}
|
|
121
127
|
const prefix = context.urlPrefix || 'frontegg';
|
|
122
128
|
if (!baseUrl.endsWith('/')) {
|
|
123
129
|
baseUrl += '/';
|
|
@@ -129,7 +135,7 @@
|
|
|
129
135
|
}
|
|
130
136
|
function prepareUrl(context, url, params) {
|
|
131
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
-
const baseUrl = getBaseUrl(context);
|
|
138
|
+
const baseUrl = getBaseUrl(context, url);
|
|
133
139
|
const paramsToSend = yield buildQueryParams(context, params);
|
|
134
140
|
let finalUrl = url.startsWith('http') ? url : `${baseUrl}${url}`;
|
|
135
141
|
const hasKeys = Object.keys(paramsToSend).length > 0;
|
|
@@ -206,7 +212,8 @@
|
|
|
206
212
|
});
|
|
207
213
|
if (response.status === 302) {
|
|
208
214
|
window.location.href = yield response.text();
|
|
209
|
-
return new Promise(() => {
|
|
215
|
+
return new Promise(() => {
|
|
216
|
+
});
|
|
210
217
|
}
|
|
211
218
|
if (!response.ok) {
|
|
212
219
|
if (response.status === 413) {
|
|
@@ -217,7 +224,8 @@
|
|
|
217
224
|
errorMessage = yield response.text();
|
|
218
225
|
errorMessage = JSON.parse(errorMessage);
|
|
219
226
|
}
|
|
220
|
-
catch (e) {
|
|
227
|
+
catch (e) {
|
|
228
|
+
}
|
|
221
229
|
if (errorMessage.errors) {
|
|
222
230
|
errorMessage = errorMessage.errors.join(', ');
|
|
223
231
|
}
|
|
@@ -2332,6 +2340,33 @@
|
|
|
2332
2340
|
console.debug('getManagedSubscriptions()');
|
|
2333
2341
|
return Get(`${urls.subscriptions.managedSubscriptions.v1}`);
|
|
2334
2342
|
});
|
|
2343
|
+
}
|
|
2344
|
+
/**
|
|
2345
|
+
* Cancel tenant subscription
|
|
2346
|
+
*/
|
|
2347
|
+
function cancelManagedSubscription(subscriptionId) {
|
|
2348
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2349
|
+
console.debug("cancelManagedSubscription()", { subscriptionId });
|
|
2350
|
+
return Put(`${urls.subscriptions.managedSubscriptions.v1}/${subscriptionId}/cancellations/`, {});
|
|
2351
|
+
});
|
|
2352
|
+
}
|
|
2353
|
+
/**
|
|
2354
|
+
* Renew tenant subscription
|
|
2355
|
+
*/
|
|
2356
|
+
function renewManagedSubscription(subscriptionId) {
|
|
2357
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2358
|
+
console.debug("renewManagedSubscription()", { subscriptionId });
|
|
2359
|
+
return Put(`${urls.subscriptions.managedSubscriptions.v1}/${subscriptionId}/renewals/`, {});
|
|
2360
|
+
});
|
|
2361
|
+
}
|
|
2362
|
+
/**
|
|
2363
|
+
* Upgrade/Downgrade tenant subscription plan
|
|
2364
|
+
*/
|
|
2365
|
+
function updateManagedSubscription(subscriptionId, { paymentMethodId, planId }) {
|
|
2366
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2367
|
+
console.debug("updateManagedSubscription()", { subscriptionId });
|
|
2368
|
+
return Put(`${urls.subscriptions.managedSubscriptions.v1}/${subscriptionId}`, { paymentMethodId, planId });
|
|
2369
|
+
});
|
|
2335
2370
|
}
|
|
2336
2371
|
|
|
2337
2372
|
/**
|
|
@@ -2528,6 +2563,9 @@
|
|
|
2528
2563
|
updateSubscription: updateSubscription,
|
|
2529
2564
|
getManagedSubscription: getManagedSubscription,
|
|
2530
2565
|
getManagedSubscriptions: getManagedSubscriptions,
|
|
2566
|
+
cancelManagedSubscription: cancelManagedSubscription,
|
|
2567
|
+
renewManagedSubscription: renewManagedSubscription,
|
|
2568
|
+
updateManagedSubscription: updateManagedSubscription,
|
|
2531
2569
|
getSubscriptionPlans: getSubscriptionPlans,
|
|
2532
2570
|
getSubscriptionPlan: getSubscriptionPlan,
|
|
2533
2571
|
getSubscriptionInvoices: getSubscriptionInvoices,
|
package/package.json
CHANGED
package/src/fetch.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ContextHolder } from './ContextHolder';
|
|
2
2
|
import { ContextOptions, KeyValuePair } from './interfaces';
|
|
3
|
-
import { FronteggApiError } from
|
|
3
|
+
import { FronteggApiError } from './error';
|
|
4
4
|
|
|
5
5
|
interface RequestOptions {
|
|
6
6
|
url: string;
|
|
@@ -13,8 +13,13 @@ interface RequestOptions {
|
|
|
13
13
|
credentials?: RequestCredentials;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export function getBaseUrl(context: ContextOptions): string {
|
|
17
|
-
let baseUrl
|
|
16
|
+
export function getBaseUrl(context: ContextOptions, url: string): string {
|
|
17
|
+
let baseUrl;
|
|
18
|
+
if (typeof context.baseUrl === 'function') {
|
|
19
|
+
baseUrl = context.baseUrl(url);
|
|
20
|
+
} else {
|
|
21
|
+
baseUrl = context.baseUrl;
|
|
22
|
+
}
|
|
18
23
|
const prefix = context.urlPrefix || 'frontegg';
|
|
19
24
|
if (!baseUrl.endsWith('/')) {
|
|
20
25
|
baseUrl += '/';
|
|
@@ -26,7 +31,7 @@ export function getBaseUrl(context: ContextOptions): string {
|
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
async function prepareUrl(context: ContextOptions, url: string, params?: any): Promise<string> {
|
|
29
|
-
const baseUrl = getBaseUrl(context);
|
|
34
|
+
const baseUrl = getBaseUrl(context, url);
|
|
30
35
|
const paramsToSend = await buildQueryParams(context, params);
|
|
31
36
|
|
|
32
37
|
let finalUrl = url.startsWith('http') ? url : `${baseUrl}${url}`;
|
|
@@ -110,7 +115,8 @@ const sendRequest = async (opts: RequestOptions) => {
|
|
|
110
115
|
|
|
111
116
|
if (response.status === 302) {
|
|
112
117
|
window.location.href = await response.text();
|
|
113
|
-
return new Promise(() => {
|
|
118
|
+
return new Promise(() => {
|
|
119
|
+
});
|
|
114
120
|
}
|
|
115
121
|
if (!response.ok) {
|
|
116
122
|
if (response.status === 413) {
|
|
@@ -120,16 +126,17 @@ const sendRequest = async (opts: RequestOptions) => {
|
|
|
120
126
|
try {
|
|
121
127
|
errorMessage = await response.text();
|
|
122
128
|
errorMessage = JSON.parse(errorMessage);
|
|
123
|
-
} catch (e) {
|
|
129
|
+
} catch (e) {
|
|
130
|
+
}
|
|
124
131
|
if (errorMessage.errors) {
|
|
125
132
|
errorMessage = errorMessage.errors.join(', ');
|
|
126
133
|
} else if (typeof errorMessage !== 'string') {
|
|
127
134
|
errorMessage = `Error ${response.status} - ${response.statusText}`;
|
|
128
135
|
}
|
|
129
136
|
|
|
130
|
-
if (response.status >= 400 && response.status < 500 && ['warn'].includes(context.logLevel ?? ''))
|
|
137
|
+
if (response.status >= 400 && response.status < 500 && [ 'warn' ].includes(context.logLevel ?? ''))
|
|
131
138
|
console.warn(errorMessage);
|
|
132
|
-
else if (response.status === 500 && ['warn', 'error'].includes(context.logLevel ?? '')) console.error(errorMessage);
|
|
139
|
+
else if (response.status === 500 && [ 'warn', 'error' ].includes(context.logLevel ?? '')) console.error(errorMessage);
|
|
133
140
|
|
|
134
141
|
throw new FronteggApiError(errorMessage, response.status);
|
|
135
142
|
}
|
package/src/interfaces.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface KeyValuePair {
|
|
|
16
16
|
export type LogLevel = 'warn' | 'error';
|
|
17
17
|
|
|
18
18
|
export interface ContextOptions {
|
|
19
|
-
baseUrl: string;
|
|
19
|
+
baseUrl: string | ((url: string) => string);
|
|
20
20
|
clientId?: string;
|
|
21
21
|
tokenResolver?: () => Promise<string> | string; // custom resolve Authorization Header value
|
|
22
22
|
additionalQueryParamsResolver?: () => Promise<KeyValuePair[]> | KeyValuePair[];
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ISubscriptionCancellationPolicy,
|
|
3
|
+
ISubscriptionStatus,
|
|
4
|
+
PaymentMethodType,
|
|
5
|
+
ProviderType,
|
|
6
|
+
} from "./enums";
|
|
2
7
|
|
|
3
8
|
export * from "./providers/stripe/interfaces";
|
|
4
9
|
|
|
@@ -26,8 +31,12 @@ export interface ISubscriptionResponse {
|
|
|
26
31
|
currentPeriodEnd: string;
|
|
27
32
|
status: ISubscriptionStatus;
|
|
28
33
|
cancellation: ISubscriptionCancellationResponse | null;
|
|
29
|
-
items: ISubscriptionItemResponse[];
|
|
30
34
|
trialEnd?: string;
|
|
35
|
+
plan: ISubscriptionPlanResponse;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ISubscriptionPlanResponse {
|
|
39
|
+
slug: string;
|
|
31
40
|
}
|
|
32
41
|
|
|
33
42
|
export interface ISubscriptionCancellationResponse {
|
|
@@ -132,12 +141,17 @@ export interface ICreateTenantConfigurationResponse {
|
|
|
132
141
|
}
|
|
133
142
|
|
|
134
143
|
export interface IPaymentProviderResponse {
|
|
135
|
-
providerType: ProviderType
|
|
136
|
-
name: string
|
|
137
|
-
status: string
|
|
144
|
+
providerType: ProviderType;
|
|
145
|
+
name: string;
|
|
146
|
+
status: string;
|
|
138
147
|
}
|
|
139
148
|
|
|
140
149
|
export interface IUpdateSubscriptionRequest {
|
|
141
150
|
paymentMethodId: string;
|
|
142
151
|
planId: string;
|
|
143
152
|
}
|
|
153
|
+
|
|
154
|
+
export interface IUpdateManagedSubscriptionRequest {
|
|
155
|
+
paymentMethodId: string;
|
|
156
|
+
planId: string;
|
|
157
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ISubscriptionResponse } from "./interfaces";
|
|
2
|
-
import { Get } from "../fetch";
|
|
1
|
+
import { ISubscriptionResponse, IUpdateManagedSubscriptionRequest } from "./interfaces";
|
|
2
|
+
import { Get, Put } from "../fetch";
|
|
3
3
|
import { urls } from "../constants";
|
|
4
4
|
|
|
5
5
|
export async function getManagedSubscription(subscriptionId: string): Promise<ISubscriptionResponse> {
|
|
@@ -11,3 +11,43 @@ export async function getManagedSubscriptions(): Promise<ISubscriptionResponse[]
|
|
|
11
11
|
console.debug('getManagedSubscriptions()');
|
|
12
12
|
return Get(`${urls.subscriptions.managedSubscriptions.v1}`)
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Cancel tenant subscription
|
|
17
|
+
*/
|
|
18
|
+
export async function cancelManagedSubscription(
|
|
19
|
+
subscriptionId: string
|
|
20
|
+
): Promise<void> {
|
|
21
|
+
console.debug("cancelManagedSubscription()", { subscriptionId });
|
|
22
|
+
return Put(
|
|
23
|
+
`${urls.subscriptions.managedSubscriptions.v1}/${subscriptionId}/cancellations/`,
|
|
24
|
+
{}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Renew tenant subscription
|
|
30
|
+
*/
|
|
31
|
+
export async function renewManagedSubscription(
|
|
32
|
+
subscriptionId: string
|
|
33
|
+
): Promise<void> {
|
|
34
|
+
console.debug("renewManagedSubscription()", { subscriptionId });
|
|
35
|
+
return Put(
|
|
36
|
+
`${urls.subscriptions.managedSubscriptions.v1}/${subscriptionId}/renewals/`,
|
|
37
|
+
{}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Upgrade/Downgrade tenant subscription plan
|
|
43
|
+
*/
|
|
44
|
+
export async function updateManagedSubscription(
|
|
45
|
+
subscriptionId: string,
|
|
46
|
+
{ paymentMethodId, planId }: IUpdateManagedSubscriptionRequest
|
|
47
|
+
): Promise<void> {
|
|
48
|
+
console.debug("updateManagedSubscription()", { subscriptionId });
|
|
49
|
+
return Put(
|
|
50
|
+
`${urls.subscriptions.managedSubscriptions.v1}/${subscriptionId}`,
|
|
51
|
+
{ paymentMethodId, planId }
|
|
52
|
+
);
|
|
53
|
+
}
|