@payabli/sdk-node 0.0.116 → 0.0.117

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 (230) hide show
  1. package/README.md +24 -7
  2. package/dist/cjs/BaseClient.d.ts +10 -1
  3. package/dist/cjs/BaseClient.js +57 -0
  4. package/dist/cjs/Client.d.ts +87 -86
  5. package/dist/cjs/Client.js +31 -72
  6. package/dist/cjs/api/resources/bill/client/Client.d.ts +33 -33
  7. package/dist/cjs/api/resources/bill/client/Client.js +69 -216
  8. package/dist/cjs/api/resources/boarding/client/Client.d.ts +27 -27
  9. package/dist/cjs/api/resources/boarding/client/Client.js +51 -198
  10. package/dist/cjs/api/resources/chargeBacks/client/Client.d.ts +17 -15
  11. package/dist/cjs/api/resources/chargeBacks/client/Client.js +38 -79
  12. package/dist/cjs/api/resources/checkCapture/client/Client.d.ts +7 -7
  13. package/dist/cjs/api/resources/checkCapture/client/Client.js +11 -28
  14. package/dist/cjs/api/resources/cloud/client/Client.d.ts +17 -17
  15. package/dist/cjs/api/resources/cloud/client/Client.js +33 -89
  16. package/dist/cjs/api/resources/customer/client/Client.d.ts +17 -17
  17. package/dist/cjs/api/resources/customer/client/Client.js +31 -113
  18. package/dist/cjs/api/resources/export/client/Client.d.ts +93 -89
  19. package/dist/cjs/api/resources/export/client/Client.js +205 -582
  20. package/dist/cjs/api/resources/hostedPaymentPages/client/Client.d.ts +11 -11
  21. package/dist/cjs/api/resources/hostedPaymentPages/client/Client.js +19 -62
  22. package/dist/cjs/api/resources/import/client/Client.d.ts +11 -11
  23. package/dist/cjs/api/resources/import/client/Client.js +19 -62
  24. package/dist/cjs/api/resources/invoice/client/Client.d.ts +31 -31
  25. package/dist/cjs/api/resources/invoice/client/Client.js +62 -209
  26. package/dist/cjs/api/resources/lineItem/client/Client.d.ts +15 -15
  27. package/dist/cjs/api/resources/lineItem/client/Client.js +27 -96
  28. package/dist/cjs/api/resources/moneyIn/client/Client.d.ts +39 -39
  29. package/dist/cjs/api/resources/moneyIn/client/Client.js +79 -249
  30. package/dist/cjs/api/resources/moneyOut/client/Client.d.ts +43 -26
  31. package/dist/cjs/api/resources/moneyOut/client/Client.js +105 -168
  32. package/dist/cjs/api/resources/moneyOut/client/requests/MoneyOutTypesRequestOutAuthorize.d.ts +2 -1
  33. package/dist/cjs/api/resources/moneyOutTypes/types/AuthorizePayoutBody.d.ts +3 -1
  34. package/dist/cjs/api/resources/notification/client/Client.d.ts +16 -16
  35. package/dist/cjs/api/resources/notification/client/Client.js +32 -101
  36. package/dist/cjs/api/resources/notificationlogs/client/Client.d.ts +13 -13
  37. package/dist/cjs/api/resources/notificationlogs/client/Client.js +23 -79
  38. package/dist/cjs/api/resources/ocr/client/Client.d.ts +13 -9
  39. package/dist/cjs/api/resources/ocr/client/Client.js +19 -45
  40. package/dist/cjs/api/resources/organization/client/Client.d.ts +19 -19
  41. package/dist/cjs/api/resources/organization/client/Client.js +35 -130
  42. package/dist/cjs/api/resources/paymentLink/client/Client.d.ts +23 -23
  43. package/dist/cjs/api/resources/paymentLink/client/Client.js +43 -164
  44. package/dist/cjs/api/resources/paymentMethodDomain/client/Client.d.ts +19 -19
  45. package/dist/cjs/api/resources/paymentMethodDomain/client/Client.js +35 -130
  46. package/dist/cjs/api/resources/paypoint/client/Client.d.ts +22 -22
  47. package/dist/cjs/api/resources/paypoint/client/Client.js +44 -152
  48. package/dist/cjs/api/resources/query/client/Client.d.ts +71 -71
  49. package/dist/cjs/api/resources/query/client/Client.js +137 -572
  50. package/dist/cjs/api/resources/query/client/requests/ListPayoutOrgRequest.d.ts +1 -0
  51. package/dist/cjs/api/resources/query/client/requests/ListPayoutRequest.d.ts +1 -0
  52. package/dist/cjs/api/resources/query/client/requests/ListTransactionsRequest.d.ts +1 -0
  53. package/dist/cjs/api/resources/statistic/client/Client.d.ts +50 -50
  54. package/dist/cjs/api/resources/statistic/client/Client.js +80 -133
  55. package/dist/cjs/api/resources/statistic/client/requests/BasicStatsRequest.d.ts +2 -2
  56. package/dist/cjs/api/resources/statistic/types/StatBasicExtendedQueryRecord.d.ts +76 -0
  57. package/dist/cjs/api/resources/statistic/types/StatBasicExtendedQueryRecord.js +3 -0
  58. package/dist/cjs/api/resources/statistic/types/index.d.ts +1 -0
  59. package/dist/cjs/api/resources/statistic/types/index.js +1 -0
  60. package/dist/cjs/api/resources/subscription/client/Client.d.ts +13 -13
  61. package/dist/cjs/api/resources/subscription/client/Client.js +23 -79
  62. package/dist/cjs/api/resources/templates/client/Client.d.ts +15 -15
  63. package/dist/cjs/api/resources/templates/client/Client.js +28 -84
  64. package/dist/cjs/api/resources/tokenStorage/client/Client.d.ts +13 -13
  65. package/dist/cjs/api/resources/tokenStorage/client/Client.js +23 -79
  66. package/dist/cjs/api/resources/user/client/Client.d.ts +54 -32
  67. package/dist/cjs/api/resources/user/client/Client.js +84 -222
  68. package/dist/cjs/api/resources/vendor/client/Client.d.ts +13 -13
  69. package/dist/cjs/api/resources/vendor/client/Client.js +23 -79
  70. package/dist/cjs/api/resources/wallet/client/Client.d.ts +13 -13
  71. package/dist/cjs/api/resources/wallet/client/Client.js +23 -79
  72. package/dist/cjs/api/types/ApplicationDetailsRecord.d.ts +2 -2
  73. package/dist/cjs/api/types/NotificationContent.d.ts +1 -0
  74. package/dist/cjs/api/types/NotificationContent.js +1 -0
  75. package/dist/cjs/api/types/NotificationStandardRequest.d.ts +1 -0
  76. package/dist/cjs/api/types/NotificationStandardRequest.js +1 -0
  77. package/dist/cjs/api/types/QueryResponseSettlements.d.ts +1 -1
  78. package/dist/cjs/auth/HeaderAuthProvider.d.ts +14 -0
  79. package/dist/cjs/auth/HeaderAuthProvider.js +71 -0
  80. package/dist/cjs/auth/index.d.ts +1 -0
  81. package/dist/cjs/auth/index.js +5 -0
  82. package/dist/cjs/core/auth/AuthProvider.d.ts +7 -0
  83. package/dist/cjs/{version.js → core/auth/AuthProvider.js} +0 -2
  84. package/dist/cjs/core/auth/AuthRequest.d.ts +9 -0
  85. package/dist/cjs/core/auth/AuthRequest.js +2 -0
  86. package/dist/cjs/core/auth/BasicAuth.d.ts +8 -0
  87. package/dist/cjs/core/auth/BasicAuth.js +27 -0
  88. package/dist/cjs/core/auth/BearerToken.d.ts +7 -0
  89. package/dist/cjs/core/auth/BearerToken.js +16 -0
  90. package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +5 -0
  91. package/dist/cjs/core/auth/NoOpAuthProvider.js +9 -0
  92. package/dist/cjs/core/auth/index.d.ts +5 -0
  93. package/dist/cjs/core/auth/index.js +9 -0
  94. package/dist/cjs/core/base64.d.ts +2 -0
  95. package/dist/cjs/core/base64.js +26 -0
  96. package/dist/cjs/core/fetcher/BinaryResponse.d.ts +6 -7
  97. package/dist/cjs/core/fetcher/Fetcher.d.ts +5 -1
  98. package/dist/cjs/core/fetcher/Fetcher.js +42 -24
  99. package/dist/cjs/core/fetcher/getResponseBody.js +18 -4
  100. package/dist/cjs/core/fetcher/makeRequest.d.ts +1 -1
  101. package/dist/cjs/core/fetcher/makeRequest.js +0 -2
  102. package/dist/cjs/core/fetcher/requestWithRetries.js +0 -9
  103. package/dist/cjs/core/fetcher/signals.d.ts +1 -7
  104. package/dist/cjs/core/fetcher/signals.js +0 -12
  105. package/dist/cjs/core/index.d.ts +2 -0
  106. package/dist/cjs/core/index.js +2 -0
  107. package/dist/cjs/core/logging/logger.js +1 -1
  108. package/dist/cjs/core/runtime/runtime.js +11 -10
  109. package/dist/cjs/core/url/join.js +0 -1
  110. package/dist/cjs/errors/handleNonStatusCodeError.d.ts +2 -0
  111. package/dist/cjs/errors/handleNonStatusCodeError.js +65 -0
  112. package/dist/esm/BaseClient.d.mts +10 -1
  113. package/dist/esm/BaseClient.mjs +22 -1
  114. package/dist/esm/Client.d.mts +87 -86
  115. package/dist/esm/Client.mjs +59 -67
  116. package/dist/esm/api/resources/bill/client/Client.d.mts +33 -33
  117. package/dist/esm/api/resources/bill/client/Client.mjs +67 -214
  118. package/dist/esm/api/resources/boarding/client/Client.d.mts +27 -27
  119. package/dist/esm/api/resources/boarding/client/Client.mjs +50 -197
  120. package/dist/esm/api/resources/chargeBacks/client/Client.d.mts +17 -15
  121. package/dist/esm/api/resources/chargeBacks/client/Client.mjs +36 -77
  122. package/dist/esm/api/resources/checkCapture/client/Client.d.mts +7 -7
  123. package/dist/esm/api/resources/checkCapture/client/Client.mjs +10 -27
  124. package/dist/esm/api/resources/cloud/client/Client.d.mts +17 -17
  125. package/dist/esm/api/resources/cloud/client/Client.mjs +31 -87
  126. package/dist/esm/api/resources/customer/client/Client.d.mts +17 -17
  127. package/dist/esm/api/resources/customer/client/Client.mjs +29 -111
  128. package/dist/esm/api/resources/export/client/Client.d.mts +93 -89
  129. package/dist/esm/api/resources/export/client/Client.mjs +204 -581
  130. package/dist/esm/api/resources/hostedPaymentPages/client/Client.d.mts +11 -11
  131. package/dist/esm/api/resources/hostedPaymentPages/client/Client.mjs +17 -60
  132. package/dist/esm/api/resources/import/client/Client.d.mts +11 -11
  133. package/dist/esm/api/resources/import/client/Client.mjs +17 -60
  134. package/dist/esm/api/resources/invoice/client/Client.d.mts +31 -31
  135. package/dist/esm/api/resources/invoice/client/Client.mjs +60 -207
  136. package/dist/esm/api/resources/lineItem/client/Client.d.mts +15 -15
  137. package/dist/esm/api/resources/lineItem/client/Client.mjs +25 -94
  138. package/dist/esm/api/resources/moneyIn/client/Client.d.mts +39 -39
  139. package/dist/esm/api/resources/moneyIn/client/Client.mjs +77 -247
  140. package/dist/esm/api/resources/moneyOut/client/Client.d.mts +43 -26
  141. package/dist/esm/api/resources/moneyOut/client/Client.mjs +103 -166
  142. package/dist/esm/api/resources/moneyOut/client/requests/MoneyOutTypesRequestOutAuthorize.d.mts +2 -1
  143. package/dist/esm/api/resources/moneyOutTypes/types/AuthorizePayoutBody.d.mts +3 -1
  144. package/dist/esm/api/resources/notification/client/Client.d.mts +16 -16
  145. package/dist/esm/api/resources/notification/client/Client.mjs +31 -100
  146. package/dist/esm/api/resources/notificationlogs/client/Client.d.mts +13 -13
  147. package/dist/esm/api/resources/notificationlogs/client/Client.mjs +22 -78
  148. package/dist/esm/api/resources/ocr/client/Client.d.mts +13 -9
  149. package/dist/esm/api/resources/ocr/client/Client.mjs +18 -44
  150. package/dist/esm/api/resources/organization/client/Client.d.mts +19 -19
  151. package/dist/esm/api/resources/organization/client/Client.mjs +33 -128
  152. package/dist/esm/api/resources/paymentLink/client/Client.d.mts +23 -23
  153. package/dist/esm/api/resources/paymentLink/client/Client.mjs +41 -162
  154. package/dist/esm/api/resources/paymentMethodDomain/client/Client.d.mts +19 -19
  155. package/dist/esm/api/resources/paymentMethodDomain/client/Client.mjs +34 -129
  156. package/dist/esm/api/resources/paypoint/client/Client.d.mts +22 -22
  157. package/dist/esm/api/resources/paypoint/client/Client.mjs +43 -151
  158. package/dist/esm/api/resources/query/client/Client.d.mts +71 -71
  159. package/dist/esm/api/resources/query/client/Client.mjs +136 -571
  160. package/dist/esm/api/resources/query/client/requests/ListPayoutOrgRequest.d.mts +1 -0
  161. package/dist/esm/api/resources/query/client/requests/ListPayoutRequest.d.mts +1 -0
  162. package/dist/esm/api/resources/query/client/requests/ListTransactionsRequest.d.mts +1 -0
  163. package/dist/esm/api/resources/statistic/client/Client.d.mts +50 -50
  164. package/dist/esm/api/resources/statistic/client/Client.mjs +79 -132
  165. package/dist/esm/api/resources/statistic/client/requests/BasicStatsRequest.d.mts +2 -2
  166. package/dist/esm/api/resources/statistic/types/StatBasicExtendedQueryRecord.d.mts +76 -0
  167. package/dist/esm/api/resources/statistic/types/StatBasicExtendedQueryRecord.mjs +2 -0
  168. package/dist/esm/api/resources/statistic/types/index.d.mts +1 -0
  169. package/dist/esm/api/resources/statistic/types/index.mjs +1 -0
  170. package/dist/esm/api/resources/subscription/client/Client.d.mts +13 -13
  171. package/dist/esm/api/resources/subscription/client/Client.mjs +21 -77
  172. package/dist/esm/api/resources/templates/client/Client.d.mts +15 -15
  173. package/dist/esm/api/resources/templates/client/Client.mjs +27 -83
  174. package/dist/esm/api/resources/tokenStorage/client/Client.d.mts +13 -13
  175. package/dist/esm/api/resources/tokenStorage/client/Client.mjs +21 -77
  176. package/dist/esm/api/resources/user/client/Client.d.mts +54 -32
  177. package/dist/esm/api/resources/user/client/Client.mjs +83 -221
  178. package/dist/esm/api/resources/vendor/client/Client.d.mts +13 -13
  179. package/dist/esm/api/resources/vendor/client/Client.mjs +22 -78
  180. package/dist/esm/api/resources/wallet/client/Client.d.mts +13 -13
  181. package/dist/esm/api/resources/wallet/client/Client.mjs +22 -78
  182. package/dist/esm/api/types/ApplicationDetailsRecord.d.mts +2 -2
  183. package/dist/esm/api/types/NotificationContent.d.mts +1 -0
  184. package/dist/esm/api/types/NotificationContent.mjs +1 -0
  185. package/dist/esm/api/types/NotificationStandardRequest.d.mts +1 -0
  186. package/dist/esm/api/types/NotificationStandardRequest.mjs +1 -0
  187. package/dist/esm/api/types/QueryResponseSettlements.d.mts +1 -1
  188. package/dist/esm/auth/HeaderAuthProvider.d.mts +14 -0
  189. package/dist/esm/auth/HeaderAuthProvider.mjs +34 -0
  190. package/dist/esm/auth/index.d.mts +1 -0
  191. package/dist/esm/auth/index.mjs +1 -0
  192. package/dist/esm/core/auth/AuthProvider.d.mts +7 -0
  193. package/dist/esm/core/auth/AuthProvider.mjs +1 -0
  194. package/dist/esm/core/auth/AuthRequest.d.mts +9 -0
  195. package/dist/esm/core/auth/AuthRequest.mjs +1 -0
  196. package/dist/esm/core/auth/BasicAuth.d.mts +8 -0
  197. package/dist/esm/core/auth/BasicAuth.mjs +24 -0
  198. package/dist/esm/core/auth/BearerToken.d.mts +7 -0
  199. package/dist/esm/core/auth/BearerToken.mjs +13 -0
  200. package/dist/esm/core/auth/NoOpAuthProvider.d.mts +5 -0
  201. package/dist/esm/core/auth/NoOpAuthProvider.mjs +5 -0
  202. package/dist/esm/core/auth/index.d.mts +5 -0
  203. package/dist/esm/core/auth/index.mjs +3 -0
  204. package/dist/esm/core/base64.d.mts +2 -0
  205. package/dist/esm/core/base64.mjs +22 -0
  206. package/dist/esm/core/fetcher/BinaryResponse.d.mts +6 -7
  207. package/dist/esm/core/fetcher/Fetcher.d.mts +5 -1
  208. package/dist/esm/core/fetcher/Fetcher.mjs +42 -24
  209. package/dist/esm/core/fetcher/getResponseBody.mjs +18 -4
  210. package/dist/esm/core/fetcher/makeRequest.d.mts +1 -1
  211. package/dist/esm/core/fetcher/makeRequest.mjs +0 -2
  212. package/dist/esm/core/fetcher/requestWithRetries.mjs +0 -9
  213. package/dist/esm/core/fetcher/signals.d.mts +1 -7
  214. package/dist/esm/core/fetcher/signals.mjs +0 -12
  215. package/dist/esm/core/index.d.mts +2 -0
  216. package/dist/esm/core/index.mjs +2 -0
  217. package/dist/esm/core/logging/logger.mjs +1 -1
  218. package/dist/esm/core/runtime/runtime.mjs +11 -10
  219. package/dist/esm/core/url/join.mjs +0 -1
  220. package/dist/esm/errors/handleNonStatusCodeError.d.mts +2 -0
  221. package/dist/esm/errors/handleNonStatusCodeError.mjs +29 -0
  222. package/package.json +4 -4
  223. package/reference.md +761 -473
  224. package/dist/cjs/core/fetcher/ResponseWithBody.d.ts +0 -4
  225. package/dist/cjs/core/fetcher/ResponseWithBody.js +0 -6
  226. package/dist/cjs/version.d.ts +0 -1
  227. package/dist/esm/core/fetcher/ResponseWithBody.d.mts +0 -4
  228. package/dist/esm/core/fetcher/ResponseWithBody.mjs +0 -3
  229. package/dist/esm/version.d.mts +0 -1
  230. package/dist/esm/version.mjs +0 -1
