@payabli/sdk-node 0.0.116 → 0.0.123

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 (271) hide show
  1. package/README.md +31 -2
  2. package/dist/cjs/BaseClient.d.ts +13 -4
  3. package/dist/cjs/BaseClient.js +59 -0
  4. package/dist/cjs/Client.d.ts +88 -88
  5. package/dist/cjs/Client.js +31 -72
  6. package/dist/cjs/api/errors/BadRequestError.js +5 -1
  7. package/dist/cjs/api/errors/ConflictError.js +5 -1
  8. package/dist/cjs/api/errors/ForbiddenError.js +5 -1
  9. package/dist/cjs/api/errors/InternalServerError.js +5 -1
  10. package/dist/cjs/api/errors/ServiceUnavailableError.js +5 -1
  11. package/dist/cjs/api/errors/UnauthorizedError.js +5 -1
  12. package/dist/cjs/api/resources/bill/client/Client.d.ts +34 -35
  13. package/dist/cjs/api/resources/bill/client/Client.js +69 -216
  14. package/dist/cjs/api/resources/boarding/client/Client.d.ts +28 -29
  15. package/dist/cjs/api/resources/boarding/client/Client.js +51 -198
  16. package/dist/cjs/api/resources/chargeBacks/client/Client.d.ts +18 -17
  17. package/dist/cjs/api/resources/chargeBacks/client/Client.js +38 -79
  18. package/dist/cjs/api/resources/checkCapture/client/Client.d.ts +8 -9
  19. package/dist/cjs/api/resources/checkCapture/client/Client.js +11 -28
  20. package/dist/cjs/api/resources/cloud/client/Client.d.ts +18 -19
  21. package/dist/cjs/api/resources/cloud/client/Client.js +33 -89
  22. package/dist/cjs/api/resources/customer/client/Client.d.ts +18 -19
  23. package/dist/cjs/api/resources/customer/client/Client.js +31 -113
  24. package/dist/cjs/api/resources/export/client/Client.d.ts +94 -91
  25. package/dist/cjs/api/resources/export/client/Client.js +205 -582
  26. package/dist/cjs/api/resources/hostedPaymentPages/client/Client.d.ts +12 -13
  27. package/dist/cjs/api/resources/hostedPaymentPages/client/Client.js +19 -62
  28. package/dist/cjs/api/resources/import/client/Client.d.ts +12 -13
  29. package/dist/cjs/api/resources/import/client/Client.js +19 -62
  30. package/dist/cjs/api/resources/invoice/client/Client.d.ts +37 -36
  31. package/dist/cjs/api/resources/invoice/client/Client.js +67 -212
  32. package/dist/cjs/api/resources/invoice/client/requests/AddInvoiceRequest.d.ts +5 -3
  33. package/dist/cjs/api/resources/lineItem/client/Client.d.ts +16 -17
  34. package/dist/cjs/api/resources/lineItem/client/Client.js +27 -96
  35. package/dist/cjs/api/resources/moneyIn/client/Client.d.ts +40 -41
  36. package/dist/cjs/api/resources/moneyIn/client/Client.js +79 -249
  37. package/dist/cjs/api/resources/moneyIn/errors/CaptureError.js +5 -1
  38. package/dist/cjs/api/resources/moneyIn/errors/InvalidTransStatusError.js +5 -1
  39. package/dist/cjs/api/resources/moneyOut/client/Client.d.ts +44 -28
  40. package/dist/cjs/api/resources/moneyOut/client/Client.js +105 -168
  41. package/dist/cjs/api/resources/moneyOut/client/requests/MoneyOutTypesRequestOutAuthorize.d.ts +2 -1
  42. package/dist/cjs/api/resources/moneyOutTypes/types/AuthorizePayoutBody.d.ts +3 -1
  43. package/dist/cjs/api/resources/notification/client/Client.d.ts +30 -18
  44. package/dist/cjs/api/resources/notification/client/Client.js +45 -101
  45. package/dist/cjs/api/resources/notificationlogs/client/Client.d.ts +14 -15
  46. package/dist/cjs/api/resources/notificationlogs/client/Client.js +23 -79
  47. package/dist/cjs/api/resources/ocr/client/Client.d.ts +14 -11
  48. package/dist/cjs/api/resources/ocr/client/Client.js +19 -45
  49. package/dist/cjs/api/resources/organization/client/Client.d.ts +20 -21
  50. package/dist/cjs/api/resources/organization/client/Client.js +35 -130
  51. package/dist/cjs/api/resources/paymentLink/client/Client.d.ts +27 -28
  52. package/dist/cjs/api/resources/paymentLink/client/Client.js +46 -167
  53. package/dist/cjs/api/resources/paymentLink/client/requests/PayLinkDataBill.d.ts +1 -1
  54. package/dist/cjs/api/resources/paymentLink/client/requests/PayLinkDataInvoice.d.ts +1 -1
  55. package/dist/cjs/api/resources/paymentLink/client/requests/PayLinkDataOut.d.ts +1 -1
  56. package/dist/cjs/api/resources/paymentLink/types/PaymentPageRequestBody.d.ts +2 -2
  57. package/dist/cjs/api/resources/paymentMethodDomain/client/Client.d.ts +20 -21
  58. package/dist/cjs/api/resources/paymentMethodDomain/client/Client.js +35 -130
  59. package/dist/cjs/api/resources/paypoint/client/Client.d.ts +23 -24
  60. package/dist/cjs/api/resources/paypoint/client/Client.js +44 -152
  61. package/dist/cjs/api/resources/query/client/Client.d.ts +72 -73
  62. package/dist/cjs/api/resources/query/client/Client.js +137 -572
  63. package/dist/cjs/api/resources/query/client/requests/ListPayoutOrgRequest.d.ts +1 -0
  64. package/dist/cjs/api/resources/query/client/requests/ListPayoutRequest.d.ts +1 -0
  65. package/dist/cjs/api/resources/query/client/requests/ListTransactionsRequest.d.ts +1 -0
  66. package/dist/cjs/api/resources/statistic/client/Client.d.ts +51 -52
  67. package/dist/cjs/api/resources/statistic/client/Client.js +80 -133
  68. package/dist/cjs/api/resources/statistic/client/requests/BasicStatsRequest.d.ts +2 -2
  69. package/dist/cjs/api/resources/statistic/types/StatBasicExtendedQueryRecord.d.ts +76 -0
  70. package/dist/cjs/api/resources/statistic/types/StatBasicExtendedQueryRecord.js +3 -0
  71. package/dist/cjs/api/resources/statistic/types/index.d.ts +1 -0
  72. package/dist/cjs/api/resources/statistic/types/index.js +1 -0
  73. package/dist/cjs/api/resources/subscription/client/Client.d.ts +14 -15
  74. package/dist/cjs/api/resources/subscription/client/Client.js +23 -79
  75. package/dist/cjs/api/resources/templates/client/Client.d.ts +16 -17
  76. package/dist/cjs/api/resources/templates/client/Client.js +28 -84
  77. package/dist/cjs/api/resources/tokenStorage/client/Client.d.ts +14 -15
  78. package/dist/cjs/api/resources/tokenStorage/client/Client.js +23 -79
  79. package/dist/cjs/api/resources/tokenStorage/types/GetMethodResponse.d.ts +1 -1
  80. package/dist/cjs/api/resources/user/client/Client.d.ts +55 -34
  81. package/dist/cjs/api/resources/user/client/Client.js +84 -222
  82. package/dist/cjs/api/resources/vendor/client/Client.d.ts +14 -15
  83. package/dist/cjs/api/resources/vendor/client/Client.js +23 -79
  84. package/dist/cjs/api/resources/wallet/client/Client.d.ts +14 -15
  85. package/dist/cjs/api/resources/wallet/client/Client.js +23 -79
  86. package/dist/cjs/api/types/ApplicationDetailsRecord.d.ts +2 -2
  87. package/dist/cjs/api/types/Frequency.d.ts +1 -1
  88. package/dist/cjs/api/types/Frequency.js +1 -1
  89. package/dist/cjs/api/types/FrequencyList.d.ts +1 -1
  90. package/dist/cjs/api/types/NotificationContent.d.ts +1 -0
  91. package/dist/cjs/api/types/NotificationContent.js +1 -0
  92. package/dist/cjs/api/types/NotificationStandardRequest.d.ts +1 -0
  93. package/dist/cjs/api/types/NotificationStandardRequest.js +1 -0
  94. package/dist/cjs/api/types/PayorDataResponse.d.ts +1 -1
  95. package/dist/cjs/api/types/QueryResponseSettlements.d.ts +1 -1
  96. package/dist/cjs/auth/HeaderAuthProvider.d.ts +16 -0
  97. package/dist/cjs/auth/HeaderAuthProvider.js +71 -0
  98. package/dist/cjs/auth/index.d.ts +1 -0
  99. package/dist/cjs/auth/index.js +5 -0
  100. package/dist/cjs/core/auth/AuthProvider.d.ts +7 -0
  101. package/dist/cjs/core/auth/AuthProvider.js +2 -0
  102. package/dist/cjs/core/auth/AuthRequest.d.ts +9 -0
  103. package/dist/cjs/core/auth/AuthRequest.js +2 -0
  104. package/dist/cjs/core/auth/BasicAuth.d.ts +8 -0
  105. package/dist/cjs/core/auth/BasicAuth.js +27 -0
  106. package/dist/cjs/core/auth/BearerToken.d.ts +7 -0
  107. package/dist/cjs/core/auth/BearerToken.js +16 -0
  108. package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +5 -0
  109. package/dist/cjs/core/auth/NoOpAuthProvider.js +9 -0
  110. package/dist/cjs/core/auth/index.d.ts +5 -0
  111. package/dist/cjs/core/auth/index.js +9 -0
  112. package/dist/cjs/core/base64.d.ts +2 -0
  113. package/dist/cjs/core/base64.js +26 -0
  114. package/dist/cjs/core/fetcher/BinaryResponse.d.ts +6 -7
  115. package/dist/cjs/core/fetcher/Fetcher.d.ts +5 -1
  116. package/dist/cjs/core/fetcher/Fetcher.js +42 -24
  117. package/dist/cjs/core/fetcher/getResponseBody.js +18 -4
  118. package/dist/cjs/core/fetcher/makeRequest.d.ts +1 -1
  119. package/dist/cjs/core/fetcher/makeRequest.js +0 -2
  120. package/dist/cjs/core/fetcher/requestWithRetries.js +0 -9
  121. package/dist/cjs/core/fetcher/signals.d.ts +1 -7
  122. package/dist/cjs/core/fetcher/signals.js +0 -12
  123. package/dist/cjs/core/index.d.ts +2 -0
  124. package/dist/cjs/core/index.js +2 -0
  125. package/dist/cjs/core/logging/logger.js +1 -1
  126. package/dist/cjs/core/runtime/runtime.js +11 -10
  127. package/dist/cjs/core/url/join.js +0 -1
  128. package/dist/cjs/errors/PayabliError.js +5 -1
  129. package/dist/cjs/errors/PayabliTimeoutError.js +5 -1
  130. package/dist/cjs/errors/handleNonStatusCodeError.d.ts +2 -0
  131. package/dist/cjs/errors/handleNonStatusCodeError.js +65 -0
  132. package/dist/cjs/version.d.ts +1 -1
  133. package/dist/cjs/version.js +1 -1
  134. package/dist/esm/BaseClient.d.mts +13 -4
  135. package/dist/esm/BaseClient.mjs +24 -1
  136. package/dist/esm/Client.d.mts +88 -88
  137. package/dist/esm/Client.mjs +59 -67
  138. package/dist/esm/api/errors/BadRequestError.mjs +5 -1
  139. package/dist/esm/api/errors/ConflictError.mjs +5 -1
  140. package/dist/esm/api/errors/ForbiddenError.mjs +5 -1
  141. package/dist/esm/api/errors/InternalServerError.mjs +5 -1
  142. package/dist/esm/api/errors/ServiceUnavailableError.mjs +5 -1
  143. package/dist/esm/api/errors/UnauthorizedError.mjs +5 -1
  144. package/dist/esm/api/resources/bill/client/Client.d.mts +34 -35
  145. package/dist/esm/api/resources/bill/client/Client.mjs +67 -214
  146. package/dist/esm/api/resources/boarding/client/Client.d.mts +28 -29
  147. package/dist/esm/api/resources/boarding/client/Client.mjs +50 -197
  148. package/dist/esm/api/resources/chargeBacks/client/Client.d.mts +18 -17
  149. package/dist/esm/api/resources/chargeBacks/client/Client.mjs +36 -77
  150. package/dist/esm/api/resources/checkCapture/client/Client.d.mts +8 -9
  151. package/dist/esm/api/resources/checkCapture/client/Client.mjs +10 -27
  152. package/dist/esm/api/resources/cloud/client/Client.d.mts +18 -19
  153. package/dist/esm/api/resources/cloud/client/Client.mjs +31 -87
  154. package/dist/esm/api/resources/customer/client/Client.d.mts +18 -19
  155. package/dist/esm/api/resources/customer/client/Client.mjs +29 -111
  156. package/dist/esm/api/resources/export/client/Client.d.mts +94 -91
  157. package/dist/esm/api/resources/export/client/Client.mjs +204 -581
  158. package/dist/esm/api/resources/hostedPaymentPages/client/Client.d.mts +12 -13
  159. package/dist/esm/api/resources/hostedPaymentPages/client/Client.mjs +17 -60
  160. package/dist/esm/api/resources/import/client/Client.d.mts +12 -13
  161. package/dist/esm/api/resources/import/client/Client.mjs +17 -60
  162. package/dist/esm/api/resources/invoice/client/Client.d.mts +37 -36
  163. package/dist/esm/api/resources/invoice/client/Client.mjs +65 -210
  164. package/dist/esm/api/resources/invoice/client/requests/AddInvoiceRequest.d.mts +5 -3
  165. package/dist/esm/api/resources/lineItem/client/Client.d.mts +16 -17
  166. package/dist/esm/api/resources/lineItem/client/Client.mjs +25 -94
  167. package/dist/esm/api/resources/moneyIn/client/Client.d.mts +40 -41
  168. package/dist/esm/api/resources/moneyIn/client/Client.mjs +77 -247
  169. package/dist/esm/api/resources/moneyIn/errors/CaptureError.mjs +5 -1
  170. package/dist/esm/api/resources/moneyIn/errors/InvalidTransStatusError.mjs +5 -1
  171. package/dist/esm/api/resources/moneyOut/client/Client.d.mts +44 -28
  172. package/dist/esm/api/resources/moneyOut/client/Client.mjs +103 -166
  173. package/dist/esm/api/resources/moneyOut/client/requests/MoneyOutTypesRequestOutAuthorize.d.mts +2 -1
  174. package/dist/esm/api/resources/moneyOutTypes/types/AuthorizePayoutBody.d.mts +3 -1
  175. package/dist/esm/api/resources/notification/client/Client.d.mts +30 -18
  176. package/dist/esm/api/resources/notification/client/Client.mjs +44 -100
  177. package/dist/esm/api/resources/notificationlogs/client/Client.d.mts +14 -15
  178. package/dist/esm/api/resources/notificationlogs/client/Client.mjs +22 -78
  179. package/dist/esm/api/resources/ocr/client/Client.d.mts +14 -11
  180. package/dist/esm/api/resources/ocr/client/Client.mjs +18 -44
  181. package/dist/esm/api/resources/organization/client/Client.d.mts +20 -21
  182. package/dist/esm/api/resources/organization/client/Client.mjs +33 -128
  183. package/dist/esm/api/resources/paymentLink/client/Client.d.mts +27 -28
  184. package/dist/esm/api/resources/paymentLink/client/Client.mjs +44 -165
  185. package/dist/esm/api/resources/paymentLink/client/requests/PayLinkDataBill.d.mts +1 -1
  186. package/dist/esm/api/resources/paymentLink/client/requests/PayLinkDataInvoice.d.mts +1 -1
  187. package/dist/esm/api/resources/paymentLink/client/requests/PayLinkDataOut.d.mts +1 -1
  188. package/dist/esm/api/resources/paymentLink/types/PaymentPageRequestBody.d.mts +2 -2
  189. package/dist/esm/api/resources/paymentMethodDomain/client/Client.d.mts +20 -21
  190. package/dist/esm/api/resources/paymentMethodDomain/client/Client.mjs +34 -129
  191. package/dist/esm/api/resources/paypoint/client/Client.d.mts +23 -24
  192. package/dist/esm/api/resources/paypoint/client/Client.mjs +43 -151
  193. package/dist/esm/api/resources/query/client/Client.d.mts +72 -73
  194. package/dist/esm/api/resources/query/client/Client.mjs +136 -571
  195. package/dist/esm/api/resources/query/client/requests/ListPayoutOrgRequest.d.mts +1 -0
  196. package/dist/esm/api/resources/query/client/requests/ListPayoutRequest.d.mts +1 -0
  197. package/dist/esm/api/resources/query/client/requests/ListTransactionsRequest.d.mts +1 -0
  198. package/dist/esm/api/resources/statistic/client/Client.d.mts +51 -52
  199. package/dist/esm/api/resources/statistic/client/Client.mjs +79 -132
  200. package/dist/esm/api/resources/statistic/client/requests/BasicStatsRequest.d.mts +2 -2
  201. package/dist/esm/api/resources/statistic/types/StatBasicExtendedQueryRecord.d.mts +76 -0
  202. package/dist/esm/api/resources/statistic/types/StatBasicExtendedQueryRecord.mjs +2 -0
  203. package/dist/esm/api/resources/statistic/types/index.d.mts +1 -0
  204. package/dist/esm/api/resources/statistic/types/index.mjs +1 -0
  205. package/dist/esm/api/resources/subscription/client/Client.d.mts +14 -15
  206. package/dist/esm/api/resources/subscription/client/Client.mjs +21 -77
  207. package/dist/esm/api/resources/templates/client/Client.d.mts +16 -17
  208. package/dist/esm/api/resources/templates/client/Client.mjs +27 -83
  209. package/dist/esm/api/resources/tokenStorage/client/Client.d.mts +14 -15
  210. package/dist/esm/api/resources/tokenStorage/client/Client.mjs +21 -77
  211. package/dist/esm/api/resources/tokenStorage/types/GetMethodResponse.d.mts +1 -1
  212. package/dist/esm/api/resources/user/client/Client.d.mts +55 -34
  213. package/dist/esm/api/resources/user/client/Client.mjs +83 -221
  214. package/dist/esm/api/resources/vendor/client/Client.d.mts +14 -15
  215. package/dist/esm/api/resources/vendor/client/Client.mjs +22 -78
  216. package/dist/esm/api/resources/wallet/client/Client.d.mts +14 -15
  217. package/dist/esm/api/resources/wallet/client/Client.mjs +22 -78
  218. package/dist/esm/api/types/ApplicationDetailsRecord.d.mts +2 -2
  219. package/dist/esm/api/types/Frequency.d.mts +1 -1
  220. package/dist/esm/api/types/Frequency.mjs +1 -1
  221. package/dist/esm/api/types/FrequencyList.d.mts +1 -1
  222. package/dist/esm/api/types/NotificationContent.d.mts +1 -0
  223. package/dist/esm/api/types/NotificationContent.mjs +1 -0
  224. package/dist/esm/api/types/NotificationStandardRequest.d.mts +1 -0
  225. package/dist/esm/api/types/NotificationStandardRequest.mjs +1 -0
  226. package/dist/esm/api/types/PayorDataResponse.d.mts +1 -1
  227. package/dist/esm/api/types/QueryResponseSettlements.d.mts +1 -1
  228. package/dist/esm/auth/HeaderAuthProvider.d.mts +16 -0
  229. package/dist/esm/auth/HeaderAuthProvider.mjs +34 -0
  230. package/dist/esm/auth/index.d.mts +1 -0
  231. package/dist/esm/auth/index.mjs +1 -0
  232. package/dist/esm/core/auth/AuthProvider.d.mts +7 -0
  233. package/dist/esm/core/auth/AuthProvider.mjs +1 -0
  234. package/dist/esm/core/auth/AuthRequest.d.mts +9 -0
  235. package/dist/esm/core/auth/AuthRequest.mjs +1 -0
  236. package/dist/esm/core/auth/BasicAuth.d.mts +8 -0
  237. package/dist/esm/core/auth/BasicAuth.mjs +24 -0
  238. package/dist/esm/core/auth/BearerToken.d.mts +7 -0
  239. package/dist/esm/core/auth/BearerToken.mjs +13 -0
  240. package/dist/esm/core/auth/NoOpAuthProvider.d.mts +5 -0
  241. package/dist/esm/core/auth/NoOpAuthProvider.mjs +5 -0
  242. package/dist/esm/core/auth/index.d.mts +5 -0
  243. package/dist/esm/core/auth/index.mjs +3 -0
  244. package/dist/esm/core/base64.d.mts +2 -0
  245. package/dist/esm/core/base64.mjs +22 -0
  246. package/dist/esm/core/fetcher/BinaryResponse.d.mts +6 -7
  247. package/dist/esm/core/fetcher/Fetcher.d.mts +5 -1
  248. package/dist/esm/core/fetcher/Fetcher.mjs +42 -24
  249. package/dist/esm/core/fetcher/getResponseBody.mjs +18 -4
  250. package/dist/esm/core/fetcher/makeRequest.d.mts +1 -1
  251. package/dist/esm/core/fetcher/makeRequest.mjs +0 -2
  252. package/dist/esm/core/fetcher/requestWithRetries.mjs +0 -9
  253. package/dist/esm/core/fetcher/signals.d.mts +1 -7
  254. package/dist/esm/core/fetcher/signals.mjs +0 -12
  255. package/dist/esm/core/index.d.mts +2 -0
  256. package/dist/esm/core/index.mjs +2 -0
  257. package/dist/esm/core/logging/logger.mjs +1 -1
  258. package/dist/esm/core/runtime/runtime.mjs +11 -10
  259. package/dist/esm/core/url/join.mjs +0 -1
  260. package/dist/esm/errors/PayabliError.mjs +5 -1
  261. package/dist/esm/errors/PayabliTimeoutError.mjs +5 -1
  262. package/dist/esm/errors/handleNonStatusCodeError.d.mts +2 -0
  263. package/dist/esm/errors/handleNonStatusCodeError.mjs +29 -0
  264. package/dist/esm/version.d.mts +1 -1
  265. package/dist/esm/version.mjs +1 -1
  266. package/package.json +5 -2
  267. package/reference.md +768 -478
  268. package/dist/cjs/core/fetcher/ResponseWithBody.d.ts +0 -4
  269. package/dist/cjs/core/fetcher/ResponseWithBody.js +0 -6
  270. package/dist/esm/core/fetcher/ResponseWithBody.d.mts +0 -4
  271. package/dist/esm/core/fetcher/ResponseWithBody.mjs +0 -3
