orb-billing 1.20.0 → 1.20.2

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 (278) hide show
  1. package/README.md +1 -1
  2. package/dist/sdk/availability.js +17 -36
  3. package/dist/sdk/coupon.js +85 -180
  4. package/dist/sdk/credit.js +102 -216
  5. package/dist/sdk/creditnote.js +34 -72
  6. package/dist/sdk/customer.js +221 -468
  7. package/dist/sdk/event.js +153 -324
  8. package/dist/sdk/invoice.js +136 -288
  9. package/dist/sdk/item.js +34 -72
  10. package/dist/sdk/metric.js +51 -108
  11. package/dist/sdk/models/errors/fivehundrederror.d.ts +11 -0
  12. package/dist/sdk/models/{shared → errors}/fivehundrederror.js +21 -11
  13. package/dist/sdk/models/errors/fourhundredandoneerror.d.ts +11 -0
  14. package/dist/sdk/models/{shared → errors}/fourhundredandoneerror.js +21 -15
  15. package/dist/sdk/models/errors/fourhundredandtwentynineerror.d.ts +11 -0
  16. package/dist/sdk/models/{shared → errors}/fourhundredandtwentynineerror.js +21 -15
  17. package/dist/sdk/models/errors/index.d.ts +3 -0
  18. package/dist/sdk/models/errors/index.js +3 -0
  19. package/dist/sdk/models/operations/addeditpriceintervals.d.ts +0 -28
  20. package/dist/sdk/models/operations/addeditpriceintervals.js +0 -28
  21. package/dist/sdk/models/operations/amendevent.d.ts +0 -28
  22. package/dist/sdk/models/operations/amendevent.js +0 -28
  23. package/dist/sdk/models/operations/amendusage.d.ts +0 -28
  24. package/dist/sdk/models/operations/amendusage.js +0 -28
  25. package/dist/sdk/models/operations/amendusageexternalcustomerid.d.ts +0 -28
  26. package/dist/sdk/models/operations/amendusageexternalcustomerid.js +0 -28
  27. package/dist/sdk/models/operations/archivecoupon.d.ts +0 -28
  28. package/dist/sdk/models/operations/archivecoupon.js +0 -28
  29. package/dist/sdk/models/operations/cancelsubscription.d.ts +0 -28
  30. package/dist/sdk/models/operations/cancelsubscription.js +0 -28
  31. package/dist/sdk/models/operations/closebackfill.d.ts +0 -28
  32. package/dist/sdk/models/operations/closebackfill.js +0 -28
  33. package/dist/sdk/models/operations/createbackfill.d.ts +0 -28
  34. package/dist/sdk/models/operations/createbackfill.js +0 -28
  35. package/dist/sdk/models/operations/createcoupon.d.ts +0 -28
  36. package/dist/sdk/models/operations/createcoupon.js +0 -28
  37. package/dist/sdk/models/operations/createcustomer.d.ts +0 -28
  38. package/dist/sdk/models/operations/createcustomer.js +0 -28
  39. package/dist/sdk/models/operations/createcustomerbalancetransaction.d.ts +0 -28
  40. package/dist/sdk/models/operations/createcustomerbalancetransaction.js +0 -28
  41. package/dist/sdk/models/operations/createinvoice.d.ts +0 -28
  42. package/dist/sdk/models/operations/createinvoice.js +0 -28
  43. package/dist/sdk/models/operations/createinvoicelineitem.d.ts +0 -28
  44. package/dist/sdk/models/operations/createinvoicelineitem.js +0 -28
  45. package/dist/sdk/models/operations/createledgerentry.d.ts +0 -29
  46. package/dist/sdk/models/operations/createledgerentry.js +0 -52
  47. package/dist/sdk/models/operations/createledgerentryexternalid.d.ts +0 -29
  48. package/dist/sdk/models/operations/createledgerentryexternalid.js +0 -52
  49. package/dist/sdk/models/operations/createmetric.d.ts +0 -28
  50. package/dist/sdk/models/operations/createmetric.js +0 -28
  51. package/dist/sdk/models/operations/createplan.d.ts +0 -28
  52. package/dist/sdk/models/operations/createplan.js +0 -28
  53. package/dist/sdk/models/operations/createprice.d.ts +0 -29
  54. package/dist/sdk/models/operations/createprice.js +0 -52
  55. package/dist/sdk/models/operations/createsubscription.d.ts +0 -28
  56. package/dist/sdk/models/operations/createsubscription.js +0 -28
  57. package/dist/sdk/models/operations/deletecustomer.d.ts +0 -28
  58. package/dist/sdk/models/operations/deletecustomer.js +0 -28
  59. package/dist/sdk/models/operations/deprecateevent.d.ts +0 -28
  60. package/dist/sdk/models/operations/deprecateevent.js +0 -28
  61. package/dist/sdk/models/operations/fetchbackfill.d.ts +0 -28
  62. package/dist/sdk/models/operations/fetchbackfill.js +0 -28
  63. package/dist/sdk/models/operations/fetchcoupon.d.ts +0 -28
  64. package/dist/sdk/models/operations/fetchcoupon.js +0 -28
  65. package/dist/sdk/models/operations/fetchcreditnote.d.ts +0 -28
  66. package/dist/sdk/models/operations/fetchcreditnote.js +0 -28
  67. package/dist/sdk/models/operations/fetchcustomer.d.ts +0 -28
  68. package/dist/sdk/models/operations/fetchcustomer.js +0 -28
  69. package/dist/sdk/models/operations/fetchcustomercosts.d.ts +0 -28
  70. package/dist/sdk/models/operations/fetchcustomercosts.js +0 -28
  71. package/dist/sdk/models/operations/fetchcustomercostsexternalid.d.ts +0 -28
  72. package/dist/sdk/models/operations/fetchcustomercostsexternalid.js +0 -28
  73. package/dist/sdk/models/operations/fetchcustomercredits.d.ts +0 -28
  74. package/dist/sdk/models/operations/fetchcustomercredits.js +0 -28
  75. package/dist/sdk/models/operations/fetchcustomercreditsexternalid.d.ts +0 -28
  76. package/dist/sdk/models/operations/fetchcustomercreditsexternalid.js +0 -28
  77. package/dist/sdk/models/operations/fetchcustomercreditsledger.d.ts +0 -28
  78. package/dist/sdk/models/operations/fetchcustomercreditsledger.js +0 -28
  79. package/dist/sdk/models/operations/fetchcustomercreditsledgerexternalid.d.ts +0 -28
  80. package/dist/sdk/models/operations/fetchcustomercreditsledgerexternalid.js +0 -28
  81. package/dist/sdk/models/operations/fetchcustomerexternalid.d.ts +0 -28
  82. package/dist/sdk/models/operations/fetchcustomerexternalid.js +0 -28
  83. package/dist/sdk/models/operations/fetchinvoice.d.ts +0 -28
  84. package/dist/sdk/models/operations/fetchinvoice.js +0 -28
  85. package/dist/sdk/models/operations/fetchitem.d.ts +0 -28
  86. package/dist/sdk/models/operations/fetchitem.js +0 -28
  87. package/dist/sdk/models/operations/fetchmetric.d.ts +0 -28
  88. package/dist/sdk/models/operations/fetchmetric.js +0 -28
  89. package/dist/sdk/models/operations/fetchplan.d.ts +0 -28
  90. package/dist/sdk/models/operations/fetchplan.js +0 -28
  91. package/dist/sdk/models/operations/fetchplanexternalid.d.ts +0 -28
  92. package/dist/sdk/models/operations/fetchplanexternalid.js +0 -28
  93. package/dist/sdk/models/operations/fetchprice.d.ts +0 -29
  94. package/dist/sdk/models/operations/fetchprice.js +0 -52
  95. package/dist/sdk/models/operations/fetchpriceexternalid.d.ts +0 -29
  96. package/dist/sdk/models/operations/fetchpriceexternalid.js +0 -52
  97. package/dist/sdk/models/operations/fetchsubscription.d.ts +0 -28
  98. package/dist/sdk/models/operations/fetchsubscription.js +0 -28
  99. package/dist/sdk/models/operations/fetchsubscriptioncosts.d.ts +0 -28
  100. package/dist/sdk/models/operations/fetchsubscriptioncosts.js +0 -28
  101. package/dist/sdk/models/operations/fetchsubscriptionschedule.d.ts +0 -28
  102. package/dist/sdk/models/operations/fetchsubscriptionschedule.js +0 -28
  103. package/dist/sdk/models/operations/fetchsubscriptionusage.d.ts +0 -29
  104. package/dist/sdk/models/operations/fetchsubscriptionusage.js +0 -52
  105. package/dist/sdk/models/operations/fetchupcominginvoice.d.ts +0 -28
  106. package/dist/sdk/models/operations/fetchupcominginvoice.js +0 -28
  107. package/dist/sdk/models/operations/ingest.d.ts +0 -28
  108. package/dist/sdk/models/operations/ingest.js +0 -28
  109. package/dist/sdk/models/operations/issueinvoice.d.ts +0 -28
  110. package/dist/sdk/models/operations/issueinvoice.js +0 -28
  111. package/dist/sdk/models/operations/listbackfills.d.ts +0 -28
  112. package/dist/sdk/models/operations/listbackfills.js +0 -28
  113. package/dist/sdk/models/operations/listbalancetransactions.d.ts +0 -28
  114. package/dist/sdk/models/operations/listbalancetransactions.js +0 -28
  115. package/dist/sdk/models/operations/listcoupons.d.ts +0 -28
  116. package/dist/sdk/models/operations/listcoupons.js +0 -28
  117. package/dist/sdk/models/operations/listcouponsubscriptions.d.ts +0 -28
  118. package/dist/sdk/models/operations/listcouponsubscriptions.js +0 -28
  119. package/dist/sdk/models/operations/listcreditnotes.d.ts +0 -28
  120. package/dist/sdk/models/operations/listcreditnotes.js +0 -28
  121. package/dist/sdk/models/operations/listcustomers.d.ts +0 -28
  122. package/dist/sdk/models/operations/listcustomers.js +0 -28
  123. package/dist/sdk/models/operations/listinvoices.d.ts +0 -28
  124. package/dist/sdk/models/operations/listinvoices.js +0 -28
  125. package/dist/sdk/models/operations/listitems.d.ts +0 -28
  126. package/dist/sdk/models/operations/listitems.js +0 -28
  127. package/dist/sdk/models/operations/listmetrics.d.ts +0 -28
  128. package/dist/sdk/models/operations/listmetrics.js +0 -28
  129. package/dist/sdk/models/operations/listplans.d.ts +0 -28
  130. package/dist/sdk/models/operations/listplans.js +0 -28
  131. package/dist/sdk/models/operations/listprices.d.ts +0 -28
  132. package/dist/sdk/models/operations/listprices.js +0 -28
  133. package/dist/sdk/models/operations/listsubscriptions.d.ts +0 -28
  134. package/dist/sdk/models/operations/listsubscriptions.js +0 -28
  135. package/dist/sdk/models/operations/markinvoiceaspaid.d.ts +0 -28
  136. package/dist/sdk/models/operations/markinvoiceaspaid.js +0 -28
  137. package/dist/sdk/models/operations/ping.d.ts +0 -28
  138. package/dist/sdk/models/operations/ping.js +0 -28
  139. package/dist/sdk/models/operations/revertbackfill.d.ts +0 -28
  140. package/dist/sdk/models/operations/revertbackfill.js +0 -28
  141. package/dist/sdk/models/operations/scheduleplanchange.d.ts +0 -28
  142. package/dist/sdk/models/operations/scheduleplanchange.js +0 -28
  143. package/dist/sdk/models/operations/searchevents.d.ts +0 -28
  144. package/dist/sdk/models/operations/searchevents.js +0 -28
  145. package/dist/sdk/models/operations/triggerphase.d.ts +0 -28
  146. package/dist/sdk/models/operations/triggerphase.js +0 -28
  147. package/dist/sdk/models/operations/unschedulecancellation.d.ts +0 -28
  148. package/dist/sdk/models/operations/unschedulecancellation.js +0 -28
  149. package/dist/sdk/models/operations/unschedulefixedfeequantity.d.ts +0 -28
  150. package/dist/sdk/models/operations/unschedulefixedfeequantity.js +0 -28
  151. package/dist/sdk/models/operations/unscheduleplanchange.d.ts +0 -28
  152. package/dist/sdk/models/operations/unscheduleplanchange.js +0 -28
  153. package/dist/sdk/models/operations/updatecustomer.d.ts +0 -28
  154. package/dist/sdk/models/operations/updatecustomer.js +0 -28
  155. package/dist/sdk/models/operations/updatecustomerexternalid.d.ts +0 -28
  156. package/dist/sdk/models/operations/updatecustomerexternalid.js +0 -28
  157. package/dist/sdk/models/operations/updatefixedfeequantity.d.ts +0 -28
  158. package/dist/sdk/models/operations/updatefixedfeequantity.js +0 -28
  159. package/dist/sdk/models/operations/updateplan.d.ts +0 -28
  160. package/dist/sdk/models/operations/updateplan.js +0 -28
  161. package/dist/sdk/models/operations/updateplanexternal.d.ts +0 -28
  162. package/dist/sdk/models/operations/updateplanexternal.js +0 -28
  163. package/dist/sdk/models/operations/voidinvoice.d.ts +0 -28
  164. package/dist/sdk/models/operations/voidinvoice.js +0 -28
  165. package/dist/sdk/models/shared/index.d.ts +0 -3
  166. package/dist/sdk/models/shared/index.js +0 -3
  167. package/dist/sdk/models/shared/security.d.ts +1 -1
  168. package/dist/sdk/models/shared/security.js +1 -1
  169. package/dist/sdk/plan.js +102 -216
  170. package/dist/sdk/price.js +68 -144
  171. package/dist/sdk/priceinterval.js +17 -36
  172. package/dist/sdk/sdk.js +2 -2
  173. package/dist/sdk/subscription.js +221 -468
  174. package/docs/models/errors/fivehundrederror.md +12 -0
  175. package/docs/models/errors/fourhundredandoneerror.md +12 -0
  176. package/docs/models/errors/fourhundredandtwentynineerror.md +12 -0
  177. package/docs/models/operations/addeditpriceintervalsresponse.md +6 -13
  178. package/docs/models/operations/amendeventresponse.md +6 -13
  179. package/docs/models/operations/amendusageexternalcustomeridresponse.md +6 -13
  180. package/docs/models/operations/amendusageresponse.md +6 -13
  181. package/docs/models/operations/archivecouponresponse.md +6 -13
  182. package/docs/models/operations/cancelsubscriptionresponse.md +6 -13
  183. package/docs/models/operations/closebackfillresponse.md +6 -13
  184. package/docs/models/operations/createbackfillresponse.md +6 -13
  185. package/docs/models/operations/createcouponresponse.md +6 -13
  186. package/docs/models/operations/createcustomerbalancetransactionresponse.md +6 -13
  187. package/docs/models/operations/createcustomerresponse.md +6 -13
  188. package/docs/models/operations/createinvoicelineitemresponse.md +6 -13
  189. package/docs/models/operations/createinvoiceresponse.md +6 -13
  190. package/docs/models/operations/createledgerentryexternalidresponse.md +6 -13
  191. package/docs/models/operations/createledgerentryresponse.md +6 -13
  192. package/docs/models/operations/createmetricresponse.md +6 -13
  193. package/docs/models/operations/createplanresponse.md +6 -13
  194. package/docs/models/operations/createpriceresponse.md +6 -13
  195. package/docs/models/operations/createsubscriptionresponse.md +6 -13
  196. package/docs/models/operations/deletecustomerresponse.md +6 -13
  197. package/docs/models/operations/deprecateeventresponse.md +6 -13
  198. package/docs/models/operations/fetchbackfillresponse.md +6 -13
  199. package/docs/models/operations/fetchcouponresponse.md +6 -13
  200. package/docs/models/operations/fetchcreditnoteresponse.md +6 -13
  201. package/docs/models/operations/fetchcustomercostsexternalidresponse.md +6 -13
  202. package/docs/models/operations/fetchcustomercostsresponse.md +6 -13
  203. package/docs/models/operations/fetchcustomercreditsexternalidresponse.md +6 -13
  204. package/docs/models/operations/fetchcustomercreditsledgerexternalidresponse.md +6 -13
  205. package/docs/models/operations/fetchcustomercreditsledgerresponse.md +6 -13
  206. package/docs/models/operations/fetchcustomercreditsresponse.md +6 -13
  207. package/docs/models/operations/fetchcustomerexternalidresponse.md +6 -13
  208. package/docs/models/operations/fetchcustomerresponse.md +6 -13
  209. package/docs/models/operations/fetchinvoiceresponse.md +6 -13
  210. package/docs/models/operations/fetchitemresponse.md +6 -13
  211. package/docs/models/operations/fetchmetricresponse.md +6 -13
  212. package/docs/models/operations/fetchplanexternalidresponse.md +6 -13
  213. package/docs/models/operations/fetchplanresponse.md +6 -13
  214. package/docs/models/operations/fetchpriceexternalidresponse.md +6 -13
  215. package/docs/models/operations/fetchpriceresponse.md +6 -13
  216. package/docs/models/operations/fetchsubscriptioncostsresponse.md +6 -13
  217. package/docs/models/operations/fetchsubscriptionresponse.md +6 -13
  218. package/docs/models/operations/fetchsubscriptionscheduleresponse.md +6 -13
  219. package/docs/models/operations/fetchsubscriptionusageresponse.md +6 -13
  220. package/docs/models/operations/fetchupcominginvoiceresponse.md +6 -13
  221. package/docs/models/operations/ingestresponse.md +6 -13
  222. package/docs/models/operations/issueinvoiceresponse.md +6 -13
  223. package/docs/models/operations/listbackfillsresponse.md +6 -13
  224. package/docs/models/operations/listbalancetransactionsresponse.md +6 -13
  225. package/docs/models/operations/listcouponsresponse.md +6 -13
  226. package/docs/models/operations/listcouponsubscriptionsresponse.md +6 -13
  227. package/docs/models/operations/listcreditnotesresponse.md +6 -13
  228. package/docs/models/operations/listcustomersresponse.md +6 -13
  229. package/docs/models/operations/listinvoicesresponse.md +6 -13
  230. package/docs/models/operations/listitemsresponse.md +6 -13
  231. package/docs/models/operations/listmetricsresponse.md +6 -13
  232. package/docs/models/operations/listplansresponse.md +6 -13
  233. package/docs/models/operations/listpricesresponse.md +6 -13
  234. package/docs/models/operations/listsubscriptionsresponse.md +6 -13
  235. package/docs/models/operations/markinvoiceaspaidresponse.md +6 -13
  236. package/docs/models/operations/pingresponse.md +6 -13
  237. package/docs/models/operations/revertbackfillresponse.md +6 -13
  238. package/docs/models/operations/scheduleplanchangeresponse.md +6 -13
  239. package/docs/models/operations/searcheventsresponse.md +6 -13
  240. package/docs/models/operations/triggerphaseresponse.md +6 -13
  241. package/docs/models/operations/unschedulecancellationresponse.md +6 -13
  242. package/docs/models/operations/unschedulefixedfeequantityresponse.md +6 -13
  243. package/docs/models/operations/unscheduleplanchangeresponse.md +6 -13
  244. package/docs/models/operations/updatecustomerexternalidresponse.md +6 -13
  245. package/docs/models/operations/updatecustomerresponse.md +6 -13
  246. package/docs/models/operations/updatefixedfeequantityresponse.md +6 -13
  247. package/docs/models/operations/updateplanexternalresponse.md +6 -13
  248. package/docs/models/operations/updateplanresponse.md +6 -13
  249. package/docs/models/operations/voidinvoiceresponse.md +6 -13
  250. package/docs/models/shared/security.md +1 -1
  251. package/docs/sdks/availability/README.md +1 -1
  252. package/docs/sdks/coupon/README.md +5 -5
  253. package/docs/sdks/credit/README.md +6 -6
  254. package/docs/sdks/creditnote/README.md +2 -2
  255. package/docs/sdks/customer/README.md +13 -13
  256. package/docs/sdks/event/README.md +9 -9
  257. package/docs/sdks/invoice/README.md +8 -8
  258. package/docs/sdks/item/README.md +2 -2
  259. package/docs/sdks/metric/README.md +3 -3
  260. package/docs/sdks/plan/README.md +6 -6
  261. package/docs/sdks/price/README.md +4 -4
  262. package/docs/sdks/priceinterval/README.md +1 -1
  263. package/docs/sdks/subscription/README.md +13 -13
  264. package/package.json +1 -1
  265. package/dist/sdk/models/shared/fivehundrederror.d.ts +0 -13
  266. package/dist/sdk/models/shared/fourhundredandoneerror.d.ts +0 -16
  267. package/dist/sdk/models/shared/fourhundredandtwentynineerror.d.ts +0 -16
  268. package/docs/models/shared/fivehundrederror.md +0 -12
  269. package/docs/models/shared/fivehundrederrortype.md +0 -8
  270. package/docs/models/shared/fourhundredandoneerror.md +0 -12
  271. package/docs/models/shared/fourhundredandoneerrorstatus.md +0 -8
  272. package/docs/models/shared/fourhundredandoneerrortype.md +0 -8
  273. package/docs/models/shared/fourhundredandtwentynineerror.md +0 -12
  274. package/docs/models/shared/fourhundredandtwentynineerrorstatus.md +0 -8
  275. package/docs/models/shared/fourhundredandtwentynineerrortype.md +0 -8
  276. /package/docs/models/{shared → errors}/fivehundrederrorheaders.md +0 -0
  277. /package/docs/models/{shared → errors}/fourhundredandoneerrorheaders.md +0 -0
  278. /package/docs/models/{shared → errors}/fourhundredandtwentynineerrorheaders.md +0 -0
