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.
Files changed (179) hide show
  1. package/dist/cjs/api/RestAPI.d.ts +44 -39
  2. package/dist/cjs/api/RestAPI.js +41 -58
  3. package/dist/cjs/api/RestAPI.js.map +1 -1
  4. package/dist/cjs/api/utils/payload.js +2 -2
  5. package/dist/cjs/api/utils/payload.js.map +1 -1
  6. package/dist/cjs/common/constants.d.ts +1 -0
  7. package/dist/cjs/common/constants.js +2 -1
  8. package/dist/cjs/common/constants.js.map +1 -1
  9. package/dist/cjs/errors/APIError.d.ts +7 -5
  10. package/dist/cjs/errors/APIError.js.map +1 -1
  11. package/dist/cjs/resources/BankAccounts.d.ts +13 -7
  12. package/dist/cjs/resources/BankAccounts.js +24 -12
  13. package/dist/cjs/resources/BankAccounts.js.map +1 -1
  14. package/dist/cjs/resources/CRUDResource.d.ts +6 -6
  15. package/dist/cjs/resources/CRUDResource.js +10 -10
  16. package/dist/cjs/resources/CRUDResource.js.map +1 -1
  17. package/dist/cjs/resources/Cancels.d.ts +8 -9
  18. package/dist/cjs/resources/Cancels.js +19 -16
  19. package/dist/cjs/resources/Cancels.js.map +1 -1
  20. package/dist/cjs/resources/Captures.d.ts +9 -4
  21. package/dist/cjs/resources/Captures.js +4 -2
  22. package/dist/cjs/resources/Captures.js.map +1 -1
  23. package/dist/cjs/resources/Charges.d.ts +9 -10
  24. package/dist/cjs/resources/Charges.js +22 -18
  25. package/dist/cjs/resources/Charges.js.map +1 -1
  26. package/dist/cjs/resources/CheckoutInfo.d.ts +3 -2
  27. package/dist/cjs/resources/CheckoutInfo.js +4 -2
  28. package/dist/cjs/resources/CheckoutInfo.js.map +1 -1
  29. package/dist/cjs/resources/ECFormLinks.d.ts +3 -2
  30. package/dist/cjs/resources/ECFormLinks.js +4 -2
  31. package/dist/cjs/resources/ECFormLinks.js.map +1 -1
  32. package/dist/cjs/resources/ECForms.d.ts +4 -2
  33. package/dist/cjs/resources/ECForms.js +4 -2
  34. package/dist/cjs/resources/ECForms.js.map +1 -1
  35. package/dist/cjs/resources/ECInfo.d.ts +3 -2
  36. package/dist/cjs/resources/ECInfo.js +4 -2
  37. package/dist/cjs/resources/ECInfo.js.map +1 -1
  38. package/dist/cjs/resources/Emails.d.ts +3 -2
  39. package/dist/cjs/resources/Emails.js +4 -2
  40. package/dist/cjs/resources/Emails.js.map +1 -1
  41. package/dist/cjs/resources/ExchangeRates.d.ts +3 -2
  42. package/dist/cjs/resources/ExchangeRates.js +4 -2
  43. package/dist/cjs/resources/ExchangeRates.js.map +1 -1
  44. package/dist/cjs/resources/Ledgers.d.ts +5 -3
  45. package/dist/cjs/resources/Ledgers.js +8 -4
  46. package/dist/cjs/resources/Ledgers.js.map +1 -1
  47. package/dist/cjs/resources/Merchants.d.ts +3 -2
  48. package/dist/cjs/resources/Merchants.js +4 -2
  49. package/dist/cjs/resources/Merchants.js.map +1 -1
  50. package/dist/cjs/resources/Platforms.d.ts +3 -2
  51. package/dist/cjs/resources/Platforms.js +5 -2
  52. package/dist/cjs/resources/Platforms.js.map +1 -1
  53. package/dist/cjs/resources/Products.d.ts +3 -2
  54. package/dist/cjs/resources/Products.js +4 -2
  55. package/dist/cjs/resources/Products.js.map +1 -1
  56. package/dist/cjs/resources/Refunds.d.ts +10 -10
  57. package/dist/cjs/resources/Refunds.js +23 -18
  58. package/dist/cjs/resources/Refunds.js.map +1 -1
  59. package/dist/cjs/resources/Resource.d.ts +9 -3
  60. package/dist/cjs/resources/Resource.js +18 -20
  61. package/dist/cjs/resources/Resource.js.map +1 -1
  62. package/dist/cjs/resources/Stores.d.ts +11 -6
  63. package/dist/cjs/resources/Stores.js +20 -10
  64. package/dist/cjs/resources/Stores.js.map +1 -1
  65. package/dist/cjs/resources/Subscriptions.d.ts +24 -21
  66. package/dist/cjs/resources/Subscriptions.js +57 -45
  67. package/dist/cjs/resources/Subscriptions.js.map +1 -1
  68. package/dist/cjs/resources/TemporaryTokenAlias.d.ts +8 -6
  69. package/dist/cjs/resources/TemporaryTokenAlias.js +18 -6
  70. package/dist/cjs/resources/TemporaryTokenAlias.js.map +1 -1
  71. package/dist/cjs/resources/TransactionTokens.d.ts +12 -7
  72. package/dist/cjs/resources/TransactionTokens.js +22 -15
  73. package/dist/cjs/resources/TransactionTokens.js.map +1 -1
  74. package/dist/cjs/resources/Transfers.d.ts +7 -4
  75. package/dist/cjs/resources/Transfers.js +13 -8
  76. package/dist/cjs/resources/Transfers.js.map +1 -1
  77. package/dist/cjs/resources/Verification.d.ts +7 -4
  78. package/dist/cjs/resources/Verification.js +12 -6
  79. package/dist/cjs/resources/Verification.js.map +1 -1
  80. package/dist/cjs/resources/WebHooks.d.ts +11 -6
  81. package/dist/cjs/resources/WebHooks.js +20 -10
  82. package/dist/cjs/resources/WebHooks.js.map +1 -1
  83. package/dist/cjs/resources/common/ignoreDescriptor.d.ts +2 -2
  84. package/dist/cjs/resources/common/ignoreDescriptor.js +18 -20
  85. package/dist/cjs/resources/common/ignoreDescriptor.js.map +1 -1
  86. package/dist/cjs/utils/fetch.js.map +1 -1
  87. package/dist/cjs/utils/object.d.ts +0 -4
  88. package/dist/cjs/utils/object.js +1 -30
  89. package/dist/cjs/utils/object.js.map +1 -1
  90. package/dist/esm/api/RestAPI.d.ts +44 -39
  91. package/dist/esm/api/RestAPI.js +43 -60
  92. package/dist/esm/api/RestAPI.js.map +1 -1
  93. package/dist/esm/api/utils/payload.js +2 -2
  94. package/dist/esm/api/utils/payload.js.map +1 -1
  95. package/dist/esm/common/constants.d.ts +1 -0
  96. package/dist/esm/common/constants.js +1 -0
  97. package/dist/esm/common/constants.js.map +1 -1
  98. package/dist/esm/errors/APIError.d.ts +7 -5
  99. package/dist/esm/errors/APIError.js.map +1 -1
  100. package/dist/esm/resources/BankAccounts.d.ts +13 -7
  101. package/dist/esm/resources/BankAccounts.js +24 -12
  102. package/dist/esm/resources/BankAccounts.js.map +1 -1
  103. package/dist/esm/resources/CRUDResource.d.ts +6 -6
  104. package/dist/esm/resources/CRUDResource.js +10 -10
  105. package/dist/esm/resources/CRUDResource.js.map +1 -1
  106. package/dist/esm/resources/Cancels.d.ts +8 -9
  107. package/dist/esm/resources/Cancels.js +19 -16
  108. package/dist/esm/resources/Cancels.js.map +1 -1
  109. package/dist/esm/resources/Captures.d.ts +9 -4
  110. package/dist/esm/resources/Captures.js +4 -2
  111. package/dist/esm/resources/Captures.js.map +1 -1
  112. package/dist/esm/resources/Charges.d.ts +9 -10
  113. package/dist/esm/resources/Charges.js +22 -18
  114. package/dist/esm/resources/Charges.js.map +1 -1
  115. package/dist/esm/resources/CheckoutInfo.d.ts +3 -2
  116. package/dist/esm/resources/CheckoutInfo.js +4 -2
  117. package/dist/esm/resources/CheckoutInfo.js.map +1 -1
  118. package/dist/esm/resources/ECFormLinks.d.ts +3 -2
  119. package/dist/esm/resources/ECFormLinks.js +4 -2
  120. package/dist/esm/resources/ECFormLinks.js.map +1 -1
  121. package/dist/esm/resources/ECForms.d.ts +4 -2
  122. package/dist/esm/resources/ECForms.js +4 -2
  123. package/dist/esm/resources/ECForms.js.map +1 -1
  124. package/dist/esm/resources/ECInfo.d.ts +3 -2
  125. package/dist/esm/resources/ECInfo.js +4 -2
  126. package/dist/esm/resources/ECInfo.js.map +1 -1
  127. package/dist/esm/resources/Emails.d.ts +3 -2
  128. package/dist/esm/resources/Emails.js +4 -2
  129. package/dist/esm/resources/Emails.js.map +1 -1
  130. package/dist/esm/resources/ExchangeRates.d.ts +3 -2
  131. package/dist/esm/resources/ExchangeRates.js +4 -2
  132. package/dist/esm/resources/ExchangeRates.js.map +1 -1
  133. package/dist/esm/resources/Ledgers.d.ts +5 -3
  134. package/dist/esm/resources/Ledgers.js +8 -4
  135. package/dist/esm/resources/Ledgers.js.map +1 -1
  136. package/dist/esm/resources/Merchants.d.ts +3 -2
  137. package/dist/esm/resources/Merchants.js +4 -2
  138. package/dist/esm/resources/Merchants.js.map +1 -1
  139. package/dist/esm/resources/Platforms.d.ts +3 -2
  140. package/dist/esm/resources/Platforms.js +5 -2
  141. package/dist/esm/resources/Platforms.js.map +1 -1
  142. package/dist/esm/resources/Products.d.ts +3 -2
  143. package/dist/esm/resources/Products.js +4 -2
  144. package/dist/esm/resources/Products.js.map +1 -1
  145. package/dist/esm/resources/Refunds.d.ts +10 -10
  146. package/dist/esm/resources/Refunds.js +23 -18
  147. package/dist/esm/resources/Refunds.js.map +1 -1
  148. package/dist/esm/resources/Resource.d.ts +9 -3
  149. package/dist/esm/resources/Resource.js +20 -22
  150. package/dist/esm/resources/Resource.js.map +1 -1
  151. package/dist/esm/resources/Stores.d.ts +11 -6
  152. package/dist/esm/resources/Stores.js +20 -10
  153. package/dist/esm/resources/Stores.js.map +1 -1
  154. package/dist/esm/resources/Subscriptions.d.ts +24 -21
  155. package/dist/esm/resources/Subscriptions.js +57 -45
  156. package/dist/esm/resources/Subscriptions.js.map +1 -1
  157. package/dist/esm/resources/TemporaryTokenAlias.d.ts +8 -6
  158. package/dist/esm/resources/TemporaryTokenAlias.js +18 -6
  159. package/dist/esm/resources/TemporaryTokenAlias.js.map +1 -1
  160. package/dist/esm/resources/TransactionTokens.d.ts +12 -7
  161. package/dist/esm/resources/TransactionTokens.js +22 -15
  162. package/dist/esm/resources/TransactionTokens.js.map +1 -1
  163. package/dist/esm/resources/Transfers.d.ts +7 -4
  164. package/dist/esm/resources/Transfers.js +13 -8
  165. package/dist/esm/resources/Transfers.js.map +1 -1
  166. package/dist/esm/resources/Verification.d.ts +7 -4
  167. package/dist/esm/resources/Verification.js +12 -6
  168. package/dist/esm/resources/Verification.js.map +1 -1
  169. package/dist/esm/resources/WebHooks.d.ts +11 -6
  170. package/dist/esm/resources/WebHooks.js +20 -10
  171. package/dist/esm/resources/WebHooks.js.map +1 -1
  172. package/dist/esm/resources/common/ignoreDescriptor.d.ts +2 -2
  173. package/dist/esm/resources/common/ignoreDescriptor.js +18 -20
  174. package/dist/esm/resources/common/ignoreDescriptor.js.map +1 -1
  175. package/dist/esm/utils/fetch.js.map +1 -1
  176. package/dist/esm/utils/object.d.ts +0 -4
  177. package/dist/esm/utils/object.js +1 -29
  178. package/dist/esm/utils/object.js.map +1 -1
  179. 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, callback) {
13
- return this.defineRoute(HTTPMethod.GET, "/platform", undefined, false)(data, callback, auth);
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,EAA8B,MAAM,mBAAmB,CAAC;AAKvF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAajD;IAA+B,6BAAY;IAA3C;;IAQA,CAAC;IAPG,oCAAgB,GAAhB,UACI,IAAqB,EACrB,IAAiB,EACjB,QAA0D;QAE1D,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IACjG,CAAC;IACL,gBAAC;AAAD,CAAC,AARD,CAA+B,YAAY,GAQ1C"}
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, ResponseCallback, SendData } from "../api/RestAPI.js";
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
- get(id: string, data?: SendData<void>, auth?: AuthParams, callback?: ResponseCallback<ResponseProduct>): Promise<ResponseProduct>;
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, callback) {
9
- return this._getRoute()(data, callback, auth, { id: id });
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;AAwBjD;IAA8B,4BAAY;IAA1C;;IAWA,CAAC;IARG,sBAAG,GAAH,UACI,EAAU,EACV,IAAqB,EACrB,IAAiB,EACjB,QAA4C;QAE5C,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,IAAA,EAAE,CAAC,CAAC;IAC1D,CAAC;IATM,kBAAS,GAAG,oBAAoB,CAAC;IAU5C,eAAC;CAAA,AAXD,CAA8B,YAAY,GAWzC;SAXY,QAAQ"}
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, ResponseCallback, SendData } from "../api/RestAPI.js";
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
- list(storeId: string, chargeId: string, data?: SendData<RefundsListParams>, auth?: AuthParams, callback?: ResponseCallback<ResponseRefunds>): Promise<ResponseRefunds>;
59
- create(storeId: string, chargeId: string, data: SendData<RefundCreateParams>, auth?: AuthParams, callback?: ResponseCallback<ResponseRefund>): Promise<ResponseRefund>;
60
- get(storeId: string, chargeId: string, id: string, data?: SendData<PollParams>, auth?: AuthParams, callback?: ResponseCallback<ResponseRefund>): Promise<ResponseRefund>;
61
- update(storeId: string, chargeId: string, id: string, data?: SendData<RefundUpdateParams>, auth?: AuthParams, callback?: ResponseCallback<ResponseRefund>): Promise<ResponseRefund>;
62
- poll(storeId: string, chargeId: string, id: string, data?: SendData<PollParams>, auth?: AuthParams, callback?: ResponseCallback<ResponseRefund>,
63
- /**
64
- * Condition for the resource to be successfully loaded. Default to pending status check.
65
- */
66
- cancelCondition?: (response: ResponseRefund) => boolean, successCondition?: ({ status }: ResponseRefund) => boolean, iterationCallback?: (response: ResponseRefund) => void): Promise<ResponseRefund>;
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, callback) {
27
- return this._listRoute()(data, callback, auth, { storeId: storeId, chargeId: chargeId });
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, callback) {
30
- return this._createRoute(Refunds.requiredParams)(data, callback, auth, { storeId: storeId, chargeId: chargeId });
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, callback) {
33
- return this._getRoute()(data, callback, auth, { storeId: storeId, chargeId: chargeId, id: id });
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, callback) {
36
- return this._updateRoute()(data, callback, auth, { storeId: storeId, chargeId: chargeId, id: id });
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, callback,
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
- if (successCondition === void 0) { successCondition = function (_a) {
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
- return this.api.longPolling(promise, successCondition, cancelCondition, callback, undefined, undefined, iterationCallback);
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;AAE1F,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;;IA2EA,CAAC;IAtEG,sBAAI,GAAJ,UACI,OAAe,EACf,QAAgB,EAChB,IAAkC,EAClC,IAAiB,EACjB,QAA4C;QAE5C,OAAO,IAAI,C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AAE,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?: any, callback?: any, auth?: AuthParams, pathParams?: Record<string, string>) => Promise<any>;
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, required?: string[], requireAuth?: boolean, acceptType?: string, keyFormatter?: (key: string) => string): DefinedRoute;
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, missingKeys, toSnakeCase } from "../utils/object.js";
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, required, requireAuth, acceptType, keyFormatter) {
68
- if (required === void 0) { required = []; }
69
- if (requireAuth === void 0) { requireAuth = true; }
70
- if (keyFormatter === void 0) { keyFormatter = toSnakeCase; }
71
- var api = this.api;
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
- * Sanitises and ensures that the data is recreated as an object with default prototypes.
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
- var missingPathParams = (url.match(/:([a-z]+)/gi) || []).map(function (m) { return m.replace(":", ""); });
84
- var missingParams = missingKeys(data, required);
85
- var err;
86
- if (missingPathParams.length > 0) {
87
- err = fromError(new PathParameterError(missingPathParams[0]));
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
- if (missingParams.length > 0) {
92
- err = fromError(new RequestParameterError(missingParams[0]));
93
- callback === null || callback === void 0 ? void 0 : callback(err);
94
- return Promise.reject(err);
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
- // TODO: Have a look as this cast, the response can be other objects such as string, Blob or FormData
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,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAStE;;;;;;;;;;;;;;;;;;;GA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C;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, ResponseCallback, SendData } from "../api/RestAPI.js";
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
- list(data?: SendData<StoresListParams>, auth?: AuthParams, callback?: ResponseCallback<ResponseStores>): Promise<ResponseStores>;
35
- create(data: SendData<StoreCreateParams>, auth?: AuthParams, callback?: ResponseCallback<ResponseStore>): Promise<ResponseStore>;
36
- get(id: string, data?: SendData<void>, auth?: AuthParams, callback?: ResponseCallback<ResponseStore>): Promise<ResponseStore>;
37
- update(id: string, data?: SendData<StoreUpdateParams>, auth?: AuthParams, callback?: ResponseCallback<ResponseStore>): Promise<ResponseStore>;
38
- delete(id: string, data?: SendData<void>, auth?: AuthParams, callback?: ResponseCallback<void>): Promise<void>;
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, callback) {
12
- return this._listRoute()(data, callback, auth);
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, callback) {
15
- return this._createRoute(Stores.requiredParams)(data, callback, auth);
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, callback) {
18
- return this._getRoute()(data, callback, auth, { id: id });
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, callback) {
21
- return this._updateRoute()(data, callback, auth, { id: id });
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, callback) {
24
- return this._deleteRoute()(data, callback, auth, { id: id });
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;AA+B1F;IAA4B,0BAAY;IAAxC;;IA0CA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AAE,IAAI,EAAE,EAAE,EAAE,IAAA,EAAE,CAAC,CAAC;IAC5C,CAAC;IA/BM,qBAAc,GAAa,CAAC,MAAM,CAAC,CAAC;IACpC,gBAAS,GAAG,SAAS,CAAC;IA+BjC,aAAC;CAAA,AAjCD,CAA4B,YAAY,GAiCvC;SAjCY,MAAM"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @module Resources/Subscriptions
3
3
  */
4
- import { AuthParams, PollParams, ResponseCallback, RestAPI, SendData } from "../api/RestAPI.js";
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
- list(storeId: string, subscriptionsId: string, data?: SendData<ScheduledPaymentsListParams>, auth?: AuthParams, callback?: ResponseCallback<ResponsePayments>): Promise<ResponsePayments>;
167
- get(storeId: string, subscriptionsId: string, id: string, data?: SendData<void>, auth?: AuthParams, callback?: ResponseCallback<ResponsePayment>): Promise<ResponsePayment>;
168
- update(storeId: string, subscriptionsId: string, id: string, data?: SendData<PaymentUpdateParams>, auth?: AuthParams, callback?: ResponseCallback<ResponsePayment>): Promise<ResponsePayment>;
169
- listCharges(storeId: string, subscriptionsId: string, paymentId: string, data?: SendData<ChargesListParams>, auth?: AuthParams, callback?: ResponseCallback<ResponseCharges>): Promise<ResponseCharges>;
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
- list(data?: SendData<SubscriptionsListParams>, auth?: AuthParams, callback?: ResponseCallback<ResponseSubscriptions>, storeId?: string): Promise<ResponseSubscriptions>;
179
- create(data: SubscriptionCreateParams, auth?: AuthParams, callback?: ResponseCallback<ResponseSubscription>): Promise<ResponseSubscription>;
180
- get(storeId: string, id: string, data?: SendData<PollParams>, auth?: AuthParams, callback?: ResponseCallback<ResponseSubscription>): Promise<ResponseSubscription>;
181
- update(storeId: string, id: string, data?: SendData<SubscriptionUpdateParams>, auth?: AuthParams, callback?: ResponseCallback<ResponseSubscription>): Promise<ResponseSubscription>;
182
- delete(storeId: string, id: string, data?: SendData<void>, auth?: AuthParams, callback?: ResponseCallback<void>): Promise<void>;
183
- charges(storeId: string, id: string, data?: SendData<ChargesListParams>, auth?: AuthParams, callback?: ResponseCallback<ResponseCharges>): Promise<ResponseCharges>;
184
- poll(storeId: string, id: string, data?: SendData<PollParams>, auth?: AuthParams, callback?: ResponseCallback<ResponseSubscription>,
185
- /**
186
- * Condition for the resource to be successfully loaded. Default to pending status check.
187
- */
188
- cancelCondition?: (response: ResponseSubscription) => boolean, successCondition?: ({ status }: ResponseSubscription) => boolean, iterationCallback?: (response: ResponseSubscription) => void): Promise<ResponseSubscription>;
189
- pollSubscriptionWithFirstCharge(storeId: string, id: string, data?: SendData<PollParams>, auth?: AuthParams, callback?: ResponseCallback<{
190
- subscription: ResponseSubscription;
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
- simulation<InstallmentPlanData extends InstallmentBaseParams>(data: SendData<SubscriptionSimulationParams<InstallmentPlanData>>, auth?: AuthParams, callback?: ResponseCallback<SimulationInstallmentPayment[]>, storeId?: string): Promise<SimulationInstallmentPayment[]>;
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, callback) {
42
- return this.defineRoute(HTTPMethod.GET, "".concat(ScheduledPayments.routeBase))(data, callback, auth, {
43
- storeId: storeId,
44
- subscriptionsId: subscriptionsId,
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, callback) {
48
- return this._getRoute()(data, callback, auth, { storeId: storeId, subscriptionsId: subscriptionsId, id: id });
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, callback) {
51
- return this._updateRoute()(data, callback, auth, { storeId: storeId, subscriptionsId: subscriptionsId, id: id });
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, callback) {
54
- return this.defineRoute(HTTPMethod.GET, "".concat(ScheduledPayments.routeBase, "/:paymentId/charges"))(data, callback, auth, {
55
- storeId: storeId,
56
- subscriptionsId: subscriptionsId,
57
- paymentId: paymentId,
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, callback, storeId) {
77
- return this.defineRoute(HTTPMethod.GET, "(/stores/:storeId)/subscriptions")(data, callback, auth, { storeId: storeId });
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, callback) {
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, callback, auth);
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, callback) {
86
- return this._getRoute()(data, callback, auth, { storeId: storeId, id: id });
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, callback) {
89
- return this._updateRoute()(data, callback, auth, { storeId: storeId, id: id });
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, callback) {
92
- return this._deleteRoute()(data, callback, auth, { storeId: storeId, id: id });
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, callback) {
95
- return this.defineRoute(HTTPMethod.GET, "".concat(Subscriptions.routeBase, "/:id/charges"))(data, callback, auth, {
96
- storeId: storeId,
97
- id: id,
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, callback,
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
- if (successCondition === void 0) { successCondition = function (_a) {
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
- return this.api.longPolling(promise, successCondition, cancelCondition, callback, undefined, undefined, iterationCallback);
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, callback) {
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); }, function (charges) { return !!charges.items.length; })
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, callback, storeId) {
145
- return this.defineRoute(HTTPMethod.POST, "(/stores/:storeId)/subscriptions/simulate_plan", Subscriptions.requiredSimulationParams)(data, callback, auth, { storeId: storeId });
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"];