@@ -19,21 +19,23 @@ var __rest = (this && this.__rest) || function (s, e) {
19
19
  }
20
20
  return t;
21
21
  };
22
+ import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
22
23
  import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
23
24
  import * as core from "../../../../core/index.mjs";
24
25
  import * as environments from "../../../../environments.mjs";
26
+ import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.mjs";
25
27
  import * as errors from "../../../../errors/index.mjs";
26
28
  import * as Payabli from "../../../index.mjs";
27
- export class ChargeBacks {
28
- constructor(_options = {}) {
29
- this._options = _options;
29
+ export class ChargeBacksClient {
30
+ constructor(options = {}) {
31
+ this._options = normalizeClientOptionsWithAuth(options);
30
32
  }
31
33
  /**
32
34
  * Add a response to a chargeback or ACH return.
33
35
  *
34
- * @param {number} id - ID of the chargeback or return record.
36
+ * @param {number} Id - ID of the chargeback or return record.
35
37
  * @param {Payabli.ResponseChargeBack} request
36
- * @param {ChargeBacks.RequestOptions} requestOptions - Request-specific configuration.
38
+ * @param {ChargeBacksClient.RequestOptions} requestOptions - Request-specific configuration.
37
39
  *
38
40
  * @throws {@link Payabli.BadRequestError}
39
41
  * @throws {@link Payabli.UnauthorizedError}
@@ -45,16 +47,17 @@ export class ChargeBacks {
45
47
  * idempotencyKey: "6B29FC40-CA47-1067-B31D-00DD010662DA"
46
48
  * })
47
49
  */
48
- addResponse(id, request = {}, requestOptions) {
49
- return core.HttpResponsePromise.fromPromise(this.__addResponse(id, request, requestOptions));
50
+ addResponse(Id, request = {}, requestOptions) {
51
+ return core.HttpResponsePromise.fromPromise(this.__addResponse(Id, request, requestOptions));
50
52
  }
51
- __addResponse(id_1) {
52
- return __awaiter(this, arguments, void 0, function* (id, request = {}, requestOptions) {
53
+ __addResponse(Id_1) {
54
+ return __awaiter(this, arguments, void 0, function* (Id, request = {}, requestOptions) {
53
55
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
54
56
  const { idempotencyKey } = request, _body = __rest(request, ["idempotencyKey"]);
55
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({ idempotencyKey: idempotencyKey != null ? idempotencyKey : undefined }, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
57
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
58
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ idempotencyKey: idempotencyKey != null ? idempotencyKey : undefined }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
56
59
  const _response = yield core.fetcher({
57
- 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, `ChargeBacks/response/${core.url.encodePathParam(id)}`),
60
+ 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, `ChargeBacks/response/${core.url.encodePathParam(Id)}`),
58
61
  method: "POST",
59
62
  headers: _headers,
60
63
  contentType: "application/json",
@@ -88,28 +91,14 @@ export class ChargeBacks {
88
91
  });
89
92
  }
90
93
  }
91
- switch (_response.error.reason) {
92
- case "non-json":
93
- throw new errors.PayabliError({
94
- statusCode: _response.error.statusCode,
95
- body: _response.error.rawBody,
96
- rawResponse: _response.rawResponse,
97
- });
98
- case "timeout":
99
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling POST /ChargeBacks/response/{Id}.");
100
- case "unknown":
101
- throw new errors.PayabliError({
102
- message: _response.error.errorMessage,
103
- rawResponse: _response.rawResponse,
104
- });
105
- }
94
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/ChargeBacks/response/{Id}");
106
95
  });
107
96
  }
108
97
  /**
109
98
  * Retrieves a chargeback record and its details.
110
99
  *
111
- * @param {number} id - ID of the chargeback or return record. This is returned as `chargebackId` in the [RecievedChargeback](/developers/developer-guides/webhook-payloads#receivedChargeback) and [ReceivedAchReturn](/developers/developer-guides/webhook-payloads#receivedachreturn) webhook notifications.
112
- * @param {ChargeBacks.RequestOptions} requestOptions - Request-specific configuration.
100
+ * @param {number} Id - ID of the chargeback or return record. This is returned as `chargebackId` in the [RecievedChargeback](/developers/developer-guides/webhook-payloads#receivedChargeback) and [ReceivedAchReturn](/developers/developer-guides/webhook-payloads#receivedachreturn) webhook notifications.
101
+ * @param {ChargeBacksClient.RequestOptions} requestOptions - Request-specific configuration.
113
102
  *
114
103
  * @throws {@link Payabli.BadRequestError}
115
104
  * @throws {@link Payabli.UnauthorizedError}
@@ -119,15 +108,16 @@ export class ChargeBacks {
119
108
  * @example
120
109
  * await client.chargeBacks.getChargeback(1000000)
121
110
  */
122
- getChargeback(id, requestOptions) {
123
- return core.HttpResponsePromise.fromPromise(this.__getChargeback(id, requestOptions));
111
+ getChargeback(Id, requestOptions) {
112
+ return core.HttpResponsePromise.fromPromise(this.__getChargeback(Id, requestOptions));
124
113
  }
125
- __getChargeback(id, requestOptions) {
114
+ __getChargeback(Id, requestOptions) {
126
115
  return __awaiter(this, void 0, void 0, function* () {
127
116
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
128
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
117
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
118
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
129
119
  const _response = yield core.fetcher({
130
- 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, `ChargeBacks/read/${core.url.encodePathParam(id)}`),
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, `ChargeBacks/read/${core.url.encodePathParam(Id)}`),
131
121
  method: "GET",
132
122
  headers: _headers,
133
123
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
@@ -158,27 +148,15 @@ export class ChargeBacks {
158
148
  });
159
149
  }
160
150
  }
161
- switch (_response.error.reason) {
162
- case "non-json":
163
- throw new errors.PayabliError({
164
- statusCode: _response.error.statusCode,
165
- body: _response.error.rawBody,
166
- rawResponse: _response.rawResponse,
167
- });
168
- case "timeout":
169
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling GET /ChargeBacks/read/{Id}.");
170
- case "unknown":
171
- throw new errors.PayabliError({
172
- message: _response.error.errorMessage,
173
- rawResponse: _response.rawResponse,
174
- });
175
- }
151
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/ChargeBacks/read/{Id}");
176
152
  });
177
153
  }
178
154
  /**
155
+ * Retrieves a chargeback attachment file by its file name.
156
+ *
157
+ * @param {number} Id - The ID of chargeback or return record.
179
158
  * @param {string} fileName - The chargeback attachment's file name.
180
- * @param {number} id - The ID of chargeback or return record.
181
- * @param {ChargeBacks.RequestOptions} requestOptions - Request-specific configuration.
159
+ * @param {ChargeBacksClient.RequestOptions} requestOptions - Request-specific configuration.
182
160
  *
183
161
  * @throws {@link Payabli.BadRequestError}
184
162
  * @throws {@link Payabli.UnauthorizedError}
@@ -186,17 +164,18 @@ export class ChargeBacks {
186
164
  * @throws {@link Payabli.ServiceUnavailableError}
187
165
  *
188
166
  * @example
189
- * await client.chargeBacks.getChargebackAttachment("fileName", 1000000)
167
+ * await client.chargeBacks.getChargebackAttachment(1000000, "fileName")
190
168
  */
191
- getChargebackAttachment(fileName, id, requestOptions) {
192
- return core.HttpResponsePromise.fromPromise(this.__getChargebackAttachment(fileName, id, requestOptions));
169
+ getChargebackAttachment(Id, fileName, requestOptions) {
170
+ return core.HttpResponsePromise.fromPromise(this.__getChargebackAttachment(Id, fileName, requestOptions));
193
171
  }
194
- __getChargebackAttachment(fileName, id, requestOptions) {
172
+ __getChargebackAttachment(Id, fileName, requestOptions) {
195
173
  return __awaiter(this, void 0, void 0, function* () {
196
174
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
197
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
175
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
176
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
198
177
  const _response = yield core.fetcher({
199
- 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, `ChargeBacks/getChargebackAttachments/${core.url.encodePathParam(id)}/${core.url.encodePathParam(fileName)}`),
178
+ 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, `ChargeBacks/getChargebackAttachments/${core.url.encodePathParam(Id)}/${core.url.encodePathParam(fileName)}`),
200
179
  method: "GET",
201
180
  headers: _headers,
202
181
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
@@ -228,27 +207,7 @@ export class ChargeBacks {
228
207
  });
229
208
  }
230
209
  }
231
- switch (_response.error.reason) {
232
- case "non-json":
233
- throw new errors.PayabliError({
234
- statusCode: _response.error.statusCode,
235
- body: _response.error.rawBody,
236
- rawResponse: _response.rawResponse,
237
- });
238
- case "timeout":
239
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling GET /ChargeBacks/getChargebackAttachments/{Id}/{fileName}.");
240
- case "unknown":
241
- throw new errors.PayabliError({
242
- message: _response.error.errorMessage,
243
- rawResponse: _response.rawResponse,
244
- });
245
- }
246
- });
247
- }
248
- _getCustomAuthorizationHeaders() {
249
- return __awaiter(this, void 0, void 0, function* () {
250
- const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
251
- return { requestToken: apiKeyValue };
210
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/ChargeBacks/getChargebackAttachments/{Id}/{fileName}");
252
211
  });
253
212
  }
254
213
  }
@@ -1,20 +1,20 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
2
3
  import * as core from "../../../../core/index.mjs";
3
4
  import * as Payabli from "../../../index.mjs";
4
- export declare namespace CheckCapture {
5
- interface Options extends BaseClientOptions {
6
- }
5
+ export declare namespace CheckCaptureClient {
6
+ type Options = BaseClientOptions;
7
7
  interface RequestOptions extends BaseRequestOptions {
8
8
  }
9
9
  }
10
- export declare class CheckCapture {
11
- protected readonly _options: CheckCapture.Options;
12
- constructor(_options?: CheckCapture.Options);
10
+ export declare class CheckCaptureClient {
11
+ protected readonly _options: NormalizedClientOptionsWithAuth<CheckCaptureClient.Options>;
12
+ constructor(options?: CheckCaptureClient.Options);
13
13
  /**
14
14
  * Captures a check for Remote Deposit Capture (RDC) using the provided check images and details. This endpoint handles the OCR extraction of check data including MICR, routing number, account number, and amount. See the [RDC guide](/developers/developer-guides/pay-in-rdc) for more details.
15
15
  *
16
16
  * @param {Payabli.CheckCaptureRequestBody} request
17
- * @param {CheckCapture.RequestOptions} requestOptions - Request-specific configuration.
17
+ * @param {CheckCaptureClient.RequestOptions} requestOptions - Request-specific configuration.
18
18
  *
19
19
  * @throws {@link Payabli.BadRequestError}
20
20
  * @throws {@link Payabli.UnauthorizedError}
@@ -29,7 +29,6 @@ export declare class CheckCapture {
29
29
  * checkAmount: 12550
30
30
  * })
31
31
  */
32
- checkProcessing(request: Payabli.CheckCaptureRequestBody, requestOptions?: CheckCapture.RequestOptions): core.HttpResponsePromise<Payabli.CheckCaptureResponse>;
32
+ checkProcessing(request: Payabli.CheckCaptureRequestBody, requestOptions?: CheckCaptureClient.RequestOptions): core.HttpResponsePromise<Payabli.CheckCaptureResponse>;
33
33
  private __checkProcessing;
34
- protected _getCustomAuthorizationHeaders(): Promise<Record<string, string | undefined>>;
35
34
  }
@@ -8,20 +8,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
11
+ import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
12
+ import { mergeHeaders } from "../../../../core/headers.mjs";
12
13
  import * as core from "../../../../core/index.mjs";
13
14
  import * as environments from "../../../../environments.mjs";
15
+ import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.mjs";
14
16
  import * as errors from "../../../../errors/index.mjs";
15
17
  import * as Payabli from "../../../index.mjs";
16
- export class CheckCapture {
17
- constructor(_options = {}) {
18
- this._options = _options;
18
+ export class CheckCaptureClient {
19
+ constructor(options = {}) {
20
+ this._options = normalizeClientOptionsWithAuth(options);
19
21
  }
20
22
  /**
21
23
  * Captures a check for Remote Deposit Capture (RDC) using the provided check images and details. This endpoint handles the OCR extraction of check data including MICR, routing number, account number, and amount. See the [RDC guide](/developers/developer-guides/pay-in-rdc) for more details.
22
24
  *
23
25
  * @param {Payabli.CheckCaptureRequestBody} request
24
- * @param {CheckCapture.RequestOptions} requestOptions - Request-specific configuration.
26
+ * @param {CheckCaptureClient.RequestOptions} requestOptions - Request-specific configuration.
25
27
  *
26
28
  * @throws {@link Payabli.BadRequestError}
27
29
  * @throws {@link Payabli.UnauthorizedError}
@@ -42,7 +44,8 @@ export class CheckCapture {
42
44
  __checkProcessing(request, requestOptions) {
43
45
  return __awaiter(this, void 0, void 0, function* () {
44
46
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
45
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
47
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
48
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
46
49
  const _response = yield core.fetcher({
47
50
  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, "CheckCapture/CheckProcessing"),
48
51
  method: "POST",
@@ -78,27 +81,7 @@ export class CheckCapture {
78
81
  });
79
82
  }
80
83
  }
81
- switch (_response.error.reason) {
82
- case "non-json":
83
- throw new errors.PayabliError({
84
- statusCode: _response.error.statusCode,
85
- body: _response.error.rawBody,
86
- rawResponse: _response.rawResponse,
87
- });
88
- case "timeout":
89
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling POST /CheckCapture/CheckProcessing.");
90
- case "unknown":
91
- throw new errors.PayabliError({
92
- message: _response.error.errorMessage,
93
- rawResponse: _response.rawResponse,
94
- });
95
- }
96
- });
97
- }
98
- _getCustomAuthorizationHeaders() {
99
- return __awaiter(this, void 0, void 0, function* () {
100
- const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
101
- return { requestToken: apiKeyValue };
84
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/CheckCapture/CheckProcessing");
102
85
  });
103
86
  }
104
87
  }
@@ -1,21 +1,21 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
2
3
  import * as core from "../../../../core/index.mjs";
3
4
  import * as Payabli from "../../../index.mjs";
4
- export declare namespace Cloud {
5
- interface Options extends BaseClientOptions {
6
- }
5
+ export declare namespace CloudClient {
6
+ type Options = BaseClientOptions;
7
7
  interface RequestOptions extends BaseRequestOptions {
8
8
  }
9
9
  }
10
- export declare class Cloud {
11
- protected readonly _options: Cloud.Options;
12
- constructor(_options?: Cloud.Options);
10
+ export declare class CloudClient {
11
+ protected readonly _options: NormalizedClientOptionsWithAuth<CloudClient.Options>;
12
+ constructor(options?: CloudClient.Options);
13
13
  /**
14
14
  * Register a cloud device to an entrypoint. See [Devices Quickstart](/developers/developer-guides/devices-quickstart#devices-quickstart) for a complete guide.
15
15
  *
16
16
  * @param {string} entry - The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)
17
17
  * @param {Payabli.DeviceEntry} request
18
- * @param {Cloud.RequestOptions} requestOptions - Request-specific configuration.
18
+ * @param {CloudClient.RequestOptions} requestOptions - Request-specific configuration.
19
19
  *
20
20
  * @throws {@link Payabli.BadRequestError}
21
21
  * @throws {@link Payabli.UnauthorizedError}
@@ -28,14 +28,14 @@ export declare class Cloud {
28
28
  * description: "Front Desk POS"
29
29
  * })
30
30
  */
31
- addDevice(entry: string, request?: Payabli.DeviceEntry, requestOptions?: Cloud.RequestOptions): core.HttpResponsePromise<Payabli.AddDeviceResponse>;
31
+ addDevice(entry: string, request?: Payabli.DeviceEntry, requestOptions?: CloudClient.RequestOptions): core.HttpResponsePromise<Payabli.AddDeviceResponse>;
32
32
  private __addDevice;
33
33
  /**
34
34
  * Retrieve the registration history for a device.
35
35
  *
36
- * @param {string} deviceId - ID of the cloud device.
37
36
  * @param {string} entry - The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)
38
- * @param {Cloud.RequestOptions} requestOptions - Request-specific configuration.
37
+ * @param {string} deviceId - ID of the cloud device.
38
+ * @param {CloudClient.RequestOptions} requestOptions - Request-specific configuration.
39
39
  *
40
40
  * @throws {@link Payabli.BadRequestError}
41
41
  * @throws {@link Payabli.UnauthorizedError}
@@ -43,16 +43,16 @@ export declare class Cloud {
43
43
  * @throws {@link Payabli.ServiceUnavailableError}
44
44
  *
45
45
  * @example
46
- * await client.cloud.historyDevice("WXGDWB", "8cfec329267")
46
+ * await client.cloud.historyDevice("8cfec329267", "WXGDWB")
47
47
  */
48
- historyDevice(deviceId: string, entry: string, requestOptions?: Cloud.RequestOptions): core.HttpResponsePromise<Payabli.CloudQueryApiResponse>;
48
+ historyDevice(entry: string, deviceId: string, requestOptions?: CloudClient.RequestOptions): core.HttpResponsePromise<Payabli.CloudQueryApiResponse>;
49
49
  private __historyDevice;
50
50
  /**
51
51
  * Get a list of cloud devices registered to an entrypoint.
52
52
  *
53
53
  * @param {string} entry - The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)
54
54
  * @param {Payabli.ListDeviceRequest} request
55
- * @param {Cloud.RequestOptions} requestOptions - Request-specific configuration.
55
+ * @param {CloudClient.RequestOptions} requestOptions - Request-specific configuration.
56
56
  *
57
57
  * @throws {@link Payabli.BadRequestError}
58
58
  * @throws {@link Payabli.UnauthorizedError}
@@ -62,14 +62,14 @@ export declare class Cloud {
62
62
  * @example
63
63
  * await client.cloud.listDevice("8cfec329267")
64
64
  */
65
- listDevice(entry: string, request?: Payabli.ListDeviceRequest, requestOptions?: Cloud.RequestOptions): core.HttpResponsePromise<Payabli.CloudQueryApiResponse>;
65
+ listDevice(entry: string, request?: Payabli.ListDeviceRequest, requestOptions?: CloudClient.RequestOptions): core.HttpResponsePromise<Payabli.CloudQueryApiResponse>;
66
66
  private __listDevice;
67
67
  /**
68
68
  * Remove a cloud device from an entrypoint.
69
69
  *
70
- * @param {string} deviceId - ID of the cloud device.
71
70
  * @param {string} entry - The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)
72
- * @param {Cloud.RequestOptions} requestOptions - Request-specific configuration.
71
+ * @param {string} deviceId - ID of the cloud device.
72
+ * @param {CloudClient.RequestOptions} requestOptions - Request-specific configuration.
73
73
  *
74
74
  * @throws {@link Payabli.BadRequestError}
75
75
  * @throws {@link Payabli.UnauthorizedError}
@@ -77,9 +77,8 @@ export declare class Cloud {
77
77
  * @throws {@link Payabli.ServiceUnavailableError}
78
78
  *
79
79
  * @example
80
- * await client.cloud.removeDevice("6c361c7d-674c-44cc-b790-382b75d1xxx", "8cfec329267")
80
+ * await client.cloud.removeDevice("8cfec329267", "6c361c7d-674c-44cc-b790-382b75d1xxx")
81
81
  */
82
- removeDevice(deviceId: string, entry: string, requestOptions?: Cloud.RequestOptions): core.HttpResponsePromise<Payabli.RemoveDeviceResponse>;
82
+ removeDevice(entry: string, deviceId: string, requestOptions?: CloudClient.RequestOptions): core.HttpResponsePromise<Payabli.RemoveDeviceResponse>;
83
83
  private __removeDevice;
84
- protected _getCustomAuthorizationHeaders(): Promise<Record<string, string | undefined>>;
85
84
  }
@@ -19,21 +19,23 @@ var __rest = (this && this.__rest) || function (s, e) {
19
19
  }
20
20
  return t;
21
21
  };
22
+ import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
22
23
  import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
23
24
  import * as core from "../../../../core/index.mjs";
24
25
  import * as environments from "../../../../environments.mjs";
26
+ import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.mjs";
25
27
  import * as errors from "../../../../errors/index.mjs";
26
28
  import * as Payabli from "../../../index.mjs";
27
- export class Cloud {
28
- constructor(_options = {}) {
29
- this._options = _options;
29
+ export class CloudClient {
30
+ constructor(options = {}) {
31
+ this._options = normalizeClientOptionsWithAuth(options);
30
32
  }
31
33
  /**
32
34
  * Register a cloud device to an entrypoint. See [Devices Quickstart](/developers/developer-guides/devices-quickstart#devices-quickstart) for a complete guide.
33
35
  *
34
36
  * @param {string} entry - The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)
35
37
  * @param {Payabli.DeviceEntry} request
36
- * @param {Cloud.RequestOptions} requestOptions - Request-specific configuration.
38
+ * @param {CloudClient.RequestOptions} requestOptions - Request-specific configuration.
37
39
  *
38
40
  * @throws {@link Payabli.BadRequestError}
39
41
  * @throws {@link Payabli.UnauthorizedError}
@@ -53,7 +55,8 @@ export class Cloud {
53
55
  return __awaiter(this, arguments, void 0, function* (entry, request = {}, requestOptions) {
54
56
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
55
57
  const { idempotencyKey } = request, _body = __rest(request, ["idempotencyKey"]);
56
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({ idempotencyKey: idempotencyKey != null ? idempotencyKey : undefined }, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
58
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
59
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ idempotencyKey: idempotencyKey != null ? idempotencyKey : undefined }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
57
60
  const _response = yield core.fetcher({
58
61
  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, `Cloud/register/${core.url.encodePathParam(entry)}`),
59
62
  method: "POST",
@@ -89,29 +92,15 @@ export class Cloud {
89
92
  });
90
93
  }
91
94
  }
92
- switch (_response.error.reason) {
93
- case "non-json":
94
- throw new errors.PayabliError({
95
- statusCode: _response.error.statusCode,
96
- body: _response.error.rawBody,
97
- rawResponse: _response.rawResponse,
98
- });
99
- case "timeout":
100
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling POST /Cloud/register/{entry}.");
101
- case "unknown":
102
- throw new errors.PayabliError({
103
- message: _response.error.errorMessage,
104
- rawResponse: _response.rawResponse,
105
- });
106
- }
95
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/Cloud/register/{entry}");
107
96
  });
108
97
  }
109
98
  /**
110
99
  * Retrieve the registration history for a device.
111
100
  *
112
- * @param {string} deviceId - ID of the cloud device.
113
101
  * @param {string} entry - The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)
114
- * @param {Cloud.RequestOptions} requestOptions - Request-specific configuration.
102
+ * @param {string} deviceId - ID of the cloud device.
103
+ * @param {CloudClient.RequestOptions} requestOptions - Request-specific configuration.
115
104
  *
116
105
  * @throws {@link Payabli.BadRequestError}
117
106
  * @throws {@link Payabli.UnauthorizedError}
@@ -119,15 +108,16 @@ export class Cloud {
119
108
  * @throws {@link Payabli.ServiceUnavailableError}
120
109
  *
121
110
  * @example
122
- * await client.cloud.historyDevice("WXGDWB", "8cfec329267")
111
+ * await client.cloud.historyDevice("8cfec329267", "WXGDWB")
123
112
  */
124
- historyDevice(deviceId, entry, requestOptions) {
125
- return core.HttpResponsePromise.fromPromise(this.__historyDevice(deviceId, entry, requestOptions));
113
+ historyDevice(entry, deviceId, requestOptions) {
114
+ return core.HttpResponsePromise.fromPromise(this.__historyDevice(entry, deviceId, requestOptions));
126
115
  }
127
- __historyDevice(deviceId, entry, requestOptions) {
116
+ __historyDevice(entry, deviceId, requestOptions) {
128
117
  return __awaiter(this, void 0, void 0, function* () {
129
118
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
130
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
119
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
120
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
131
121
  const _response = yield core.fetcher({
132
122
  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, `Cloud/history/${core.url.encodePathParam(entry)}/${core.url.encodePathParam(deviceId)}`),
133
123
  method: "GET",
@@ -160,21 +150,7 @@ export class Cloud {
160
150
  });
161
151
  }
162
152
  }
163
- switch (_response.error.reason) {
164
- case "non-json":
165
- throw new errors.PayabliError({
166
- statusCode: _response.error.statusCode,
167
- body: _response.error.rawBody,
168
- rawResponse: _response.rawResponse,
169
- });
170
- case "timeout":
171
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling GET /Cloud/history/{entry}/{deviceId}.");
172
- case "unknown":
173
- throw new errors.PayabliError({
174
- message: _response.error.errorMessage,
175
- rawResponse: _response.rawResponse,
176
- });
177
- }
153
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/Cloud/history/{entry}/{deviceId}");
178
154
  });
179
155
  }
180
156
  /**
@@ -182,7 +158,7 @@ export class Cloud {
182
158
  *
183
159
  * @param {string} entry - The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)
184
160
  * @param {Payabli.ListDeviceRequest} request
185
- * @param {Cloud.RequestOptions} requestOptions - Request-specific configuration.
161
+ * @param {CloudClient.RequestOptions} requestOptions - Request-specific configuration.
186
162
  *
187
163
  * @throws {@link Payabli.BadRequestError}
188
164
  * @throws {@link Payabli.UnauthorizedError}
@@ -203,7 +179,8 @@ export class Cloud {
203
179
  if (forceRefresh != null) {
204
180
  _queryParams.forceRefresh = forceRefresh.toString();
205
181
  }
206
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
182
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
183
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
207
184
  const _response = yield core.fetcher({
208
185
  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, `Cloud/list/${core.url.encodePathParam(entry)}`),
209
186
  method: "GET",
@@ -236,29 +213,15 @@ export class Cloud {
236
213
  });
237
214
  }
238
215
  }
239
- switch (_response.error.reason) {
240
- case "non-json":
241
- throw new errors.PayabliError({
242
- statusCode: _response.error.statusCode,
243
- body: _response.error.rawBody,
244
- rawResponse: _response.rawResponse,
245
- });
246
- case "timeout":
247
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling GET /Cloud/list/{entry}.");
248
- case "unknown":
249
- throw new errors.PayabliError({
250
- message: _response.error.errorMessage,
251
- rawResponse: _response.rawResponse,
252
- });
253
- }
216
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/Cloud/list/{entry}");
254
217
  });
255
218
  }
256
219
  /**
257
220
  * Remove a cloud device from an entrypoint.
258
221
  *
259
- * @param {string} deviceId - ID of the cloud device.
260
222
  * @param {string} entry - The paypoint's entrypoint identifier. [Learn more](/api-reference/api-overview#entrypoint-vs-entry)
261
- * @param {Cloud.RequestOptions} requestOptions - Request-specific configuration.
223
+ * @param {string} deviceId - ID of the cloud device.
224
+ * @param {CloudClient.RequestOptions} requestOptions - Request-specific configuration.
262
225
  *
263
226
  * @throws {@link Payabli.BadRequestError}
264
227
  * @throws {@link Payabli.UnauthorizedError}
@@ -266,15 +229,16 @@ export class Cloud {
266
229
  * @throws {@link Payabli.ServiceUnavailableError}
267
230
  *
268
231
  * @example
269
- * await client.cloud.removeDevice("6c361c7d-674c-44cc-b790-382b75d1xxx", "8cfec329267")
232
+ * await client.cloud.removeDevice("8cfec329267", "6c361c7d-674c-44cc-b790-382b75d1xxx")
270
233
  */
271
- removeDevice(deviceId, entry, requestOptions) {
272
- return core.HttpResponsePromise.fromPromise(this.__removeDevice(deviceId, entry, requestOptions));
234
+ removeDevice(entry, deviceId, requestOptions) {
235
+ return core.HttpResponsePromise.fromPromise(this.__removeDevice(entry, deviceId, requestOptions));
273
236
  }
274
- __removeDevice(deviceId, entry, requestOptions) {
237
+ __removeDevice(entry, deviceId, requestOptions) {
275
238
  return __awaiter(this, void 0, void 0, function* () {
276
239
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
277
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
240
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
241
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
278
242
  const _response = yield core.fetcher({
279
243
  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, `Cloud/register/${core.url.encodePathParam(entry)}/${core.url.encodePathParam(deviceId)}`),
280
244
  method: "DELETE",
@@ -307,27 +271,7 @@ export class Cloud {
307
271
  });
308
272
  }
309
273
  }
310
- switch (_response.error.reason) {
311
- case "non-json":
312
- throw new errors.PayabliError({
313
- statusCode: _response.error.statusCode,
314
- body: _response.error.rawBody,
315
- rawResponse: _response.rawResponse,
316
- });
317
- case "timeout":
318
- throw new errors.PayabliTimeoutError("Timeout exceeded when calling DELETE /Cloud/register/{entry}/{deviceId}.");
319
- case "unknown":
320
- throw new errors.PayabliError({
321
- message: _response.error.errorMessage,
322
- rawResponse: _response.rawResponse,
323
- });
324
- }
325
- });
326
- }
327
- _getCustomAuthorizationHeaders() {
328
- return __awaiter(this, void 0, void 0, function* () {
329
- const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
330
- return { requestToken: apiKeyValue };
274
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/Cloud/register/{entry}/{deviceId}");
331
275
  });
332
276
  }
333
277
  }