@@ -198,7 +198,7 @@ var Credit = /** @class */ (function () {
198
198
  Credit.prototype.addByExternalId = function (externalCustomerId, requestBody, config) {
199
199
  var _a, _b;
200
200
  return __awaiter(this, void 0, void 0, function () {
201
- var req, baseURL, url, _c, reqBodyHeaders, reqBody, client, globalSecurity, properties, headers, httpRes, contentType, res, decodedRes;
201
+ var req, baseURL, url, _c, reqBodyHeaders, reqBody, client, globalSecurity, properties, headers, httpRes, contentType, res, decodedRes, err, err, err;
202
202
  var _d;
203
203
  return __generator(this, function (_e) {
204
204
  switch (_e.label) {
@@ -255,41 +255,18 @@ var Credit = /** @class */ (function () {
255
255
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
256
256
  }
257
257
  break;
258
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
259
- if (utils.matchContentType(contentType, "application/json")) {
260
- res.fourHundredError = JSON.parse(decodedRes);
261
- }
262
- else {
263
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
264
- }
265
- break;
258
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400 ||
259
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 404 ||
260
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 409 ||
261
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 413 ||
262
+ ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
263
+ ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
264
+ throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
266
265
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
267
266
  if (utils.matchContentType(contentType, "application/json")) {
268
- res.fourHundredAndOneError = utils.objectToClass(JSON.parse(decodedRes), shared.FourHundredAndOneError);
269
- }
270
- else {
271
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
272
- }
273
- break;
274
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 404:
275
- if (utils.matchContentType(contentType, "application/json")) {
276
- res.fourHundredAndFourError = JSON.parse(decodedRes);
277
- }
278
- else {
279
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
280
- }
281
- break;
282
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 409:
283
- if (utils.matchContentType(contentType, "application/json")) {
284
- res.fourHundredAndNineError = JSON.parse(decodedRes);
285
- }
286
- else {
287
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
288
- }
289
- break;
290
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 413:
291
- if (utils.matchContentType(contentType, "application/json")) {
292
- res.fourHundredAndThirteenError = JSON.parse(decodedRes);
267
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FourHundredAndOneError);
268
+ err.rawResponse = httpRes;
269
+ throw new errors.FourHundredAndOneError(err);
293
270
  }
294
271
  else {
295
272
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
@@ -297,7 +274,9 @@ var Credit = /** @class */ (function () {
297
274
  break;
298
275
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 429:
299
276
  if (utils.matchContentType(contentType, "application/json")) {
300
- res.fourHundredAndTwentyNineError = utils.objectToClass(JSON.parse(decodedRes), shared.FourHundredAndTwentyNineError);
277
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FourHundredAndTwentyNineError);
278
+ err.rawResponse = httpRes;
279
+ throw new errors.FourHundredAndTwentyNineError(err);
301
280
  }
302
281
  else {
303
282
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
@@ -305,7 +284,9 @@ var Credit = /** @class */ (function () {
305
284
  break;
306
285
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
307
286
  if (utils.matchContentType(contentType, "application/json")) {
308
- res.fiveHundredError = utils.objectToClass(JSON.parse(decodedRes), shared.FiveHundredError);
287
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FiveHundredError);
288
+ err.rawResponse = httpRes;
289
+ throw new errors.FiveHundredError(err);
309
290
  }
310
291
  else {
311
292
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
@@ -414,7 +395,7 @@ var Credit = /** @class */ (function () {
414
395
  Credit.prototype.create = function (customerId, requestBody, config) {
415
396
  var _a, _b;
416
397
  return __awaiter(this, void 0, void 0, function () {
417
- var req, baseURL, url, _c, reqBodyHeaders, reqBody, client, globalSecurity, properties, headers, httpRes, contentType, res, decodedRes;
398
+ var req, baseURL, url, _c, reqBodyHeaders, reqBody, client, globalSecurity, properties, headers, httpRes, contentType, res, decodedRes, err, err, err;
418
399
  var _d;
419
400
  return __generator(this, function (_e) {
420
401
  switch (_e.label) {
@@ -471,41 +452,18 @@ var Credit = /** @class */ (function () {
471
452
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
472
453
  }
473
454
  break;
474
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
475
- if (utils.matchContentType(contentType, "application/json")) {
476
- res.fourHundredError = JSON.parse(decodedRes);
477
- }
478
- else {
479
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
480
- }
481
- break;
455
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400 ||
456
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 404 ||
457
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 409 ||
458
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 413 ||
459
+ ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
460
+ ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
461
+ throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
482
462
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
483
463
  if (utils.matchContentType(contentType, "application/json")) {
484
- res.fourHundredAndOneError = utils.objectToClass(JSON.parse(decodedRes), shared.FourHundredAndOneError);
485
- }
486
- else {
487
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
488
- }
489
- break;
490
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 404:
491
- if (utils.matchContentType(contentType, "application/json")) {
492
- res.fourHundredAndFourError = JSON.parse(decodedRes);
493
- }
494
- else {
495
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
496
- }
497
- break;
498
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 409:
499
- if (utils.matchContentType(contentType, "application/json")) {
500
- res.fourHundredAndNineError = JSON.parse(decodedRes);
501
- }
502
- else {
503
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
504
- }
505
- break;
506
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 413:
507
- if (utils.matchContentType(contentType, "application/json")) {
508
- res.fourHundredAndThirteenError = JSON.parse(decodedRes);
464
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FourHundredAndOneError);
465
+ err.rawResponse = httpRes;
466
+ throw new errors.FourHundredAndOneError(err);
509
467
  }
510
468
  else {
511
469
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
@@ -513,7 +471,9 @@ var Credit = /** @class */ (function () {
513
471
  break;
514
472
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 429:
515
473
  if (utils.matchContentType(contentType, "application/json")) {
516
- res.fourHundredAndTwentyNineError = utils.objectToClass(JSON.parse(decodedRes), shared.FourHundredAndTwentyNineError);
474
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FourHundredAndTwentyNineError);
475
+ err.rawResponse = httpRes;
476
+ throw new errors.FourHundredAndTwentyNineError(err);
517
477
  }
518
478
  else {
519
479
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
@@ -521,7 +481,9 @@ var Credit = /** @class */ (function () {
521
481
  break;
522
482
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
523
483
  if (utils.matchContentType(contentType, "application/json")) {
524
- res.fiveHundredError = utils.objectToClass(JSON.parse(decodedRes), shared.FiveHundredError);
484
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FiveHundredError);
485
+ err.rawResponse = httpRes;
486
+ throw new errors.FiveHundredError(err);
525
487
  }
526
488
  else {
527
489
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
@@ -542,7 +504,7 @@ var Credit = /** @class */ (function () {
542
504
  Credit.prototype.fetchBalance = function (customerId, cursor, limit, config) {
543
505
  var _a, _b;
544
506
  return __awaiter(this, void 0, void 0, function () {
545
- var req, baseURL, url, client, globalSecurity, properties, headers, queryParams, httpRes, contentType, res, decodedRes;
507
+ var req, baseURL, url, client, globalSecurity, properties, headers, queryParams, httpRes, contentType, res, decodedRes, err, err, err;
546
508
  return __generator(this, function (_c) {
547
509
  switch (_c.label) {
548
510
  case 0:
@@ -591,41 +553,18 @@ var Credit = /** @class */ (function () {
591
553
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
592
554
  }
593
555
  break;
594
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
595
- if (utils.matchContentType(contentType, "application/json")) {
596
- res.fourHundredError = JSON.parse(decodedRes);
597
- }
598
- else {
599
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
600
- }
601
- break;
556
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400 ||
557
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 404 ||
558
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 409 ||
559
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 413 ||
560
+ ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
561
+ ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
562
+ throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
602
563
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
603
564
  if (utils.matchContentType(contentType, "application/json")) {
604
- res.fourHundredAndOneError = utils.objectToClass(JSON.parse(decodedRes), shared.FourHundredAndOneError);
605
- }
606
- else {
607
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
608
- }
609
- break;
610
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 404:
611
- if (utils.matchContentType(contentType, "application/json")) {
612
- res.fourHundredAndFourError = JSON.parse(decodedRes);
613
- }
614
- else {
615
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
616
- }
617
- break;
618
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 409:
619
- if (utils.matchContentType(contentType, "application/json")) {
620
- res.fourHundredAndNineError = JSON.parse(decodedRes);
621
- }
622
- else {
623
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
624
- }
625
- break;
626
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 413:
627
- if (utils.matchContentType(contentType, "application/json")) {
628
- res.fourHundredAndThirteenError = JSON.parse(decodedRes);
565
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FourHundredAndOneError);
566
+ err.rawResponse = httpRes;
567
+ throw new errors.FourHundredAndOneError(err);
629
568
  }
630
569
  else {
631
570
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
@@ -633,7 +572,9 @@ var Credit = /** @class */ (function () {
633
572
  break;
634
573
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 429:
635
574
  if (utils.matchContentType(contentType, "application/json")) {
636
- res.fourHundredAndTwentyNineError = utils.objectToClass(JSON.parse(decodedRes), shared.FourHundredAndTwentyNineError);
575
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FourHundredAndTwentyNineError);
576
+ err.rawResponse = httpRes;
577
+ throw new errors.FourHundredAndTwentyNineError(err);
637
578
  }
638
579
  else {
639
580
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
@@ -641,7 +582,9 @@ var Credit = /** @class */ (function () {
641
582
  break;
642
583
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
643
584
  if (utils.matchContentType(contentType, "application/json")) {
644
- res.fiveHundredError = utils.objectToClass(JSON.parse(decodedRes), shared.FiveHundredError);
585
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FiveHundredError);
586
+ err.rawResponse = httpRes;
587
+ throw new errors.FiveHundredError(err);
645
588
  }
646
589
  else {
647
590
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
@@ -662,7 +605,7 @@ var Credit = /** @class */ (function () {
662
605
  Credit.prototype.fetchBalanceByExternalId = function (externalCustomerId, cursor, limit, config) {
663
606
  var _a, _b;
664
607
  return __awaiter(this, void 0, void 0, function () {
665
- var req, baseURL, url, client, globalSecurity, properties, headers, queryParams, httpRes, contentType, res, decodedRes;
608
+ var req, baseURL, url, client, globalSecurity, properties, headers, queryParams, httpRes, contentType, res, decodedRes, err, err, err;
666
609
  return __generator(this, function (_c) {
667
610
  switch (_c.label) {
668
611
  case 0:
@@ -711,41 +654,18 @@ var Credit = /** @class */ (function () {
711
654
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
712
655
  }
713
656
  break;
714
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
715
- if (utils.matchContentType(contentType, "application/json")) {
716
- res.fourHundredError = JSON.parse(decodedRes);
717
- }
718
- else {
719
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
720
- }
721
- break;
657
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400 ||
658
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 404 ||
659
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 409 ||
660
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 413 ||
661
+ ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
662
+ ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
663
+ throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
722
664
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
723
665
  if (utils.matchContentType(contentType, "application/json")) {
724
- res.fourHundredAndOneError = utils.objectToClass(JSON.parse(decodedRes), shared.FourHundredAndOneError);
725
- }
726
- else {
727
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
728
- }
729
- break;
730
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 404:
731
- if (utils.matchContentType(contentType, "application/json")) {
732
- res.fourHundredAndFourError = JSON.parse(decodedRes);
733
- }
734
- else {
735
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
736
- }
737
- break;
738
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 409:
739
- if (utils.matchContentType(contentType, "application/json")) {
740
- res.fourHundredAndNineError = JSON.parse(decodedRes);
741
- }
742
- else {
743
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
744
- }
745
- break;
746
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 413:
747
- if (utils.matchContentType(contentType, "application/json")) {
748
- res.fourHundredAndThirteenError = JSON.parse(decodedRes);
666
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FourHundredAndOneError);
667
+ err.rawResponse = httpRes;
668
+ throw new errors.FourHundredAndOneError(err);
749
669
  }
750
670
  else {
751
671
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
@@ -753,7 +673,9 @@ var Credit = /** @class */ (function () {
753
673
  break;
754
674
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 429:
755
675
  if (utils.matchContentType(contentType, "application/json")) {
756
- res.fourHundredAndTwentyNineError = utils.objectToClass(JSON.parse(decodedRes), shared.FourHundredAndTwentyNineError);
676
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FourHundredAndTwentyNineError);
677
+ err.rawResponse = httpRes;
678
+ throw new errors.FourHundredAndTwentyNineError(err);
757
679
  }
758
680
  else {
759
681
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
@@ -761,7 +683,9 @@ var Credit = /** @class */ (function () {
761
683
  break;
762
684
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
763
685
  if (utils.matchContentType(contentType, "application/json")) {
764
- res.fiveHundredError = utils.objectToClass(JSON.parse(decodedRes), shared.FiveHundredError);
686
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FiveHundredError);
687
+ err.rawResponse = httpRes;
688
+ throw new errors.FiveHundredError(err);
765
689
  }
766
690
  else {
767
691
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
@@ -842,7 +766,7 @@ var Credit = /** @class */ (function () {
842
766
  Credit.prototype.fetchLedger = function (req, config) {
843
767
  var _a, _b;
844
768
  return __awaiter(this, void 0, void 0, function () {
845
- var baseURL, url, client, globalSecurity, properties, headers, queryParams, httpRes, contentType, res, decodedRes;
769
+ var baseURL, url, client, globalSecurity, properties, headers, queryParams, httpRes, contentType, res, decodedRes, err, err, err;
846
770
  return __generator(this, function (_c) {
847
771
  switch (_c.label) {
848
772
  case 0:
@@ -889,41 +813,18 @@ var Credit = /** @class */ (function () {
889
813
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
890
814
  }
891
815
  break;
892
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
893
- if (utils.matchContentType(contentType, "application/json")) {
894
- res.fourHundredError = JSON.parse(decodedRes);
895
- }
896
- else {
897
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
898
- }
899
- break;
816
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400 ||
817
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 404 ||
818
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 409 ||
819
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 413 ||
820
+ ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
821
+ ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
822
+ throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
900
823
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
901
824
  if (utils.matchContentType(contentType, "application/json")) {
902
- res.fourHundredAndOneError = utils.objectToClass(JSON.parse(decodedRes), shared.FourHundredAndOneError);
903
- }
904
- else {
905
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
906
- }
907
- break;
908
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 404:
909
- if (utils.matchContentType(contentType, "application/json")) {
910
- res.fourHundredAndFourError = JSON.parse(decodedRes);
911
- }
912
- else {
913
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
914
- }
915
- break;
916
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 409:
917
- if (utils.matchContentType(contentType, "application/json")) {
918
- res.fourHundredAndNineError = JSON.parse(decodedRes);
919
- }
920
- else {
921
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
922
- }
923
- break;
924
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 413:
925
- if (utils.matchContentType(contentType, "application/json")) {
926
- res.fourHundredAndThirteenError = JSON.parse(decodedRes);
825
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FourHundredAndOneError);
826
+ err.rawResponse = httpRes;
827
+ throw new errors.FourHundredAndOneError(err);
927
828
  }
928
829
  else {
929
830
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
@@ -931,7 +832,9 @@ var Credit = /** @class */ (function () {
931
832
  break;
932
833
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 429:
933
834
  if (utils.matchContentType(contentType, "application/json")) {
934
- res.fourHundredAndTwentyNineError = utils.objectToClass(JSON.parse(decodedRes), shared.FourHundredAndTwentyNineError);
835
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FourHundredAndTwentyNineError);
836
+ err.rawResponse = httpRes;
837
+ throw new errors.FourHundredAndTwentyNineError(err);
935
838
  }
936
839
  else {
937
840
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
@@ -939,7 +842,9 @@ var Credit = /** @class */ (function () {
939
842
  break;
940
843
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
941
844
  if (utils.matchContentType(contentType, "application/json")) {
942
- res.fiveHundredError = utils.objectToClass(JSON.parse(decodedRes), shared.FiveHundredError);
845
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FiveHundredError);
846
+ err.rawResponse = httpRes;
847
+ throw new errors.FiveHundredError(err);
943
848
  }
944
849
  else {
945
850
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
@@ -1020,7 +925,7 @@ var Credit = /** @class */ (function () {
1020
925
  Credit.prototype.fetchLedgerByExternalId = function (req, config) {
1021
926
  var _a, _b;
1022
927
  return __awaiter(this, void 0, void 0, function () {
1023
- var baseURL, url, client, globalSecurity, properties, headers, queryParams, httpRes, contentType, res, decodedRes;
928
+ var baseURL, url, client, globalSecurity, properties, headers, queryParams, httpRes, contentType, res, decodedRes, err, err, err;
1024
929
  return __generator(this, function (_c) {
1025
930
  switch (_c.label) {
1026
931
  case 0:
@@ -1067,41 +972,18 @@ var Credit = /** @class */ (function () {
1067
972
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
1068
973
  }
1069
974
  break;
1070
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
1071
- if (utils.matchContentType(contentType, "application/json")) {
1072
- res.fourHundredError = JSON.parse(decodedRes);
1073
- }
1074
- else {
1075
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
1076
- }
1077
- break;
975
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400 ||
976
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 404 ||
977
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 409 ||
978
+ (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 413 ||
979
+ ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 400 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 500) ||
980
+ ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) >= 500 && (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) < 600):
981
+ throw new errors.SDKError("API error occurred", httpRes.status, decodedRes, httpRes);
1078
982
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 401:
1079
983
  if (utils.matchContentType(contentType, "application/json")) {
1080
- res.fourHundredAndOneError = utils.objectToClass(JSON.parse(decodedRes), shared.FourHundredAndOneError);
1081
- }
1082
- else {
1083
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
1084
- }
1085
- break;
1086
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 404:
1087
- if (utils.matchContentType(contentType, "application/json")) {
1088
- res.fourHundredAndFourError = JSON.parse(decodedRes);
1089
- }
1090
- else {
1091
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
1092
- }
1093
- break;
1094
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 409:
1095
- if (utils.matchContentType(contentType, "application/json")) {
1096
- res.fourHundredAndNineError = JSON.parse(decodedRes);
1097
- }
1098
- else {
1099
- throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
1100
- }
1101
- break;
1102
- case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 413:
1103
- if (utils.matchContentType(contentType, "application/json")) {
1104
- res.fourHundredAndThirteenError = JSON.parse(decodedRes);
984
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FourHundredAndOneError);
985
+ err.rawResponse = httpRes;
986
+ throw new errors.FourHundredAndOneError(err);
1105
987
  }
1106
988
  else {
1107
989
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
@@ -1109,7 +991,9 @@ var Credit = /** @class */ (function () {
1109
991
  break;
1110
992
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 429:
1111
993
  if (utils.matchContentType(contentType, "application/json")) {
1112
- res.fourHundredAndTwentyNineError = utils.objectToClass(JSON.parse(decodedRes), shared.FourHundredAndTwentyNineError);
994
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FourHundredAndTwentyNineError);
995
+ err.rawResponse = httpRes;
996
+ throw new errors.FourHundredAndTwentyNineError(err);
1113
997
  }
1114
998
  else {
1115
999
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);
@@ -1117,7 +1001,9 @@ var Credit = /** @class */ (function () {
1117
1001
  break;
1118
1002
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 500:
1119
1003
  if (utils.matchContentType(contentType, "application/json")) {
1120
- res.fiveHundredError = utils.objectToClass(JSON.parse(decodedRes), shared.FiveHundredError);
1004
+ err = utils.objectToClass(JSON.parse(decodedRes), errors.FiveHundredError);
1005
+ err.rawResponse = httpRes;
1006
+ throw new errors.FiveHundredError(err);
1121
1007
  }
1122
1008
  else {
1123
1009
  throw new errors.SDKError("unknown content-type received: " + contentType, httpRes.status, decodedRes, httpRes);