@@ -54,15 +54,17 @@ var __rest = (this && this.__rest) || function (s, e) {
54
54
  return t;
55
55
  };
56
56
  Object.defineProperty(exports, "__esModule", { value: true });
57
- exports.MoneyIn = void 0;
57
+ exports.MoneyInClient = void 0;
58
+ const BaseClient_js_1 = require("../../../../BaseClient.js");
58
59
  const headers_js_1 = require("../../../../core/headers.js");
59
60
  const core = __importStar(require("../../../../core/index.js"));
60
61
  const environments = __importStar(require("../../../../environments.js"));
62
+ const handleNonStatusCodeError_js_1 = require("../../../../errors/handleNonStatusCodeError.js");
61
63
  const errors = __importStar(require("../../../../errors/index.js"));
62
64
  const Payabli = __importStar(require("../../../index.js"));
63
- class MoneyIn {
64
- constructor(_options = {}) {
65
- this._options = _options;
65
+ class MoneyInClient {
66
+ constructor(options = {}) {
67
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
66
68
  }
67
69
  /**
68
70
  * Authorize a card transaction. This returns an authorization code and reserves funds for the merchant. Authorized transactions aren't flagged for settlement until [captured](/api-reference/moneyin/capture-an-authorized-transaction).
@@ -70,7 +72,7 @@ class MoneyIn {
70
72
  * **Note**: Only card transactions can be authorized. This endpoint can't be used for ACH transactions.
71
73
  *
72
74
  * @param {Payabli.RequestPaymentAuthorize} request
73
- * @param {MoneyIn.RequestOptions} requestOptions - Request-specific configuration.
75
+ * @param {MoneyInClient.RequestOptions} requestOptions - Request-specific configuration.
74
76
  *
75
77
  * @throws {@link Payabli.BadRequestError}
76
78
  * @throws {@link Payabli.UnauthorizedError}
@@ -112,7 +114,8 @@ class MoneyIn {
112
114
  if (forceCustomerCreation != null) {
113
115
  _queryParams.forceCustomerCreation = forceCustomerCreation.toString();
114
116
  }
115
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({ idempotencyKey: idempotencyKey != null ? idempotencyKey : undefined }, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
117
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
118
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ idempotencyKey: idempotencyKey != null ? idempotencyKey : undefined }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
116
119
  const _response = yield core.fetcher({
117
120
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PayabliEnvironment.Sandbox, "MoneyIn/authorize"),
118
121
  method: "POST",
@@ -148,21 +151,7 @@ class MoneyIn {
148
151
  });
149
152
  }
150
153
  }
151
- switch (_response.error.reason) {
152
- case "non-json":
153
- throw new errors.PayabliError({
154
- statusCode: _response.error.statusCode,
155
- body: _response.error.rawBody,
156
- rawResponse: _response.rawResponse,
157
- });
158
- case "timeout":
159
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling POST /MoneyIn/authorize.");
160
- case "unknown":
161
- throw new errors.PayabliError({
162
- message: _response.error.errorMessage,
163
- rawResponse: _response.rawResponse,
164
- });
165
- }
154
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/MoneyIn/authorize");
166
155
  });
167
156
  }
168
157
  /**
@@ -173,9 +162,9 @@ class MoneyIn {
173
162
  * Capture an [authorized
174
163
  * transaction](/api-reference/moneyin/authorize-a-transaction) to complete the transaction and move funds from the customer to merchant account.
175
164
  *
176
- * @param {number} amount - Amount to be captured. The amount can't be greater the original total amount of the transaction. `0` captures the total amount authorized in the transaction. Partial captures aren't supported.
177
165
  * @param {string} transId - ReferenceId for the transaction (PaymentId).
178
- * @param {MoneyIn.RequestOptions} requestOptions - Request-specific configuration.
166
+ * @param {number} amount - Amount to be captured. The amount can't be greater the original total amount of the transaction. `0` captures the total amount authorized in the transaction. Partial captures aren't supported.
167
+ * @param {MoneyInClient.RequestOptions} requestOptions - Request-specific configuration.
179
168
  *
180
169
  * @throws {@link Payabli.BadRequestError}
181
170
  * @throws {@link Payabli.UnauthorizedError}
@@ -183,15 +172,16 @@ class MoneyIn {
183
172
  * @throws {@link Payabli.ServiceUnavailableError}
184
173
  *
185
174
  * @example
186
- * await client.moneyIn.capture(0, "10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13")
175
+ * await client.moneyIn.capture("10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13", 0)
187
176
  */
188
- capture(amount, transId, requestOptions) {
189
- return core.HttpResponsePromise.fromPromise(this.__capture(amount, transId, requestOptions));
177
+ capture(transId, amount, requestOptions) {
178
+ return core.HttpResponsePromise.fromPromise(this.__capture(transId, amount, requestOptions));
190
179
  }
191
- __capture(amount, transId, requestOptions) {
180
+ __capture(transId, amount, requestOptions) {
192
181
  return __awaiter(this, void 0, void 0, function* () {
193
182
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
194
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
183
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
184
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
195
185
  const _response = yield core.fetcher({
196
186
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PayabliEnvironment.Sandbox, `MoneyIn/capture/${core.url.encodePathParam(transId)}/${core.url.encodePathParam(amount)}`),
197
187
  method: "GET",
@@ -224,21 +214,7 @@ class MoneyIn {
224
214
  });
225
215
  }
226
216
  }
227
- switch (_response.error.reason) {
228
- case "non-json":
229
- throw new errors.PayabliError({
230
- statusCode: _response.error.statusCode,
231
- body: _response.error.rawBody,
232
- rawResponse: _response.rawResponse,
233
- });
234
- case "timeout":
235
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling GET /MoneyIn/capture/{transId}/{amount}.");
236
- case "unknown":
237
- throw new errors.PayabliError({
238
- message: _response.error.errorMessage,
239
- rawResponse: _response.rawResponse,
240
- });
241
- }
217
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/MoneyIn/capture/{transId}/{amount}");
242
218
  });
243
219
  }
244
220
  /**
@@ -248,7 +224,7 @@ class MoneyIn {
248
224
  *
249
225
  * @param {string} transId - ReferenceId for the transaction (PaymentId).
250
226
  * @param {Payabli.CaptureRequest} request
251
- * @param {MoneyIn.RequestOptions} requestOptions - Request-specific configuration.
227
+ * @param {MoneyInClient.RequestOptions} requestOptions - Request-specific configuration.
252
228
  *
253
229
  * @throws {@link Payabli.BadRequestError}
254
230
  * @throws {@link Payabli.UnauthorizedError}
@@ -284,7 +260,8 @@ class MoneyIn {
284
260
  __captureAuth(transId, request, requestOptions) {
285
261
  return __awaiter(this, void 0, void 0, function* () {
286
262
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
287
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
263
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
264
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
288
265
  const _response = yield core.fetcher({
289
266
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PayabliEnvironment.Sandbox, `MoneyIn/capture/${core.url.encodePathParam(transId)}`),
290
267
  method: "POST",
@@ -320,21 +297,7 @@ class MoneyIn {
320
297
  });
321
298
  }
322
299
  }
323
- switch (_response.error.reason) {
324
- case "non-json":
325
- throw new errors.PayabliError({
326
- statusCode: _response.error.statusCode,
327
- body: _response.error.rawBody,
328
- rawResponse: _response.rawResponse,
329
- });
330
- case "timeout":
331
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling POST /MoneyIn/capture/{transId}.");
332
- case "unknown":
333
- throw new errors.PayabliError({
334
- message: _response.error.errorMessage,
335
- rawResponse: _response.rawResponse,
336
- });
337
- }
300
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/MoneyIn/capture/{transId}");
338
301
  });
339
302
  }
340
303
  /**
@@ -343,7 +306,7 @@ class MoneyIn {
343
306
  * This feature must be enabled by Payabli on a per-merchant basis. Contact support for help.
344
307
  *
345
308
  * @param {Payabli.RequestCredit} request
346
- * @param {MoneyIn.RequestOptions} requestOptions - Request-specific configuration.
309
+ * @param {MoneyInClient.RequestOptions} requestOptions - Request-specific configuration.
347
310
  *
348
311
  * @throws {@link Payabli.BadRequestError}
349
312
  * @throws {@link Payabli.UnauthorizedError}
@@ -408,7 +371,8 @@ class MoneyIn {
408
371
  if (forceCustomerCreation != null) {
409
372
  _queryParams.forceCustomerCreation = forceCustomerCreation.toString();
410
373
  }
411
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({ idempotencyKey: idempotencyKey != null ? idempotencyKey : undefined }, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
374
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
375
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ idempotencyKey: idempotencyKey != null ? idempotencyKey : undefined }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
412
376
  const _response = yield core.fetcher({
413
377
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PayabliEnvironment.Sandbox, "MoneyIn/makecredit"),
414
378
  method: "POST",
@@ -444,28 +408,14 @@ class MoneyIn {
444
408
  });
445
409
  }
446
410
  }
447
- switch (_response.error.reason) {
448
- case "non-json":
449
- throw new errors.PayabliError({
450
- statusCode: _response.error.statusCode,
451
- body: _response.error.rawBody,
452
- rawResponse: _response.rawResponse,
453
- });
454
- case "timeout":
455
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling POST /MoneyIn/makecredit.");
456
- case "unknown":
457
- throw new errors.PayabliError({
458
- message: _response.error.errorMessage,
459
- rawResponse: _response.rawResponse,
460
- });
461
- }
411
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/MoneyIn/makecredit");
462
412
  });
463
413
  }
464
414
  /**
465
415
  * Retrieve a processed transaction's details.
466
416
  *
467
417
  * @param {string} transId - ReferenceId for the transaction (PaymentId).
468
- * @param {MoneyIn.RequestOptions} requestOptions - Request-specific configuration.
418
+ * @param {MoneyInClient.RequestOptions} requestOptions - Request-specific configuration.
469
419
  *
470
420
  * @throws {@link Payabli.BadRequestError}
471
421
  * @throws {@link Payabli.UnauthorizedError}
@@ -481,7 +431,8 @@ class MoneyIn {
481
431
  __details(transId, requestOptions) {
482
432
  return __awaiter(this, void 0, void 0, function* () {
483
433
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
484
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
434
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
435
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
485
436
  const _response = yield core.fetcher({
486
437
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PayabliEnvironment.Sandbox, `MoneyIn/details/${core.url.encodePathParam(transId)}`),
487
438
  method: "GET",
@@ -517,28 +468,14 @@ class MoneyIn {
517
468
  });
518
469
  }
519
470
  }
520
- switch (_response.error.reason) {
521
- case "non-json":
522
- throw new errors.PayabliError({
523
- statusCode: _response.error.statusCode,
524
- body: _response.error.rawBody,
525
- rawResponse: _response.rawResponse,
526
- });
527
- case "timeout":
528
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling GET /MoneyIn/details/{transId}.");
529
- case "unknown":
530
- throw new errors.PayabliError({
531
- message: _response.error.errorMessage,
532
- rawResponse: _response.rawResponse,
533
- });
534
- }
471
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/MoneyIn/details/{transId}");
535
472
  });
536
473
  }
537
474
  /**
538
475
  * Make a single transaction. This method authorizes and captures a payment in one step.
539
476
  *
540
477
  * @param {Payabli.RequestPayment} request
541
- * @param {MoneyIn.RequestOptions} requestOptions - Request-specific configuration.
478
+ * @param {MoneyInClient.RequestOptions} requestOptions - Request-specific configuration.
542
479
  *
543
480
  * @throws {@link Payabli.BadRequestError}
544
481
  * @throws {@link Payabli.UnauthorizedError}
@@ -713,7 +650,11 @@ class MoneyIn {
713
650
  if (includeDetails != null) {
714
651
  _queryParams.includeDetails = includeDetails.toString();
715
652
  }
716
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({ idempotencyKey: idempotencyKey != null ? idempotencyKey : undefined, validationCode: validationCode != null ? validationCode : undefined }, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
653
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
654
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
655
+ idempotencyKey: idempotencyKey != null ? idempotencyKey : undefined,
656
+ validationCode: validationCode != null ? validationCode : undefined,
657
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
717
658
  const _response = yield core.fetcher({
718
659
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PayabliEnvironment.Sandbox, "MoneyIn/getpaid"),
719
660
  method: "POST",
@@ -749,34 +690,20 @@ class MoneyIn {
749
690
  });
750
691
  }
751
692
  }
752
- switch (_response.error.reason) {
753
- case "non-json":
754
- throw new errors.PayabliError({
755
- statusCode: _response.error.statusCode,
756
- body: _response.error.rawBody,
757
- rawResponse: _response.rawResponse,
758
- });
759
- case "timeout":
760
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling POST /MoneyIn/getpaid.");
761
- case "unknown":
762
- throw new errors.PayabliError({
763
- message: _response.error.errorMessage,
764
- rawResponse: _response.rawResponse,
765
- });
766
- }
693
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/MoneyIn/getpaid");
767
694
  });
768
695
  }
769
696
  /**
770
697
  * A reversal either refunds or voids a transaction independent of the transaction's settlement status. Send a reversal request for a transaction, and Payabli automatically determines whether it's a refund or void. You don't need to know whether the transaction is settled or not.
771
698
  *
699
+ * @param {string} transId - ReferenceId for the transaction (PaymentId).
772
700
  * @param {number} amount -
773
701
  * Amount to reverse from original transaction, minus any service fees charged on the original transaction.
774
702
  *
775
703
  * The amount provided can't be greater than the original total amount of the transaction, minus service fees. For example, if a transaction was $90 plus a $10 service fee, you can reverse up to $90.
776
704
  *
777
705
  * An amount equal to zero will refunds the total amount authorized minus any service fee.
778
- * @param {string} transId - ReferenceId for the transaction (PaymentId).
779
- * @param {MoneyIn.RequestOptions} requestOptions - Request-specific configuration.
706
+ * @param {MoneyInClient.RequestOptions} requestOptions - Request-specific configuration.
780
707
  *
781
708
  * @throws {@link Payabli.BadRequestError}
782
709
  * @throws {@link Payabli.UnauthorizedError}
@@ -784,18 +711,19 @@ class MoneyIn {
784
711
  * @throws {@link Payabli.ServiceUnavailableError}
785
712
  *
786
713
  * @example
787
- * await client.moneyIn.reverse(0, "10-3ffa27df-b171-44e0-b251-e95fbfc7a723")
714
+ * await client.moneyIn.reverse("10-3ffa27df-b171-44e0-b251-e95fbfc7a723", 0)
788
715
  *
789
716
  * @example
790
- * await client.moneyIn.reverse(53.76, "10-3ffa27df-b171-44e0-b251-e95fbfc7a723")
717
+ * await client.moneyIn.reverse("10-3ffa27df-b171-44e0-b251-e95fbfc7a723", 53.76)
791
718
  */
792
- reverse(amount, transId, requestOptions) {
793
- return core.HttpResponsePromise.fromPromise(this.__reverse(amount, transId, requestOptions));
719
+ reverse(transId, amount, requestOptions) {
720
+ return core.HttpResponsePromise.fromPromise(this.__reverse(transId, amount, requestOptions));
794
721
  }
795
- __reverse(amount, transId, requestOptions) {
722
+ __reverse(transId, amount, requestOptions) {
796
723
  return __awaiter(this, void 0, void 0, function* () {
797
724
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
798
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
725
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
726
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
799
727
  const _response = yield core.fetcher({
800
728
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PayabliEnvironment.Sandbox, `MoneyIn/reverse/${core.url.encodePathParam(transId)}/${core.url.encodePathParam(amount)}`),
801
729
  method: "GET",
@@ -828,34 +756,20 @@ class MoneyIn {
828
756
  });
829
757
  }
830
758
  }
831
- switch (_response.error.reason) {
832
- case "non-json":
833
- throw new errors.PayabliError({
834
- statusCode: _response.error.statusCode,
835
- body: _response.error.rawBody,
836
- rawResponse: _response.rawResponse,
837
- });
838
- case "timeout":
839
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling GET /MoneyIn/reverse/{transId}/{amount}.");
840
- case "unknown":
841
- throw new errors.PayabliError({
842
- message: _response.error.errorMessage,
843
- rawResponse: _response.rawResponse,
844
- });
845
- }
759
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/MoneyIn/reverse/{transId}/{amount}");
846
760
  });
847
761
  }
848
762
  /**
849
763
  * Refund a transaction that has settled and send money back to the account holder. If a transaction hasn't been settled, void it instead.
850
764
  *
765
+ * @param {string} transId - ReferenceId for the transaction (PaymentId).
851
766
  * @param {number} amount -
852
767
  * Amount to refund from original transaction, minus any service fees charged on the original transaction.
853
768
  *
854
769
  * The amount provided can't be greater than the original total amount of the transaction, minus service fees. For example, if a transaction was \$90 plus a \$10 service fee, you can refund up to \$90.
855
770
  *
856
771
  * An amount equal to zero will refund the total amount authorized minus any service fee.
857
- * @param {string} transId - ReferenceId for the transaction (PaymentId).
858
- * @param {MoneyIn.RequestOptions} requestOptions - Request-specific configuration.
772
+ * @param {MoneyInClient.RequestOptions} requestOptions - Request-specific configuration.
859
773
  *
860
774
  * @throws {@link Payabli.BadRequestError}
861
775
  * @throws {@link Payabli.UnauthorizedError}
@@ -863,18 +777,19 @@ class MoneyIn {
863
777
  * @throws {@link Payabli.ServiceUnavailableError}
864
778
  *
865
779
  * @example
866
- * await client.moneyIn.refund(0, "10-3ffa27df-b171-44e0-b251-e95fbfc7a723")
780
+ * await client.moneyIn.refund("10-3ffa27df-b171-44e0-b251-e95fbfc7a723", 0)
867
781
  *
868
782
  * @example
869
- * await client.moneyIn.refund(100.99, "10-3ffa27df-b171-44e0-b251-e95fbfc7a723")
783
+ * await client.moneyIn.refund("10-3ffa27df-b171-44e0-b251-e95fbfc7a723", 100.99)
870
784
  */
871
- refund(amount, transId, requestOptions) {
872
- return core.HttpResponsePromise.fromPromise(this.__refund(amount, transId, requestOptions));
785
+ refund(transId, amount, requestOptions) {
786
+ return core.HttpResponsePromise.fromPromise(this.__refund(transId, amount, requestOptions));
873
787
  }
874
- __refund(amount, transId, requestOptions) {
788
+ __refund(transId, amount, requestOptions) {
875
789
  return __awaiter(this, void 0, void 0, function* () {
876
790
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
877
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
791
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
792
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
878
793
  const _response = yield core.fetcher({
879
794
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PayabliEnvironment.Sandbox, `MoneyIn/refund/${core.url.encodePathParam(transId)}/${core.url.encodePathParam(amount)}`),
880
795
  method: "GET",
@@ -907,21 +822,7 @@ class MoneyIn {
907
822
  });
908
823
  }
909
824
  }
910
- switch (_response.error.reason) {
911
- case "non-json":
912
- throw new errors.PayabliError({
913
- statusCode: _response.error.statusCode,
914
- body: _response.error.rawBody,
915
- rawResponse: _response.rawResponse,
916
- });
917
- case "timeout":
918
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling GET /MoneyIn/refund/{transId}/{amount}.");
919
- case "unknown":
920
- throw new errors.PayabliError({
921
- message: _response.error.errorMessage,
922
- rawResponse: _response.rawResponse,
923
- });
924
- }
825
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/MoneyIn/refund/{transId}/{amount}");
925
826
  });
926
827
  }
927
828
  /**
@@ -929,7 +830,7 @@ class MoneyIn {
929
830
  *
930
831
  * @param {string} transId - ReferenceId for the transaction (PaymentId).
931
832
  * @param {Payabli.RequestRefund} request
932
- * @param {MoneyIn.RequestOptions} requestOptions - Request-specific configuration.
833
+ * @param {MoneyInClient.RequestOptions} requestOptions - Request-specific configuration.
933
834
  *
934
835
  * @throws {@link Payabli.BadRequestError}
935
836
  * @throws {@link Payabli.UnauthorizedError}
@@ -985,7 +886,8 @@ class MoneyIn {
985
886
  return __awaiter(this, arguments, void 0, function* (transId, request = {}, requestOptions) {
986
887
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
987
888
  const { idempotencyKey } = request, _body = __rest(request, ["idempotencyKey"]);
988
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({ idempotencyKey: idempotencyKey != null ? idempotencyKey : undefined }, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
889
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
890
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ idempotencyKey: idempotencyKey != null ? idempotencyKey : undefined }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
989
891
  const _response = yield core.fetcher({
990
892
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PayabliEnvironment.Sandbox, `MoneyIn/refund/${core.url.encodePathParam(transId)}`),
991
893
  method: "POST",
@@ -1024,28 +926,14 @@ class MoneyIn {
1024
926
  });
1025
927
  }
1026
928
  }
1027
- switch (_response.error.reason) {
1028
- case "non-json":
1029
- throw new errors.PayabliError({
1030
- statusCode: _response.error.statusCode,
1031
- body: _response.error.rawBody,
1032
- rawResponse: _response.rawResponse,
1033
- });
1034
- case "timeout":
1035
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling POST /MoneyIn/refund/{transId}.");
1036
- case "unknown":
1037
- throw new errors.PayabliError({
1038
- message: _response.error.errorMessage,
1039
- rawResponse: _response.rawResponse,
1040
- });
1041
- }
929
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/MoneyIn/refund/{transId}");
1042
930
  });
1043
931
  }
1044
932
  /**
1045
933
  * Reverse microdeposits that are used to verify customer account ownership and access. The `transId` value is returned in the success response for the original credit transaction made with `api/MoneyIn/makecredit`.
1046
934
  *
1047
935
  * @param {string} transId - ReferenceId for the transaction (PaymentId).
1048
- * @param {MoneyIn.RequestOptions} requestOptions - Request-specific configuration.
936
+ * @param {MoneyInClient.RequestOptions} requestOptions - Request-specific configuration.
1049
937
  *
1050
938
  * @throws {@link Payabli.BadRequestError}
1051
939
  * @throws {@link Payabli.UnauthorizedError}
@@ -1061,7 +949,8 @@ class MoneyIn {
1061
949
  __reverseCredit(transId, requestOptions) {
1062
950
  return __awaiter(this, void 0, void 0, function* () {
1063
951
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1064
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
952
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
953
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
1065
954
  const _response = yield core.fetcher({
1066
955
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PayabliEnvironment.Sandbox, `MoneyIn/reverseCredit/${core.url.encodePathParam(transId)}`),
1067
956
  method: "GET",
@@ -1094,21 +983,7 @@ class MoneyIn {
1094
983
  });
1095
984
  }
1096
985
  }
1097
- switch (_response.error.reason) {
1098
- case "non-json":
1099
- throw new errors.PayabliError({
1100
- statusCode: _response.error.statusCode,
1101
- body: _response.error.rawBody,
1102
- rawResponse: _response.rawResponse,
1103
- });
1104
- case "timeout":
1105
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling GET /MoneyIn/reverseCredit/{transId}.");
1106
- case "unknown":
1107
- throw new errors.PayabliError({
1108
- message: _response.error.errorMessage,
1109
- rawResponse: _response.rawResponse,
1110
- });
1111
- }
986
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/MoneyIn/reverseCredit/{transId}");
1112
987
  });
1113
988
  }
1114
989
  /**
@@ -1116,7 +991,7 @@ class MoneyIn {
1116
991
  *
1117
992
  * @param {string} transId - ReferenceId for the transaction (PaymentId).
1118
993
  * @param {Payabli.SendReceipt2TransRequest} request
1119
- * @param {MoneyIn.RequestOptions} requestOptions - Request-specific configuration.
994
+ * @param {MoneyInClient.RequestOptions} requestOptions - Request-specific configuration.
1120
995
  *
1121
996
  * @throws {@link Payabli.BadRequestError}
1122
997
  * @throws {@link Payabli.UnauthorizedError}
@@ -1139,7 +1014,8 @@ class MoneyIn {
1139
1014
  if (email != null) {
1140
1015
  _queryParams.email = email;
1141
1016
  }
1142
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
1017
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
1018
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
1143
1019
  const _response = yield core.fetcher({
1144
1020
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PayabliEnvironment.Sandbox, `MoneyIn/sendreceipt/${core.url.encodePathParam(transId)}`),
1145
1021
  method: "GET",
@@ -1172,28 +1048,14 @@ class MoneyIn {
1172
1048
  });
1173
1049
  }
1174
1050
  }
1175
- switch (_response.error.reason) {
1176
- case "non-json":
1177
- throw new errors.PayabliError({
1178
- statusCode: _response.error.statusCode,
1179
- body: _response.error.rawBody,
1180
- rawResponse: _response.rawResponse,
1181
- });
1182
- case "timeout":
1183
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling GET /MoneyIn/sendreceipt/{transId}.");
1184
- case "unknown":
1185
- throw new errors.PayabliError({
1186
- message: _response.error.errorMessage,
1187
- rawResponse: _response.rawResponse,
1188
- });
1189
- }
1051
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/MoneyIn/sendreceipt/{transId}");
1190
1052
  });
1191
1053
  }
1192
1054
  /**
1193
1055
  * Validates a card number without running a transaction or authorizing a charge.
1194
1056
  *
1195
1057
  * @param {Payabli.RequestPaymentValidate} request
1196
- * @param {MoneyIn.RequestOptions} requestOptions - Request-specific configuration.
1058
+ * @param {MoneyInClient.RequestOptions} requestOptions - Request-specific configuration.
1197
1059
  *
1198
1060
  * @throws {@link Payabli.BadRequestError}
1199
1061
  * @throws {@link Payabli.UnauthorizedError}
@@ -1220,7 +1082,8 @@ class MoneyIn {
1220
1082
  return __awaiter(this, void 0, void 0, function* () {
1221
1083
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1222
1084
  const { idempotencyKey } = request, _body = __rest(request, ["idempotencyKey"]);
1223
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({ idempotencyKey: idempotencyKey != null ? idempotencyKey : undefined }, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
1085
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
1086
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ idempotencyKey: idempotencyKey != null ? idempotencyKey : undefined }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
1224
1087
  const _response = yield core.fetcher({
1225
1088
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PayabliEnvironment.Sandbox, "MoneyIn/validate"),
1226
1089
  method: "POST",
@@ -1256,28 +1119,14 @@ class MoneyIn {
1256
1119
  });
1257
1120
  }
1258
1121
  }
1259
- switch (_response.error.reason) {
1260
- case "non-json":
1261
- throw new errors.PayabliError({
1262
- statusCode: _response.error.statusCode,
1263
- body: _response.error.rawBody,
1264
- rawResponse: _response.rawResponse,
1265
- });
1266
- case "timeout":
1267
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling POST /MoneyIn/validate.");
1268
- case "unknown":
1269
- throw new errors.PayabliError({
1270
- message: _response.error.errorMessage,
1271
- rawResponse: _response.rawResponse,
1272
- });
1273
- }
1122
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/MoneyIn/validate");
1274
1123
  });
1275
1124
  }
1276
1125
  /**
1277
1126
  * Cancel a transaction that hasn't been settled yet. Voiding non-captured authorizations prevents future captures. If a transaction has been settled, refund it instead.
1278
1127
  *
1279
1128
  * @param {string} transId - ReferenceId for the transaction (PaymentId).
1280
- * @param {MoneyIn.RequestOptions} requestOptions - Request-specific configuration.
1129
+ * @param {MoneyInClient.RequestOptions} requestOptions - Request-specific configuration.
1281
1130
  *
1282
1131
  * @throws {@link Payabli.BadRequestError}
1283
1132
  * @throws {@link Payabli.UnauthorizedError}
@@ -1293,7 +1142,8 @@ class MoneyIn {
1293
1142
  __void(transId, requestOptions) {
1294
1143
  return __awaiter(this, void 0, void 0, function* () {
1295
1144
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1296
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
1145
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
1146
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
1297
1147
  const _response = yield core.fetcher({
1298
1148
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PayabliEnvironment.Sandbox, `MoneyIn/void/${core.url.encodePathParam(transId)}`),
1299
1149
  method: "GET",
@@ -1326,28 +1176,8 @@ class MoneyIn {
1326
1176
  });
1327
1177
  }
1328
1178
  }
1329
- switch (_response.error.reason) {
1330
- case "non-json":
1331
- throw new errors.PayabliError({
1332
- statusCode: _response.error.statusCode,
1333
- body: _response.error.rawBody,
1334
- rawResponse: _response.rawResponse,
1335
- });
1336
- case "timeout":
1337
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling GET /MoneyIn/void/{transId}.");
1338
- case "unknown":
1339
- throw new errors.PayabliError({
1340
- message: _response.error.errorMessage,
1341
- rawResponse: _response.rawResponse,
1342
- });
1343
- }
1344
- });
1345
- }
1346
- _getCustomAuthorizationHeaders() {
1347
- return __awaiter(this, void 0, void 0, function* () {
1348
- const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
1349
- return { requestToken: apiKeyValue };
1179
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/MoneyIn/void/{transId}");
1350
1180
  });
1351
1181
  }
1352
1182
  }
1353
- exports.MoneyIn = MoneyIn;
1183
+ exports.MoneyInClient = MoneyInClient;