@frontegg/rest-api 2.10.58 → 2.10.61

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 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.61](https://github.com/frontegg/typescript-rest-api/compare/v2.10.60...v2.10.61) (2022-02-27)
6
+
7
+ ### [2.10.60](https://github.com/frontegg/typescript-rest-api/compare/v2.10.59...v2.10.60) (2022-02-24)
8
+
9
+ ### [2.10.59](https://github.com/frontegg/typescript-rest-api/compare/v2.10.58...v2.10.59) (2022-02-24)
10
+
5
11
  ### [2.10.58](https://github.com/frontegg/typescript-rest-api/compare/v2.10.57...v2.10.58) (2022-02-22)
6
12
 
7
13
  ### [2.10.57](https://github.com/frontegg/typescript-rest-api/compare/v2.10.56...v2.10.57) (2022-02-20)
@@ -16,6 +16,7 @@ export interface IPlanResponsePriceResponse {
16
16
  export interface ISubscriptionResponse {
17
17
  id: string;
18
18
  externalId: string;
19
+ externallyManaged: boolean;
19
20
  startDate: string;
20
21
  currentPeriodStart: string;
21
22
  currentPeriodEnd: string;
@@ -117,4 +118,13 @@ export interface IPaymentProviderResponse {
117
118
  export interface IUpdateSubscriptionRequest {
118
119
  paymentMethodId: string;
119
120
  planId: string;
121
+ items: IUpdateSubscriptionItemRequest[];
122
+ }
123
+ export interface IUpdateSubscriptionItemRequest {
124
+ id: string;
125
+ planId: string;
126
+ }
127
+ export interface IUpdateManagedSubscriptionRequest {
128
+ paymentMethodId: string;
129
+ planId: string;
120
130
  }
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/subscriptions/interfaces.ts"],"names":[],"mappings":"AAEA,cAAc,+BAA+B,CAAC"}
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;AAC/B,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"}
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,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4 +18,4 @@ export declare function renewSubscription(subscriptionId: string): Promise<void>
18
18
  /**
19
19
  * Upgrade/Downgrade tenant subscription plan
20
20
  */
21
- export declare function updateSubscription(subscriptionId: string, { paymentMethodId, planId }: IUpdateSubscriptionRequest): Promise<void>;
21
+ export declare function updateSubscription(subscriptionId: string, { paymentMethodId, planId, items }: IUpdateSubscriptionRequest): Promise<void>;
@@ -48,10 +48,10 @@ export function renewSubscription(subscriptionId) {
48
48
  /**
49
49
  * Upgrade/Downgrade tenant subscription plan
50
50
  */
51
- export function updateSubscription(subscriptionId, { paymentMethodId, planId }) {
51
+ export function updateSubscription(subscriptionId, { paymentMethodId, planId, items }) {
52
52
  return __awaiter(this, void 0, void 0, function* () {
53
53
  console.debug("updateSubscription()", { subscriptionId });
54
- return Put(`${urls.subscriptions.billing.subscriptions.v1}/${subscriptionId}`, { paymentMethodId, planId });
54
+ return Put(`${urls.subscriptions.billing.subscriptions.v1}/${subscriptionId}`, { paymentMethodId, planId, items });
55
55
  });
56
56
  }
57
57
  //# sourceMappingURL=subscriptions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../../../src/subscriptions/subscriptions.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC;;GAEG;AACH,MAAM,UAAgB,gBAAgB;;QACpC,OAAO,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACpC,OAAO,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IAC1D,CAAC;CAAA;AAED;;GAEG;AACH,MAAM,UAAgB,eAAe,CACnC,cAAsB;;QAEtB,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QACvD,OAAO,GAAG,CACR,GAAG,IA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AE,EAClE,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,CACnC,CAAC;IACJ,CAAC;CAAA"}
@@ -16,6 +16,7 @@ export interface IPlanResponsePriceResponse {
16
16
  export interface ISubscriptionResponse {
17
17
  id: string;
18
18
  externalId: string;
19
+ externallyManaged: boolean;
19
20
  startDate: string;
20
21
  currentPeriodStart: string;
21
22
  currentPeriodEnd: string;
@@ -117,4 +118,13 @@ export interface IPaymentProviderResponse {
117
118
  export interface IUpdateSubscriptionRequest {
118
119
  paymentMethodId: string;
119
120
  planId: string;
121
+ items: IUpdateSubscriptionItemRequest[];
122
+ }
123
+ export interface IUpdateSubscriptionItemRequest {
124
+ id: string;
125
+ planId: string;
126
+ }
127
+ export interface IUpdateManagedSubscriptionRequest {
128
+ paymentMethodId: string;
129
+ planId: string;
120
130
  }
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/subscriptions/interfaces.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,gEAA8C"}
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,oCAA+B;AAC/B,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"}
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"}
@@ -18,4 +18,4 @@ export declare function renewSubscription(subscriptionId: string): Promise<void>
18
18
  /**
19
19
  * Upgrade/Downgrade tenant subscription plan
20
20
  */
21
- export declare function updateSubscription(subscriptionId: string, { paymentMethodId, planId }: IUpdateSubscriptionRequest): Promise<void>;
21
+ export declare function updateSubscription(subscriptionId: string, { paymentMethodId, planId, items }: IUpdateSubscriptionRequest): Promise<void>;
@@ -55,10 +55,10 @@ exports.renewSubscription = renewSubscription;
55
55
  /**
56
56
  * Upgrade/Downgrade tenant subscription plan
57
57
  */
58
- function updateSubscription(subscriptionId, { paymentMethodId, planId }) {
58
+ function updateSubscription(subscriptionId, { paymentMethodId, planId, items }) {
59
59
  return __awaiter(this, void 0, void 0, function* () {
60
60
  console.debug("updateSubscription()", { subscriptionId });
61
- return fetch_1.Put(`${constants_1.urls.subscriptions.billing.subscriptions.v1}/${subscriptionId}`, { paymentMethodId, planId });
61
+ return fetch_1.Put(`${constants_1.urls.subscriptions.billing.subscriptions.v1}/${subscriptionId}`, { paymentMethodId, planId, items });
62
62
  });
63
63
  }
64
64
  exports.updateSubscription = updateSubscription;
@@ -1 +1 @@
1
- {"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../../src/subscriptions/subscriptions.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,oCAAoC;AACpC,4CAAoC;AAEpC;;GAEG;AACH,SAAsB,gBAAgB;;QACpC,OAAO,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACpC,OAAO,WAAG,CAAC,gBAAI,CAAC,aAAa,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IAC1D,CAAC;CAAA;AAHD,4CAGC;AAED;;GAEG;AACH,SAAsB,eAAe,CACnC,cAAsB;;QAEtB,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QACvD,OAAO,WAAG,CACR,GAAG,gBAAI,CAAC,aAAa,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,IAAI,cAAc,EAAE,CACnE,CAAC;IACJ,CAAC;CAAA;AAPD,0CAOC;AAED;;GAEG;AACH,SAAsB,kBAAkB,CACtC,cAAsB;;QAEtB,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QAC1D,OAAO,WAAG,CACR,GAAG,gBAAI,CAAC,aAAa,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,IAAI,cAAc,iBAAiB,EACjF,EAAE,CACH,CAAC;IACJ,CAAC;CAAA;AARD,gDAQC;AAED;;GAEG;AACH,SAAsB,iBAAiB,CACrC,cAAsB;;QAEtB,OAAO,CAA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C,sBAAsB,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QAC1D,OAAO,WAAG,CACR,GAAG,gBAAI,CAAC,aAAa,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,IAAI,cAAc,iBAAiB,EACjF,EAAE,CACH,CAAC;IACJ,CAAC;CAAA;AARD,gDAQC;AAED;;GAEG;AACH,SAAsB,iBAAiB,CACrC,cAAsB;;QAEtB,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QACzD,OAAO,WAAG,CACR,GAAG,gBAAI,CAAC,aAAa,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,IAAI,cAAc,YAAY,EAC5E,EAAE,CACH,CAAC;IACJ,CAAC;CAAA;AARD,8CAQC;AAED;;GAEG;AACH,SAAsB,kBAAkB,CACtC,cAAsB,EACtB,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,EAA8B;;QAE9D,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QAC1D,OAAO,WAAG,CACR,GAAG,gBAAI,CAAC,aAAa,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,IAAI,cAAc,EAAE,EAClE,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,CACnC,CAAC;IACJ,CAAC;CAAA;AATD,gDASC"}
package/dist/umd/index.js CHANGED
@@ -2314,10 +2314,10 @@
2314
2314
  /**
2315
2315
  * Upgrade/Downgrade tenant subscription plan
2316
2316
  */
2317
- function updateSubscription(subscriptionId, { paymentMethodId, planId }) {
2317
+ function updateSubscription(subscriptionId, { paymentMethodId, planId, items }) {
2318
2318
  return __awaiter(this, void 0, void 0, function* () {
2319
2319
  console.debug("updateSubscription()", { subscriptionId });
2320
- return Put(`${urls.subscriptions.billing.subscriptions.v1}/${subscriptionId}`, { paymentMethodId, planId });
2320
+ return Put(`${urls.subscriptions.billing.subscriptions.v1}/${subscriptionId}`, { paymentMethodId, planId, items });
2321
2321
  });
2322
2322
  }
2323
2323
 
@@ -2332,6 +2332,33 @@
2332
2332
  console.debug('getManagedSubscriptions()');
2333
2333
  return Get(`${urls.subscriptions.managedSubscriptions.v1}`);
2334
2334
  });
2335
+ }
2336
+ /**
2337
+ * Cancel tenant subscription
2338
+ */
2339
+ function cancelManagedSubscription(subscriptionId) {
2340
+ return __awaiter(this, void 0, void 0, function* () {
2341
+ console.debug("cancelManagedSubscription()", { subscriptionId });
2342
+ return Put(`${urls.subscriptions.managedSubscriptions.v1}/${subscriptionId}/cancellations/`, {});
2343
+ });
2344
+ }
2345
+ /**
2346
+ * Renew tenant subscription
2347
+ */
2348
+ function renewManagedSubscription(subscriptionId) {
2349
+ return __awaiter(this, void 0, void 0, function* () {
2350
+ console.debug("renewManagedSubscription()", { subscriptionId });
2351
+ return Put(`${urls.subscriptions.managedSubscriptions.v1}/${subscriptionId}/renewals/`, {});
2352
+ });
2353
+ }
2354
+ /**
2355
+ * Upgrade/Downgrade tenant subscription plan
2356
+ */
2357
+ function updateManagedSubscription(subscriptionId, { paymentMethodId, planId }) {
2358
+ return __awaiter(this, void 0, void 0, function* () {
2359
+ console.debug("updateManagedSubscription()", { subscriptionId });
2360
+ return Put(`${urls.subscriptions.managedSubscriptions.v1}/${subscriptionId}`, { paymentMethodId, planId });
2361
+ });
2335
2362
  }
2336
2363
 
2337
2364
  /**
@@ -2528,6 +2555,9 @@
2528
2555
  updateSubscription: updateSubscription,
2529
2556
  getManagedSubscription: getManagedSubscription,
2530
2557
  getManagedSubscriptions: getManagedSubscriptions,
2558
+ cancelManagedSubscription: cancelManagedSubscription,
2559
+ renewManagedSubscription: renewManagedSubscription,
2560
+ updateManagedSubscription: updateManagedSubscription,
2531
2561
  getSubscriptionPlans: getSubscriptionPlans,
2532
2562
  getSubscriptionPlan: getSubscriptionPlan,
2533
2563
  getSubscriptionInvoices: getSubscriptionInvoices,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@frontegg/rest-api",
3
3
  "libName": "FronteggRestApi",
4
- "version": "2.10.58",
4
+ "version": "2.10.61",
5
5
  "author": "Frontegg LTD",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -1,4 +1,9 @@
1
- import {ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType} from "./enums";
1
+ import {
2
+ ISubscriptionCancellationPolicy,
3
+ ISubscriptionStatus,
4
+ PaymentMethodType,
5
+ ProviderType,
6
+ } from "./enums";
2
7
 
3
8
  export * from "./providers/stripe/interfaces";
4
9
 
@@ -20,6 +25,7 @@ export interface IPlanResponsePriceResponse {
20
25
  export interface ISubscriptionResponse {
21
26
  id: string;
22
27
  externalId: string;
28
+ externallyManaged: boolean;
23
29
  startDate: string;
24
30
  currentPeriodStart: string;
25
31
  currentPeriodEnd: string;
@@ -131,12 +137,23 @@ export interface ICreateTenantConfigurationResponse {
131
137
  }
132
138
 
133
139
  export interface IPaymentProviderResponse {
134
- providerType: ProviderType
135
- name: string
136
- status: string
140
+ providerType: ProviderType;
141
+ name: string;
142
+ status: string;
137
143
  }
138
144
 
139
145
  export interface IUpdateSubscriptionRequest {
140
146
  paymentMethodId: string;
141
147
  planId: string;
148
+ items: IUpdateSubscriptionItemRequest[];
149
+ }
150
+
151
+ export interface IUpdateSubscriptionItemRequest {
152
+ id: string;
153
+ planId: string;
142
154
  }
155
+
156
+ export interface IUpdateManagedSubscriptionRequest {
157
+ paymentMethodId: string;
158
+ planId: string;
159
+ }
@@ -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
+ }
@@ -53,11 +53,11 @@ export async function renewSubscription(
53
53
  */
54
54
  export async function updateSubscription(
55
55
  subscriptionId: string,
56
- { paymentMethodId, planId }: IUpdateSubscriptionRequest
56
+ { paymentMethodId, planId, items }: IUpdateSubscriptionRequest
57
57
  ): Promise<void> {
58
58
  console.debug("updateSubscription()", { subscriptionId });
59
59
  return Put(
60
60
  `${urls.subscriptions.billing.subscriptions.v1}/${subscriptionId}`,
61
- { paymentMethodId, planId }
61
+ { paymentMethodId, planId, items }
62
62
  );
63
63
  }