univapay-node 2.1.0 → 3.0.0
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/cjs/api/RestAPI.d.ts +44 -39
- package/dist/cjs/api/RestAPI.js +41 -58
- package/dist/cjs/api/RestAPI.js.map +1 -1
- package/dist/cjs/api/utils/payload.js +2 -2
- package/dist/cjs/api/utils/payload.js.map +1 -1
- package/dist/cjs/common/constants.d.ts +1 -0
- package/dist/cjs/common/constants.js +2 -1
- package/dist/cjs/common/constants.js.map +1 -1
- package/dist/cjs/errors/APIError.d.ts +7 -5
- package/dist/cjs/errors/APIError.js.map +1 -1
- package/dist/cjs/resources/BankAccounts.d.ts +13 -7
- package/dist/cjs/resources/BankAccounts.js +24 -12
- package/dist/cjs/resources/BankAccounts.js.map +1 -1
- package/dist/cjs/resources/CRUDResource.d.ts +6 -6
- package/dist/cjs/resources/CRUDResource.js +10 -10
- package/dist/cjs/resources/CRUDResource.js.map +1 -1
- package/dist/cjs/resources/Cancels.d.ts +8 -9
- package/dist/cjs/resources/Cancels.js +19 -16
- package/dist/cjs/resources/Cancels.js.map +1 -1
- package/dist/cjs/resources/Captures.d.ts +9 -4
- package/dist/cjs/resources/Captures.js +4 -2
- package/dist/cjs/resources/Captures.js.map +1 -1
- package/dist/cjs/resources/Charges.d.ts +9 -10
- package/dist/cjs/resources/Charges.js +22 -18
- package/dist/cjs/resources/Charges.js.map +1 -1
- package/dist/cjs/resources/CheckoutInfo.d.ts +3 -2
- package/dist/cjs/resources/CheckoutInfo.js +4 -2
- package/dist/cjs/resources/CheckoutInfo.js.map +1 -1
- package/dist/cjs/resources/ECFormLinks.d.ts +3 -2
- package/dist/cjs/resources/ECFormLinks.js +4 -2
- package/dist/cjs/resources/ECFormLinks.js.map +1 -1
- package/dist/cjs/resources/ECForms.d.ts +4 -2
- package/dist/cjs/resources/ECForms.js +4 -2
- package/dist/cjs/resources/ECForms.js.map +1 -1
- package/dist/cjs/resources/ECInfo.d.ts +3 -2
- package/dist/cjs/resources/ECInfo.js +4 -2
- package/dist/cjs/resources/ECInfo.js.map +1 -1
- package/dist/cjs/resources/Emails.d.ts +3 -2
- package/dist/cjs/resources/Emails.js +4 -2
- package/dist/cjs/resources/Emails.js.map +1 -1
- package/dist/cjs/resources/ExchangeRates.d.ts +3 -2
- package/dist/cjs/resources/ExchangeRates.js +4 -2
- package/dist/cjs/resources/ExchangeRates.js.map +1 -1
- package/dist/cjs/resources/Ledgers.d.ts +5 -3
- package/dist/cjs/resources/Ledgers.js +8 -4
- package/dist/cjs/resources/Ledgers.js.map +1 -1
- package/dist/cjs/resources/Merchants.d.ts +3 -2
- package/dist/cjs/resources/Merchants.js +4 -2
- package/dist/cjs/resources/Merchants.js.map +1 -1
- package/dist/cjs/resources/Platforms.d.ts +3 -2
- package/dist/cjs/resources/Platforms.js +5 -2
- package/dist/cjs/resources/Platforms.js.map +1 -1
- package/dist/cjs/resources/Products.d.ts +3 -2
- package/dist/cjs/resources/Products.js +4 -2
- package/dist/cjs/resources/Products.js.map +1 -1
- package/dist/cjs/resources/Refunds.d.ts +10 -10
- package/dist/cjs/resources/Refunds.js +23 -18
- package/dist/cjs/resources/Refunds.js.map +1 -1
- package/dist/cjs/resources/Resource.d.ts +9 -3
- package/dist/cjs/resources/Resource.js +18 -20
- package/dist/cjs/resources/Resource.js.map +1 -1
- package/dist/cjs/resources/Stores.d.ts +11 -6
- package/dist/cjs/resources/Stores.js +20 -10
- package/dist/cjs/resources/Stores.js.map +1 -1
- package/dist/cjs/resources/Subscriptions.d.ts +24 -21
- package/dist/cjs/resources/Subscriptions.js +57 -45
- package/dist/cjs/resources/Subscriptions.js.map +1 -1
- package/dist/cjs/resources/TemporaryTokenAlias.d.ts +8 -6
- package/dist/cjs/resources/TemporaryTokenAlias.js +18 -6
- package/dist/cjs/resources/TemporaryTokenAlias.js.map +1 -1
- package/dist/cjs/resources/TransactionTokens.d.ts +12 -7
- package/dist/cjs/resources/TransactionTokens.js +22 -15
- package/dist/cjs/resources/TransactionTokens.js.map +1 -1
- package/dist/cjs/resources/Transfers.d.ts +7 -4
- package/dist/cjs/resources/Transfers.js +13 -8
- package/dist/cjs/resources/Transfers.js.map +1 -1
- package/dist/cjs/resources/Verification.d.ts +7 -4
- package/dist/cjs/resources/Verification.js +12 -6
- package/dist/cjs/resources/Verification.js.map +1 -1
- package/dist/cjs/resources/WebHooks.d.ts +11 -6
- package/dist/cjs/resources/WebHooks.js +20 -10
- package/dist/cjs/resources/WebHooks.js.map +1 -1
- package/dist/cjs/resources/common/ignoreDescriptor.d.ts +2 -2
- package/dist/cjs/resources/common/ignoreDescriptor.js +18 -20
- package/dist/cjs/resources/common/ignoreDescriptor.js.map +1 -1
- package/dist/cjs/utils/fetch.js.map +1 -1
- package/dist/cjs/utils/object.d.ts +0 -4
- package/dist/cjs/utils/object.js +1 -30
- package/dist/cjs/utils/object.js.map +1 -1
- package/dist/esm/api/RestAPI.d.ts +44 -39
- package/dist/esm/api/RestAPI.js +43 -60
- package/dist/esm/api/RestAPI.js.map +1 -1
- package/dist/esm/api/utils/payload.js +2 -2
- package/dist/esm/api/utils/payload.js.map +1 -1
- package/dist/esm/common/constants.d.ts +1 -0
- package/dist/esm/common/constants.js +1 -0
- package/dist/esm/common/constants.js.map +1 -1
- package/dist/esm/errors/APIError.d.ts +7 -5
- package/dist/esm/errors/APIError.js.map +1 -1
- package/dist/esm/resources/BankAccounts.d.ts +13 -7
- package/dist/esm/resources/BankAccounts.js +24 -12
- package/dist/esm/resources/BankAccounts.js.map +1 -1
- package/dist/esm/resources/CRUDResource.d.ts +6 -6
- package/dist/esm/resources/CRUDResource.js +10 -10
- package/dist/esm/resources/CRUDResource.js.map +1 -1
- package/dist/esm/resources/Cancels.d.ts +8 -9
- package/dist/esm/resources/Cancels.js +19 -16
- package/dist/esm/resources/Cancels.js.map +1 -1
- package/dist/esm/resources/Captures.d.ts +9 -4
- package/dist/esm/resources/Captures.js +4 -2
- package/dist/esm/resources/Captures.js.map +1 -1
- package/dist/esm/resources/Charges.d.ts +9 -10
- package/dist/esm/resources/Charges.js +22 -18
- package/dist/esm/resources/Charges.js.map +1 -1
- package/dist/esm/resources/CheckoutInfo.d.ts +3 -2
- package/dist/esm/resources/CheckoutInfo.js +4 -2
- package/dist/esm/resources/CheckoutInfo.js.map +1 -1
- package/dist/esm/resources/ECFormLinks.d.ts +3 -2
- package/dist/esm/resources/ECFormLinks.js +4 -2
- package/dist/esm/resources/ECFormLinks.js.map +1 -1
- package/dist/esm/resources/ECForms.d.ts +4 -2
- package/dist/esm/resources/ECForms.js +4 -2
- package/dist/esm/resources/ECForms.js.map +1 -1
- package/dist/esm/resources/ECInfo.d.ts +3 -2
- package/dist/esm/resources/ECInfo.js +4 -2
- package/dist/esm/resources/ECInfo.js.map +1 -1
- package/dist/esm/resources/Emails.d.ts +3 -2
- package/dist/esm/resources/Emails.js +4 -2
- package/dist/esm/resources/Emails.js.map +1 -1
- package/dist/esm/resources/ExchangeRates.d.ts +3 -2
- package/dist/esm/resources/ExchangeRates.js +4 -2
- package/dist/esm/resources/ExchangeRates.js.map +1 -1
- package/dist/esm/resources/Ledgers.d.ts +5 -3
- package/dist/esm/resources/Ledgers.js +8 -4
- package/dist/esm/resources/Ledgers.js.map +1 -1
- package/dist/esm/resources/Merchants.d.ts +3 -2
- package/dist/esm/resources/Merchants.js +4 -2
- package/dist/esm/resources/Merchants.js.map +1 -1
- package/dist/esm/resources/Platforms.d.ts +3 -2
- package/dist/esm/resources/Platforms.js +5 -2
- package/dist/esm/resources/Platforms.js.map +1 -1
- package/dist/esm/resources/Products.d.ts +3 -2
- package/dist/esm/resources/Products.js +4 -2
- package/dist/esm/resources/Products.js.map +1 -1
- package/dist/esm/resources/Refunds.d.ts +10 -10
- package/dist/esm/resources/Refunds.js +23 -18
- package/dist/esm/resources/Refunds.js.map +1 -1
- package/dist/esm/resources/Resource.d.ts +9 -3
- package/dist/esm/resources/Resource.js +20 -22
- package/dist/esm/resources/Resource.js.map +1 -1
- package/dist/esm/resources/Stores.d.ts +11 -6
- package/dist/esm/resources/Stores.js +20 -10
- package/dist/esm/resources/Stores.js.map +1 -1
- package/dist/esm/resources/Subscriptions.d.ts +24 -21
- package/dist/esm/resources/Subscriptions.js +57 -45
- package/dist/esm/resources/Subscriptions.js.map +1 -1
- package/dist/esm/resources/TemporaryTokenAlias.d.ts +8 -6
- package/dist/esm/resources/TemporaryTokenAlias.js +18 -6
- package/dist/esm/resources/TemporaryTokenAlias.js.map +1 -1
- package/dist/esm/resources/TransactionTokens.d.ts +12 -7
- package/dist/esm/resources/TransactionTokens.js +22 -15
- package/dist/esm/resources/TransactionTokens.js.map +1 -1
- package/dist/esm/resources/Transfers.d.ts +7 -4
- package/dist/esm/resources/Transfers.js +13 -8
- package/dist/esm/resources/Transfers.js.map +1 -1
- package/dist/esm/resources/Verification.d.ts +7 -4
- package/dist/esm/resources/Verification.js +12 -6
- package/dist/esm/resources/Verification.js.map +1 -1
- package/dist/esm/resources/WebHooks.d.ts +11 -6
- package/dist/esm/resources/WebHooks.js +20 -10
- package/dist/esm/resources/WebHooks.js.map +1 -1
- package/dist/esm/resources/common/ignoreDescriptor.d.ts +2 -2
- package/dist/esm/resources/common/ignoreDescriptor.js +18 -20
- package/dist/esm/resources/common/ignoreDescriptor.js.map +1 -1
- package/dist/esm/utils/fetch.js.map +1 -1
- package/dist/esm/utils/object.d.ts +0 -4
- package/dist/esm/utils/object.js +1 -29
- package/dist/esm/utils/object.js.map +1 -1
- package/package.json +11 -11
|
@@ -9,8 +9,11 @@ var Platforms = /** @class */ (function (_super) {
|
|
|
9
9
|
function Platforms() {
|
|
10
10
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
11
11
|
}
|
|
12
|
-
Platforms.prototype.getConfiguration = function (data, auth
|
|
13
|
-
|
|
12
|
+
Platforms.prototype.getConfiguration = function (data, auth) {
|
|
13
|
+
var _a;
|
|
14
|
+
this._getConfiguration =
|
|
15
|
+
(_a = this._getConfiguration) !== null && _a !== void 0 ? _a : this.defineRoute(HTTPMethod.GET, "/platform", { requireAuth: false });
|
|
16
|
+
return this._getConfiguration(data, auth);
|
|
14
17
|
};
|
|
15
18
|
return Platforms;
|
|
16
19
|
}(CRUDResource));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Platforms.js","sourceRoot":"","sources":["../../../src/resources/Platforms.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAc,UAAU,
|
|
1
|
+
{"version":3,"file":"Platforms.js","sourceRoot":"","sources":["../../../src/resources/Platforms.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAc,UAAU,EAAY,MAAM,mBAAmB,CAAC;AAKrE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAcjD;IAA+B,6BAAY;IAA3C;;IAOA,CAAC;IALG,oCAAgB,GAAhB,UAAiB,IAAqB,EAAE,IAAiB;;QACrD,IAAI,CAAC,iBAAiB;YAClB,MAAA,IAAI,CAAC,iBAAiB,mCAAI,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;QACpG,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;IACL,gBAAC;AAAD,CAAC,AAPD,CAA+B,YAAY,GAO1C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Resources/Products
|
|
3
3
|
*/
|
|
4
|
-
import { AuthParams,
|
|
4
|
+
import { AuthParams, SendData } from "../api/RestAPI.js";
|
|
5
5
|
import { CRUDResource } from "./CRUDResource.js";
|
|
6
6
|
import { TransactionTokenType } from "./TransactionTokens.js";
|
|
7
7
|
export declare type ProductItem = {
|
|
@@ -23,5 +23,6 @@ export declare type ProductItem = {
|
|
|
23
23
|
export declare type ResponseProduct = ProductItem;
|
|
24
24
|
export declare class Products extends CRUDResource {
|
|
25
25
|
static routeBase: string;
|
|
26
|
-
|
|
26
|
+
private _get;
|
|
27
|
+
get(id: string, data?: SendData<void>, auth?: AuthParams): Promise<ResponseProduct>;
|
|
27
28
|
}
|
|
@@ -5,8 +5,10 @@ var Products = /** @class */ (function (_super) {
|
|
|
5
5
|
function Products() {
|
|
6
6
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
7
7
|
}
|
|
8
|
-
Products.prototype.get = function (id, data, auth
|
|
9
|
-
|
|
8
|
+
Products.prototype.get = function (id, data, auth) {
|
|
9
|
+
var _a;
|
|
10
|
+
this._get = (_a = this._get) !== null && _a !== void 0 ? _a : this._getRoute();
|
|
11
|
+
return this._get(data, auth, { id: id });
|
|
10
12
|
};
|
|
11
13
|
Products.routeBase = "/checkout/products";
|
|
12
14
|
return Products;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Products.js","sourceRoot":"","sources":["../../../src/resources/Products.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Products.js","sourceRoot":"","sources":["../../../src/resources/Products.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAyBjD;IAA8B,4BAAY;IAA1C;;IAQA,CAAC;IAJG,sBAAG,GAAH,UAAI,EAAU,EAAE,IAAqB,EAAE,IAAiB;;QACpD,IAAI,CAAC,IAAI,GAAG,MAAA,IAAI,CAAC,IAAI,mCAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAA,EAAE,CAAC,CAAC;IACzC,CAAC;IANM,kBAAS,GAAG,oBAAoB,CAAC;IAO5C,eAAC;CAAA,AARD,CAA8B,YAAY,GAQzC;SARY,QAAQ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Resources/Refunds
|
|
3
3
|
*/
|
|
4
|
-
import { AuthParams, PollParams,
|
|
4
|
+
import { AuthParams, PollParams, PollData, SendData } from "../api/RestAPI.js";
|
|
5
5
|
import { PaymentError } from "../errors/APIError.js";
|
|
6
6
|
import { ProcessingMode } from "./common/enums.js";
|
|
7
7
|
import { Metadata } from "./common/types.js";
|
|
@@ -55,13 +55,13 @@ export declare type ResponseRefunds = CRUDItemsResponse<RefundListItem>;
|
|
|
55
55
|
export declare class Refunds extends CRUDResource {
|
|
56
56
|
static requiredParams: string[];
|
|
57
57
|
static routeBase: string;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
private _list;
|
|
59
|
+
list(storeId: string, chargeId: string, data?: SendData<RefundsListParams>, auth?: AuthParams): Promise<ResponseRefunds>;
|
|
60
|
+
private _create;
|
|
61
|
+
create(storeId: string, chargeId: string, data: SendData<RefundCreateParams>, auth?: AuthParams): Promise<ResponseRefund>;
|
|
62
|
+
private _get;
|
|
63
|
+
get(storeId: string, chargeId: string, id: string, data?: SendData<PollData>, auth?: AuthParams): Promise<ResponseRefund>;
|
|
64
|
+
private _update;
|
|
65
|
+
update(storeId: string, chargeId: string, id: string, data?: SendData<RefundUpdateParams>, auth?: AuthParams): Promise<ResponseRefund>;
|
|
66
|
+
poll(storeId: string, chargeId: string, id: string, data?: SendData<PollData>, auth?: AuthParams, pollParams?: Partial<PollParams<ResponseRefund>>): Promise<ResponseRefund>;
|
|
67
67
|
}
|
|
@@ -23,31 +23,36 @@ var Refunds = /** @class */ (function (_super) {
|
|
|
23
23
|
function Refunds() {
|
|
24
24
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
25
25
|
}
|
|
26
|
-
Refunds.prototype.list = function (storeId, chargeId, data, auth
|
|
27
|
-
|
|
26
|
+
Refunds.prototype.list = function (storeId, chargeId, data, auth) {
|
|
27
|
+
var _a;
|
|
28
|
+
this._list = (_a = this._list) !== null && _a !== void 0 ? _a : this._listRoute();
|
|
29
|
+
return this._list(data, auth, { storeId: storeId, chargeId: chargeId });
|
|
28
30
|
};
|
|
29
|
-
Refunds.prototype.create = function (storeId, chargeId, data, auth
|
|
30
|
-
|
|
31
|
+
Refunds.prototype.create = function (storeId, chargeId, data, auth) {
|
|
32
|
+
var _a;
|
|
33
|
+
this._create = (_a = this._create) !== null && _a !== void 0 ? _a : this._createRoute({ requiredParams: Refunds.requiredParams });
|
|
34
|
+
return this._create(data, auth, { storeId: storeId, chargeId: chargeId });
|
|
31
35
|
};
|
|
32
|
-
Refunds.prototype.get = function (storeId, chargeId, id, data, auth
|
|
33
|
-
|
|
36
|
+
Refunds.prototype.get = function (storeId, chargeId, id, data, auth) {
|
|
37
|
+
var _a;
|
|
38
|
+
this._get = (_a = this._get) !== null && _a !== void 0 ? _a : this._getRoute();
|
|
39
|
+
return this._get(data, auth, { storeId: storeId, chargeId: chargeId, id: id });
|
|
34
40
|
};
|
|
35
|
-
Refunds.prototype.update = function (storeId, chargeId, id, data, auth
|
|
36
|
-
|
|
41
|
+
Refunds.prototype.update = function (storeId, chargeId, id, data, auth) {
|
|
42
|
+
var _a;
|
|
43
|
+
this._update = (_a = this._update) !== null && _a !== void 0 ? _a : this._updateRoute();
|
|
44
|
+
return this._update(data, auth, { storeId: storeId, chargeId: chargeId, id: id });
|
|
37
45
|
};
|
|
38
|
-
Refunds.prototype.poll = function (storeId, chargeId, id, data, auth,
|
|
39
|
-
/**
|
|
40
|
-
* Condition for the resource to be successfully loaded. Default to pending status check.
|
|
41
|
-
*/
|
|
42
|
-
cancelCondition, successCondition, iterationCallback) {
|
|
46
|
+
Refunds.prototype.poll = function (storeId, chargeId, id, data, auth, pollParams) {
|
|
43
47
|
var _this = this;
|
|
44
|
-
|
|
45
|
-
var status = _a.status;
|
|
46
|
-
return status !== RefundStatus.PENDING;
|
|
47
|
-
}; }
|
|
48
|
+
var _a;
|
|
48
49
|
var pollData = __assign(__assign({}, data), { polling: true });
|
|
49
50
|
var promise = function () { return _this.get(storeId, chargeId, id, pollData, auth); };
|
|
50
|
-
|
|
51
|
+
var successCondition = (_a = pollParams === null || pollParams === void 0 ? void 0 : pollParams.successCondition) !== null && _a !== void 0 ? _a : (function (_a) {
|
|
52
|
+
var status = _a.status;
|
|
53
|
+
return status !== RefundStatus.PENDING;
|
|
54
|
+
});
|
|
55
|
+
return this.api.longPolling(promise, __assign(__assign({}, pollParams), { successCondition: successCondition }));
|
|
51
56
|
};
|
|
52
57
|
Refunds.requiredParams = ["amount", "currency"];
|
|
53
58
|
Refunds.routeBase = "/stores/:storeId/charges/:chargeId/refunds";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Refunds.js","sourceRoot":"","sources":["../../../src/resources/Refunds.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAOH,OAAO,EAA2C,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Refunds.js","sourceRoot":"","sources":["../../../src/resources/Refunds.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAOH,OAAO,EAA2C,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG1F,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACpB,mCAAmB,CAAA;IACnB,yCAAyB,CAAA;IACzB,iCAAiB,CAAA;IACjB,+BAAe,CAAA;AACnB,CAAC,EALW,YAAY,GAAZ,YAAY,KAAZ,YAAY,QAKvB;AAED,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACpB,uCAAuB,CAAA;IACvB,+BAAe,CAAA;IACf,qDAAqC,CAAA;IACrC,yCAAyB,CAAA;IACzB,iDAAiC,CAAA;AACrC,CAAC,EANW,YAAY,GAAZ,YAAY,KAAZ,YAAY,QAMvB;AA2CD;IAA6B,2BAAY;IAAzC;;IAiEA,CAAC;IA3DG,sBAAI,GAAJ,UACI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AAC;IAC/D,CAAC;IAED,sBAAI,GAAJ,UACI,OAAe,EACf,QAAgB,EAChB,EAAU,EACV,IAAyB,EACzB,IAAiB,EACjB,UAAgD;QANpD,iBAaC;;QALG,IAAM,QAAQ,yBAAQ,IAAI,KAAE,OAAO,EAAE,IAAI,GAAE,CAAC;QAC5C,IAAM,OAAO,GAAkC,cAAM,OAAA,KAAI,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,EAA/C,CAA+C,CAAC;QACrG,IAAM,gBAAgB,GAAG,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,gBAAgB,mCAAI,CAAC,UAAC,EAAU;gBAAR,MAAM,YAAA;YAAO,OAAA,MAAM,KAAK,YAAY,CAAC,OAAO;QAA/B,CAA+B,CAAC,CAAC;QAE3G,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,wBAAO,UAAU,KAAE,gBAAgB,kBAAA,IAAG,CAAC;IAC9E,CAAC;IA/DM,sBAAc,GAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAElD,iBAAS,GAAG,4CAA4C,CAAC;IA8DpE,cAAC;CAAA,AAjED,CAA6B,YAAY,GAiExC;SAjEY,OAAO"}
|
|
@@ -4,10 +4,16 @@
|
|
|
4
4
|
* @module Resources
|
|
5
5
|
*/
|
|
6
6
|
import { EventEmitter } from "events";
|
|
7
|
-
import { AuthParams, HTTPMethod, RestAPI } from "../api/RestAPI.js";
|
|
8
|
-
export declare type DefinedRoute = (data?:
|
|
7
|
+
import { ApiSendOptions, AuthParams, HTTPMethod, RestAPI } from "../api/RestAPI.js";
|
|
8
|
+
export declare type DefinedRoute = (data?: unknown, auth?: AuthParams, pathParams?: Record<string, string>) => Promise<any>;
|
|
9
|
+
export declare type DefineRouteOptions = ApiSendOptions & {
|
|
10
|
+
/**
|
|
11
|
+
* Parameters required for the route to be called.
|
|
12
|
+
*/
|
|
13
|
+
requiredParams?: string[];
|
|
14
|
+
};
|
|
9
15
|
export declare abstract class Resource extends EventEmitter {
|
|
10
16
|
protected api: RestAPI;
|
|
11
17
|
constructor(api: RestAPI);
|
|
12
|
-
protected defineRoute(method: HTTPMethod, path: string,
|
|
18
|
+
protected defineRoute(method: HTTPMethod, path: string, options?: DefineRouteOptions): DefinedRoute;
|
|
13
19
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __assign, __extends } from "tslib";
|
|
1
|
+
import { __assign, __extends, __rest } from "tslib";
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
* @module Resources
|
|
@@ -7,7 +7,7 @@ import { EventEmitter } from "events";
|
|
|
7
7
|
import { fromError } from "../errors/parser.js";
|
|
8
8
|
import { PathParameterError } from "../errors/PathParameterError.js";
|
|
9
9
|
import { RequestParameterError } from "../errors/RequestParameterError.js";
|
|
10
|
-
import { isBlob
|
|
10
|
+
import { isBlob } from "../utils/object.js";
|
|
11
11
|
/**
|
|
12
12
|
* Returns a path with pathParams filled into `:paramName`.
|
|
13
13
|
*
|
|
@@ -64,15 +64,15 @@ var Resource = /** @class */ (function (_super) {
|
|
|
64
64
|
_this.on("removeListener", function (event, listener) { return api.removeListener(event, listener); });
|
|
65
65
|
return _this;
|
|
66
66
|
}
|
|
67
|
-
Resource.prototype.defineRoute = function (method, path,
|
|
68
|
-
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return function route(originalData, callback, auth, pathParams) {
|
|
67
|
+
Resource.prototype.defineRoute = function (method, path, options) {
|
|
68
|
+
var _this = this;
|
|
69
|
+
if (options === void 0) { options = {}; }
|
|
70
|
+
return function (originalData, auth, pathParams) {
|
|
71
|
+
var _a, _b;
|
|
73
72
|
if (pathParams === void 0) { pathParams = {}; }
|
|
73
|
+
var _c = options.requiredParams, requiredParams = _c === void 0 ? [] : _c, sendOptions = __rest(options, ["requiredParams"]);
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
75
|
+
* Sanitizes and ensures that the data is recreated as an object with default prototypes.
|
|
76
76
|
* In rare cases if the data was created with `Object.create(null)` (no prototypes),
|
|
77
77
|
* this will cause the data to be sent as `WebKitFormBoundary` instead of regular JSON object.
|
|
78
78
|
*
|
|
@@ -80,21 +80,19 @@ var Resource = /** @class */ (function (_super) {
|
|
|
80
80
|
*/
|
|
81
81
|
var data = getObjectType(originalData) === "object" ? __assign({}, originalData) : originalData;
|
|
82
82
|
var url = compilePath(path, pathParams);
|
|
83
|
-
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
callback === null || callback === void 0 ? void 0 : callback(err);
|
|
89
|
-
return Promise.reject(err);
|
|
83
|
+
// Validate required path parameters
|
|
84
|
+
var firstMissingPathParam = (_b = (_a = url.match(/:([a-z]+)/gi)) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.replace(":", "");
|
|
85
|
+
if (firstMissingPathParam) {
|
|
86
|
+
var error = fromError(new PathParameterError(firstMissingPathParam));
|
|
87
|
+
return Promise.reject(error);
|
|
90
88
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
// Validate required body parameters
|
|
90
|
+
var firstMissingParam = data ? requiredParams.find(function (key) { return data[key] === undefined; }) : requiredParams[0];
|
|
91
|
+
if (firstMissingParam) {
|
|
92
|
+
var error = fromError(new RequestParameterError(firstMissingParam));
|
|
93
|
+
return Promise.reject(error);
|
|
95
94
|
}
|
|
96
|
-
|
|
97
|
-
return api.send(method, url, data, auth, callback, requireAuth, acceptType, keyFormatter);
|
|
95
|
+
return _this.api.send(method, url, data, auth, sendOptions);
|
|
98
96
|
};
|
|
99
97
|
};
|
|
100
98
|
return Resource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resource.js","sourceRoot":"","sources":["../../../src/resources/Resource.ts"],"names":[],"mappings":";AAAA;;;GAGG;AACH,OAAO,EAAE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GAAG,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YAE1C,oCAAoC;YACpC,IAAM,qBAAqB,GAAG,MAAA,MAAA,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,0CAAG,CAAC,CAAC,0CAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC9E,IAAI,qBAAqB,EAAE;gBACvB,IAAM,KAAK,GAAG,SAAS,CAAC,IAAI,kBAAkB,CAAC,qBAAqB,CAAC,CAAC,CAAC;gBACvE,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;aAChC;YAED,oCAAoC;YACpC,IAAM,iBAAiB,GAAG,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,UAAC,GAAG,IAAK,OAAA,IAAI,CAAC,GAAG,CAAC,KAAK,SAAS,EAAvB,CAAuB,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;YAC3G,IAAI,iBAAiB,EAAE;gBACnB,IAAM,KAAK,GAAG,SAAS,CAAC,IAAI,qBAAqB,CAAC,iBAAiB,CAAC,CAAC,CAAC;gBACtE,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;aAChC;YAED,OAAO,KAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAe,CAAC;QAC7E,CAAC,CAAC;IACN,CAAC;IACL,eAAC;AAAD,CAAC,AApDD,CAAuC,YAAY,GAoDlD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Resources/Stores
|
|
3
3
|
*/
|
|
4
|
-
import { AuthParams,
|
|
4
|
+
import { AuthParams, SendData } from "../api/RestAPI.js";
|
|
5
5
|
import { ConfigurationCreateParams, ConfigurationItem, ConfigurationUpdateParams } from "./common/Configuration.js";
|
|
6
6
|
import { WithMerchantName } from "./common/types.js";
|
|
7
7
|
import { CRUDItemsResponse, CRUDPaginationParams, CRUDResource } from "./CRUDResource.js";
|
|
@@ -31,9 +31,14 @@ export declare type ResponseStores = CRUDItemsResponse<StoreListItem>;
|
|
|
31
31
|
export declare class Stores extends CRUDResource {
|
|
32
32
|
static requiredParams: string[];
|
|
33
33
|
static routeBase: string;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
private _list;
|
|
35
|
+
list(data?: SendData<StoresListParams>, auth?: AuthParams): Promise<ResponseStores>;
|
|
36
|
+
private _create;
|
|
37
|
+
create(data: SendData<StoreCreateParams>, auth?: AuthParams): Promise<ResponseStore>;
|
|
38
|
+
private _get;
|
|
39
|
+
get(id: string, data?: SendData<void>, auth?: AuthParams): Promise<ResponseStore>;
|
|
40
|
+
private _update;
|
|
41
|
+
update(id: string, data?: SendData<StoreUpdateParams>, auth?: AuthParams): Promise<ResponseStore>;
|
|
42
|
+
private _delete;
|
|
43
|
+
delete(id: string, data?: SendData<void>, auth?: AuthParams): Promise<void>;
|
|
39
44
|
}
|
|
@@ -8,20 +8,30 @@ var Stores = /** @class */ (function (_super) {
|
|
|
8
8
|
function Stores() {
|
|
9
9
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
10
10
|
}
|
|
11
|
-
Stores.prototype.list = function (data, auth
|
|
12
|
-
|
|
11
|
+
Stores.prototype.list = function (data, auth) {
|
|
12
|
+
var _a;
|
|
13
|
+
this._list = (_a = this._list) !== null && _a !== void 0 ? _a : this._listRoute();
|
|
14
|
+
return this._list(data, auth);
|
|
13
15
|
};
|
|
14
|
-
Stores.prototype.create = function (data, auth
|
|
15
|
-
|
|
16
|
+
Stores.prototype.create = function (data, auth) {
|
|
17
|
+
var _a;
|
|
18
|
+
this._create = (_a = this._create) !== null && _a !== void 0 ? _a : this._createRoute({ requiredParams: Stores.requiredParams });
|
|
19
|
+
return this._create(data, auth);
|
|
16
20
|
};
|
|
17
|
-
Stores.prototype.get = function (id, data, auth
|
|
18
|
-
|
|
21
|
+
Stores.prototype.get = function (id, data, auth) {
|
|
22
|
+
var _a;
|
|
23
|
+
this._get = (_a = this._get) !== null && _a !== void 0 ? _a : this._getRoute();
|
|
24
|
+
return this._get(data, auth, { id: id });
|
|
19
25
|
};
|
|
20
|
-
Stores.prototype.update = function (id, data, auth
|
|
21
|
-
|
|
26
|
+
Stores.prototype.update = function (id, data, auth) {
|
|
27
|
+
var _a;
|
|
28
|
+
this._update = (_a = this._update) !== null && _a !== void 0 ? _a : this._updateRoute();
|
|
29
|
+
return this._update(data, auth, { id: id });
|
|
22
30
|
};
|
|
23
|
-
Stores.prototype.delete = function (id, data, auth
|
|
24
|
-
|
|
31
|
+
Stores.prototype.delete = function (id, data, auth) {
|
|
32
|
+
var _a;
|
|
33
|
+
this._delete = (_a = this._delete) !== null && _a !== void 0 ? _a : this._deleteRoute();
|
|
34
|
+
return this._delete(data, auth, { id: id });
|
|
25
35
|
};
|
|
26
36
|
Stores.requiredParams = ["name"];
|
|
27
37
|
Stores.routeBase = "/stores";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stores.js","sourceRoot":"","sources":["../../../src/resources/Stores.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAMH,OAAO,EAA2C,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Stores.js","sourceRoot":"","sources":["../../../src/resources/Stores.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAMH,OAAO,EAA2C,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAgC1F;IAA4B,0BAAY;IAAxC;;IAiCA,CAAC;IA5BG,qBAAI,GAAJ,UAAK,IAAiC,EAAE,IAAiB;;QACrD,IAAI,CAAC,KAAK,GAAG,MAAA,IAAI,CAAC,KAAK,mCAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;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
2
2
|
* @module Resources/Subscriptions
|
|
3
3
|
*/
|
|
4
|
-
import { AuthParams,
|
|
4
|
+
import { AuthParams, PollData, PollParams, RestAPI, SendData } from "../api/RestAPI.js";
|
|
5
5
|
import { ProcessingMode } from "./common/enums.js";
|
|
6
6
|
import { Metadata, WithStoreMerchantName } from "./common/types.js";
|
|
7
7
|
import { ChargesListParams, ResponseCharges } from "./Charges.js";
|
|
@@ -163,10 +163,14 @@ export declare type ResponsePayment = ScheduledPaymentItem;
|
|
|
163
163
|
export declare type ResponsePayments = CRUDItemsResponse<SchedulePaymentListItem>;
|
|
164
164
|
export declare class ScheduledPayments extends CRUDResource {
|
|
165
165
|
static routeBase: string;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
private _list;
|
|
167
|
+
list(storeId: string, subscriptionsId: string, data?: SendData<ScheduledPaymentsListParams>, auth?: AuthParams): Promise<ResponsePayments>;
|
|
168
|
+
private _get;
|
|
169
|
+
get(storeId: string, subscriptionsId: string, id: string, data?: SendData<void>, auth?: AuthParams): Promise<ResponsePayment>;
|
|
170
|
+
private _update;
|
|
171
|
+
update(storeId: string, subscriptionsId: string, id: string, data?: SendData<PaymentUpdateParams>, auth?: AuthParams): Promise<ResponsePayment>;
|
|
172
|
+
private _listCharges;
|
|
173
|
+
listCharges(storeId: string, subscriptionsId: string, paymentId: string, data?: SendData<ChargesListParams>, auth?: AuthParams): Promise<ResponseCharges>;
|
|
170
174
|
}
|
|
171
175
|
export declare class Subscriptions extends CRUDResource {
|
|
172
176
|
static requiredParams: string[];
|
|
@@ -175,24 +179,23 @@ export declare class Subscriptions extends CRUDResource {
|
|
|
175
179
|
payments: ScheduledPayments;
|
|
176
180
|
private chargesResource;
|
|
177
181
|
constructor(api: RestAPI);
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
charge?: ResponseCharge;
|
|
192
|
-
}>): Promise<{
|
|
182
|
+
private _list;
|
|
183
|
+
list(data?: SendData<SubscriptionsListParams>, auth?: AuthParams, storeId?: string): Promise<ResponseSubscriptions>;
|
|
184
|
+
create(data: SubscriptionCreateParams, auth?: AuthParams): Promise<ResponseSubscription>;
|
|
185
|
+
private _get;
|
|
186
|
+
get(storeId: string, id: string, data?: SendData<PollData>, auth?: AuthParams): Promise<ResponseSubscription>;
|
|
187
|
+
private _update;
|
|
188
|
+
update(storeId: string, id: string, data?: SendData<SubscriptionUpdateParams>, auth?: AuthParams): Promise<ResponseSubscription>;
|
|
189
|
+
private _delete;
|
|
190
|
+
delete(storeId: string, id: string, data?: SendData<void>, auth?: AuthParams): Promise<void>;
|
|
191
|
+
private _charges;
|
|
192
|
+
charges(storeId: string, id: string, data?: SendData<ChargesListParams>, auth?: AuthParams): Promise<ResponseCharges>;
|
|
193
|
+
poll(storeId: string, id: string, data?: SendData<PollData>, auth?: AuthParams, pollParams?: Partial<PollParams<ResponseSubscription>>): Promise<ResponseSubscription>;
|
|
194
|
+
pollSubscriptionWithFirstCharge(storeId: string, id: string, data?: SendData<PollData>, auth?: AuthParams): Promise<{
|
|
193
195
|
subscription: ResponseSubscription;
|
|
194
196
|
charge?: ResponseCharge;
|
|
195
197
|
}>;
|
|
196
|
-
|
|
198
|
+
private _simulation;
|
|
199
|
+
simulation<InstallmentPlanData extends InstallmentBaseParams>(data: SendData<SubscriptionSimulationParams<InstallmentPlanData>>, auth?: AuthParams, storeId?: string): Promise<SimulationInstallmentPayment[]>;
|
|
197
200
|
}
|
|
198
201
|
export {};
|
|
@@ -38,24 +38,26 @@ var ScheduledPayments = /** @class */ (function (_super) {
|
|
|
38
38
|
function ScheduledPayments() {
|
|
39
39
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
40
40
|
}
|
|
41
|
-
ScheduledPayments.prototype.list = function (storeId, subscriptionsId, data, auth
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
41
|
+
ScheduledPayments.prototype.list = function (storeId, subscriptionsId, data, auth) {
|
|
42
|
+
var _a;
|
|
43
|
+
this._list = (_a = this._list) !== null && _a !== void 0 ? _a : this.defineRoute(HTTPMethod.GET, "".concat(ScheduledPayments.routeBase));
|
|
44
|
+
return this._list(data, auth, { storeId: storeId, subscriptionsId: subscriptionsId });
|
|
46
45
|
};
|
|
47
|
-
ScheduledPayments.prototype.get = function (storeId, subscriptionsId, id, data, auth
|
|
48
|
-
|
|
46
|
+
ScheduledPayments.prototype.get = function (storeId, subscriptionsId, id, data, auth) {
|
|
47
|
+
var _a;
|
|
48
|
+
this._get = (_a = this._get) !== null && _a !== void 0 ? _a : this._getRoute();
|
|
49
|
+
return this._get(data, auth, { storeId: storeId, subscriptionsId: subscriptionsId, id: id });
|
|
49
50
|
};
|
|
50
|
-
ScheduledPayments.prototype.update = function (storeId, subscriptionsId, id, data, auth
|
|
51
|
-
|
|
51
|
+
ScheduledPayments.prototype.update = function (storeId, subscriptionsId, id, data, auth) {
|
|
52
|
+
var _a;
|
|
53
|
+
this._update = (_a = this._update) !== null && _a !== void 0 ? _a : this._updateRoute();
|
|
54
|
+
return this._update(data, auth, { storeId: storeId, subscriptionsId: subscriptionsId, id: id });
|
|
52
55
|
};
|
|
53
|
-
ScheduledPayments.prototype.listCharges = function (storeId, subscriptionsId, paymentId, data, auth
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
56
|
+
ScheduledPayments.prototype.listCharges = function (storeId, subscriptionsId, paymentId, data, auth) {
|
|
57
|
+
var _a;
|
|
58
|
+
this._listCharges =
|
|
59
|
+
(_a = this._listCharges) !== null && _a !== void 0 ? _a : this.defineRoute(HTTPMethod.GET, "".concat(ScheduledPayments.routeBase, "/:paymentId/charges"));
|
|
60
|
+
return this._listCharges(data, auth, { storeId: storeId, subscriptionsId: subscriptionsId, paymentId: paymentId });
|
|
59
61
|
};
|
|
60
62
|
ScheduledPayments.routeBase = "/stores/:storeId/subscriptions/:subscriptionsId/payments";
|
|
61
63
|
return ScheduledPayments;
|
|
@@ -73,45 +75,49 @@ var Subscriptions = /** @class */ (function (_super) {
|
|
|
73
75
|
_this.chargesResource = new Charges(api);
|
|
74
76
|
return _this;
|
|
75
77
|
}
|
|
76
|
-
Subscriptions.prototype.list = function (data, auth,
|
|
77
|
-
|
|
78
|
+
Subscriptions.prototype.list = function (data, auth, storeId) {
|
|
79
|
+
var _a;
|
|
80
|
+
this._list = (_a = this._list) !== null && _a !== void 0 ? _a : this.defineRoute(HTTPMethod.GET, "(/stores/:storeId)/subscriptions");
|
|
81
|
+
return this._list(data, auth, { storeId: storeId });
|
|
78
82
|
};
|
|
79
|
-
Subscriptions.prototype.create = function (data, auth
|
|
83
|
+
Subscriptions.prototype.create = function (data, auth) {
|
|
80
84
|
var _this = this;
|
|
81
85
|
return ignoreDescriptor(function (updatedData) {
|
|
82
|
-
return _this.defineRoute(HTTPMethod.POST, "/subscriptions", Subscriptions.requiredParams)(updatedData,
|
|
86
|
+
return _this.defineRoute(HTTPMethod.POST, "/subscriptions", { requiredParams: Subscriptions.requiredParams })(updatedData, auth);
|
|
83
87
|
}, data);
|
|
84
88
|
};
|
|
85
|
-
Subscriptions.prototype.get = function (storeId, id, data, auth
|
|
86
|
-
|
|
89
|
+
Subscriptions.prototype.get = function (storeId, id, data, auth) {
|
|
90
|
+
var _a;
|
|
91
|
+
this._get = (_a = this._get) !== null && _a !== void 0 ? _a : this._getRoute();
|
|
92
|
+
return this._get(data, auth, { storeId: storeId, id: id });
|
|
87
93
|
};
|
|
88
|
-
Subscriptions.prototype.update = function (storeId, id, data, auth
|
|
89
|
-
|
|
94
|
+
Subscriptions.prototype.update = function (storeId, id, data, auth) {
|
|
95
|
+
var _a;
|
|
96
|
+
this._update = (_a = this._update) !== null && _a !== void 0 ? _a : this._updateRoute();
|
|
97
|
+
return this._update(data, auth, { storeId: storeId, id: id });
|
|
90
98
|
};
|
|
91
|
-
Subscriptions.prototype.delete = function (storeId, id, data, auth
|
|
92
|
-
|
|
99
|
+
Subscriptions.prototype.delete = function (storeId, id, data, auth) {
|
|
100
|
+
var _a;
|
|
101
|
+
this._delete = (_a = this._delete) !== null && _a !== void 0 ? _a : this._deleteRoute();
|
|
102
|
+
return this._delete(data, auth, { storeId: storeId, id: id });
|
|
93
103
|
};
|
|
94
|
-
Subscriptions.prototype.charges = function (storeId, id, data, auth
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
});
|
|
104
|
+
Subscriptions.prototype.charges = function (storeId, id, data, auth) {
|
|
105
|
+
var _a;
|
|
106
|
+
this._charges = (_a = this._charges) !== null && _a !== void 0 ? _a : this.defineRoute(HTTPMethod.GET, "".concat(Subscriptions.routeBase, "/:id/charges"));
|
|
107
|
+
return this._charges(data, auth, { storeId: storeId, id: id });
|
|
99
108
|
};
|
|
100
|
-
Subscriptions.prototype.poll = function (storeId, id, data, auth,
|
|
101
|
-
/**
|
|
102
|
-
* Condition for the resource to be successfully loaded. Default to pending status check.
|
|
103
|
-
*/
|
|
104
|
-
cancelCondition, successCondition, iterationCallback) {
|
|
109
|
+
Subscriptions.prototype.poll = function (storeId, id, data, auth, pollParams) {
|
|
105
110
|
var _this = this;
|
|
106
|
-
|
|
107
|
-
var status = _a.status;
|
|
108
|
-
return status !== SubscriptionStatus.UNVERIFIED;
|
|
109
|
-
}; }
|
|
111
|
+
var _a;
|
|
110
112
|
var pollData = __assign(__assign({}, data), { polling: true });
|
|
111
113
|
var promise = function () { return _this.get(storeId, id, pollData, auth); };
|
|
112
|
-
|
|
114
|
+
var successCondition = (_a = pollParams === null || pollParams === void 0 ? void 0 : pollParams.successCondition) !== null && _a !== void 0 ? _a : (function (_a) {
|
|
115
|
+
var status = _a.status;
|
|
116
|
+
return status !== SubscriptionStatus.UNVERIFIED;
|
|
117
|
+
});
|
|
118
|
+
return this.api.longPolling(promise, __assign(__assign({}, pollParams), { successCondition: successCondition }));
|
|
113
119
|
};
|
|
114
|
-
Subscriptions.prototype.pollSubscriptionWithFirstCharge = function (storeId, id, data, auth
|
|
120
|
+
Subscriptions.prototype.pollSubscriptionWithFirstCharge = function (storeId, id, data, auth) {
|
|
115
121
|
return __awaiter(this, void 0, void 0, function () {
|
|
116
122
|
var subscription, charge, _a;
|
|
117
123
|
var _this = this;
|
|
@@ -122,7 +128,9 @@ var Subscriptions = /** @class */ (function (_super) {
|
|
|
122
128
|
subscription = _b.sent();
|
|
123
129
|
if (!hasImmediateCharge(subscription)) return [3 /*break*/, 3];
|
|
124
130
|
return [4 /*yield*/, this.api
|
|
125
|
-
.longPolling(function () { return _this.charges(storeId, id); },
|
|
131
|
+
.longPolling(function () { return _this.charges(storeId, id, undefined, auth); }, {
|
|
132
|
+
successCondition: function (charges) { return !!charges.items.length; },
|
|
133
|
+
})
|
|
126
134
|
.then(function (_a) {
|
|
127
135
|
var charges = _a.items;
|
|
128
136
|
return _this.chargesResource.poll(charges[0].storeId, charges[0].id, data, auth);
|
|
@@ -135,14 +143,18 @@ var Subscriptions = /** @class */ (function (_super) {
|
|
|
135
143
|
_b.label = 4;
|
|
136
144
|
case 4:
|
|
137
145
|
charge = _a;
|
|
138
|
-
callback === null || callback === void 0 ? void 0 : callback({ subscription: subscription, charge: charge });
|
|
139
146
|
return [2 /*return*/, { subscription: subscription, charge: charge }];
|
|
140
147
|
}
|
|
141
148
|
});
|
|
142
149
|
});
|
|
143
150
|
};
|
|
144
|
-
Subscriptions.prototype.simulation = function (data, auth,
|
|
145
|
-
|
|
151
|
+
Subscriptions.prototype.simulation = function (data, auth, storeId) {
|
|
152
|
+
var _a;
|
|
153
|
+
this._simulation =
|
|
154
|
+
(_a = this._simulation) !== null && _a !== void 0 ? _a : this.defineRoute(HTTPMethod.POST, "(/stores/:storeId)/subscriptions/simulate_plan", {
|
|
155
|
+
requiredParams: Subscriptions.requiredSimulationParams,
|
|
156
|
+
});
|
|
157
|
+
return this._simulation(data, auth, { storeId: storeId });
|
|
146
158
|
};
|
|
147
159
|
Subscriptions.requiredParams = ["transactionTokenId", "amount", "currency", "period"];
|
|
148
160
|
Subscriptions.requiredSimulationParams = ["installmentPlan", "paymentType", "currency", "period"];
|