orb-billing 1.0.1

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 (413) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +169 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +20 -0
  5. package/dist/internal/utils/contenttype.d.ts +1 -0
  6. package/dist/internal/utils/contenttype.js +33 -0
  7. package/dist/internal/utils/headers.d.ts +4 -0
  8. package/dist/internal/utils/headers.js +92 -0
  9. package/dist/internal/utils/index.d.ts +8 -0
  10. package/dist/internal/utils/index.js +27 -0
  11. package/dist/internal/utils/pathparams.d.ts +2 -0
  12. package/dist/internal/utils/pathparams.js +53 -0
  13. package/dist/internal/utils/queryparams.d.ts +2 -0
  14. package/dist/internal/utils/queryparams.js +178 -0
  15. package/dist/internal/utils/requestbody.d.ts +2 -0
  16. package/dist/internal/utils/requestbody.js +318 -0
  17. package/dist/internal/utils/retries.d.ts +20 -0
  18. package/dist/internal/utils/retries.js +250 -0
  19. package/dist/internal/utils/security.d.ts +2 -0
  20. package/dist/internal/utils/security.js +188 -0
  21. package/dist/internal/utils/utils.d.ts +37 -0
  22. package/dist/internal/utils/utils.js +370 -0
  23. package/dist/sdk/availability.d.ts +19 -0
  24. package/dist/sdk/availability.js +135 -0
  25. package/dist/sdk/coupon.d.ts +53 -0
  26. package/dist/sdk/coupon.js +358 -0
  27. package/dist/sdk/credit.d.ts +142 -0
  28. package/dist/sdk/credit.js +501 -0
  29. package/dist/sdk/creditnote.d.ts +26 -0
  30. package/dist/sdk/creditnote.js +186 -0
  31. package/dist/sdk/customer.d.ts +264 -0
  32. package/dist/sdk/customer.js +958 -0
  33. package/dist/sdk/event.d.ts +258 -0
  34. package/dist/sdk/event.js +732 -0
  35. package/dist/sdk/index.d.ts +1 -0
  36. package/dist/sdk/index.js +20 -0
  37. package/dist/sdk/invoice.d.ts +60 -0
  38. package/dist/sdk/invoice.js +416 -0
  39. package/dist/sdk/models/operations/addledgerentryexternalid.d.ts +16 -0
  40. package/dist/sdk/models/operations/addledgerentryexternalid.js +95 -0
  41. package/dist/sdk/models/operations/amendevent.d.ts +23 -0
  42. package/dist/sdk/models/operations/amendevent.js +99 -0
  43. package/dist/sdk/models/operations/amendusage.d.ts +34 -0
  44. package/dist/sdk/models/operations/amendusage.js +122 -0
  45. package/dist/sdk/models/operations/amendusageexternalcustomerid.d.ts +34 -0
  46. package/dist/sdk/models/operations/amendusageexternalcustomerid.js +122 -0
  47. package/dist/sdk/models/operations/archivecoupon.d.ts +15 -0
  48. package/dist/sdk/models/operations/archivecoupon.js +91 -0
  49. package/dist/sdk/models/operations/cancelsubscription.d.ts +16 -0
  50. package/dist/sdk/models/operations/cancelsubscription.js +95 -0
  51. package/dist/sdk/models/operations/closebackfill.d.ts +15 -0
  52. package/dist/sdk/models/operations/closebackfill.js +91 -0
  53. package/dist/sdk/models/operations/createbackfill.d.ts +12 -0
  54. package/dist/sdk/models/operations/createbackfill.js +79 -0
  55. package/dist/sdk/models/operations/createcoupon.d.ts +12 -0
  56. package/dist/sdk/models/operations/createcoupon.js +79 -0
  57. package/dist/sdk/models/operations/createcustomer.d.ts +12 -0
  58. package/dist/sdk/models/operations/createcustomer.js +79 -0
  59. package/dist/sdk/models/operations/createcustomerbalancetransaction.d.ts +16 -0
  60. package/dist/sdk/models/operations/createcustomerbalancetransaction.js +95 -0
  61. package/dist/sdk/models/operations/createinvoicelineitem.d.ts +12 -0
  62. package/dist/sdk/models/operations/createinvoicelineitem.js +79 -0
  63. package/dist/sdk/models/operations/createledgerentry.d.ts +16 -0
  64. package/dist/sdk/models/operations/createledgerentry.js +95 -0
  65. package/dist/sdk/models/operations/createsubscription.d.ts +12 -0
  66. package/dist/sdk/models/operations/createsubscription.js +79 -0
  67. package/dist/sdk/models/operations/deletecustomer.d.ts +22 -0
  68. package/dist/sdk/models/operations/deletecustomer.js +78 -0
  69. package/dist/sdk/models/operations/deprecateevent.d.ts +22 -0
  70. package/dist/sdk/models/operations/deprecateevent.js +95 -0
  71. package/dist/sdk/models/operations/fetchcoupon.d.ts +15 -0
  72. package/dist/sdk/models/operations/fetchcoupon.js +91 -0
  73. package/dist/sdk/models/operations/fetchcreditnote.d.ts +18 -0
  74. package/dist/sdk/models/operations/fetchcreditnote.js +91 -0
  75. package/dist/sdk/models/operations/fetchcustomer.d.ts +18 -0
  76. package/dist/sdk/models/operations/fetchcustomer.js +91 -0
  77. package/dist/sdk/models/operations/fetchcustomercosts.d.ts +34 -0
  78. package/dist/sdk/models/operations/fetchcustomercosts.js +107 -0
  79. package/dist/sdk/models/operations/fetchcustomercostsexternalid.d.ts +31 -0
  80. package/dist/sdk/models/operations/fetchcustomercostsexternalid.js +107 -0
  81. package/dist/sdk/models/operations/fetchcustomercredits.d.ts +26 -0
  82. package/dist/sdk/models/operations/fetchcustomercredits.js +99 -0
  83. package/dist/sdk/models/operations/fetchcustomercreditsexternalid.d.ts +23 -0
  84. package/dist/sdk/models/operations/fetchcustomercreditsexternalid.js +99 -0
  85. package/dist/sdk/models/operations/fetchcustomercreditsledger.d.ts +35 -0
  86. package/dist/sdk/models/operations/fetchcustomercreditsledger.js +111 -0
  87. package/dist/sdk/models/operations/fetchcustomercreditsledgerexternalid.d.ts +35 -0
  88. package/dist/sdk/models/operations/fetchcustomercreditsledgerexternalid.js +111 -0
  89. package/dist/sdk/models/operations/fetchcustomerexternalid.d.ts +15 -0
  90. package/dist/sdk/models/operations/fetchcustomerexternalid.js +91 -0
  91. package/dist/sdk/models/operations/fetchinvoice.d.ts +15 -0
  92. package/dist/sdk/models/operations/fetchinvoice.js +91 -0
  93. package/dist/sdk/models/operations/fetchplan.d.ts +15 -0
  94. package/dist/sdk/models/operations/fetchplan.js +91 -0
  95. package/dist/sdk/models/operations/fetchplanexternalid.d.ts +15 -0
  96. package/dist/sdk/models/operations/fetchplanexternalid.js +91 -0
  97. package/dist/sdk/models/operations/fetchsubscription.d.ts +15 -0
  98. package/dist/sdk/models/operations/fetchsubscription.js +91 -0
  99. package/dist/sdk/models/operations/fetchsubscriptioncosts.d.ts +31 -0
  100. package/dist/sdk/models/operations/fetchsubscriptioncosts.js +107 -0
  101. package/dist/sdk/models/operations/fetchsubscriptionschedule.d.ts +23 -0
  102. package/dist/sdk/models/operations/fetchsubscriptionschedule.js +99 -0
  103. package/dist/sdk/models/operations/fetchsubscriptionusage.d.ts +39 -0
  104. package/dist/sdk/models/operations/fetchsubscriptionusage.js +115 -0
  105. package/dist/sdk/models/operations/fetchupcominginvoice.d.ts +15 -0
  106. package/dist/sdk/models/operations/fetchupcominginvoice.js +91 -0
  107. package/dist/sdk/models/operations/index.d.ts +55 -0
  108. package/dist/sdk/models/operations/index.js +74 -0
  109. package/dist/sdk/models/operations/ingest.d.ts +30 -0
  110. package/dist/sdk/models/operations/ingest.js +118 -0
  111. package/dist/sdk/models/operations/issueinvoice.d.ts +19 -0
  112. package/dist/sdk/models/operations/issueinvoice.js +95 -0
  113. package/dist/sdk/models/operations/listbackfills.d.ts +22 -0
  114. package/dist/sdk/models/operations/listbackfills.js +95 -0
  115. package/dist/sdk/models/operations/listbalancetransactions.d.ts +23 -0
  116. package/dist/sdk/models/operations/listbalancetransactions.js +99 -0
  117. package/dist/sdk/models/operations/listcoupons.d.ts +30 -0
  118. package/dist/sdk/models/operations/listcoupons.js +103 -0
  119. package/dist/sdk/models/operations/listcouponsubscriptions.d.ts +15 -0
  120. package/dist/sdk/models/operations/listcouponsubscriptions.js +91 -0
  121. package/dist/sdk/models/operations/listcreditnote.d.ts +34 -0
  122. package/dist/sdk/models/operations/listcreditnote.js +107 -0
  123. package/dist/sdk/models/operations/listcustomers.d.ts +22 -0
  124. package/dist/sdk/models/operations/listcustomers.js +95 -0
  125. package/dist/sdk/models/operations/listinvoices.d.ts +38 -0
  126. package/dist/sdk/models/operations/listinvoices.js +111 -0
  127. package/dist/sdk/models/operations/listplans.d.ts +22 -0
  128. package/dist/sdk/models/operations/listplans.js +95 -0
  129. package/dist/sdk/models/operations/listsubscriptions.d.ts +24 -0
  130. package/dist/sdk/models/operations/listsubscriptions.js +103 -0
  131. package/dist/sdk/models/operations/ping.d.ts +12 -0
  132. package/dist/sdk/models/operations/ping.js +79 -0
  133. package/dist/sdk/models/operations/revertbackfill.d.ts +15 -0
  134. package/dist/sdk/models/operations/revertbackfill.js +91 -0
  135. package/dist/sdk/models/operations/scheduleplanchange.d.ts +16 -0
  136. package/dist/sdk/models/operations/scheduleplanchange.js +95 -0
  137. package/dist/sdk/models/operations/searchevents.d.ts +23 -0
  138. package/dist/sdk/models/operations/searchevents.js +99 -0
  139. package/dist/sdk/models/operations/unschedulecancellation.d.ts +15 -0
  140. package/dist/sdk/models/operations/unschedulecancellation.js +91 -0
  141. package/dist/sdk/models/operations/unscheduleplanchange.d.ts +15 -0
  142. package/dist/sdk/models/operations/unscheduleplanchange.js +91 -0
  143. package/dist/sdk/models/operations/updatecustomer.d.ts +19 -0
  144. package/dist/sdk/models/operations/updatecustomer.js +95 -0
  145. package/dist/sdk/models/operations/updatecustomerexternalid.d.ts +16 -0
  146. package/dist/sdk/models/operations/updatecustomerexternalid.js +95 -0
  147. package/dist/sdk/models/operations/updatefixedfeequantity.d.ts +16 -0
  148. package/dist/sdk/models/operations/updatefixedfeequantity.js +95 -0
  149. package/dist/sdk/models/operations/voidinvoice.d.ts +19 -0
  150. package/dist/sdk/models/operations/voidinvoice.js +95 -0
  151. package/dist/sdk/models/shared/action.d.ts +8 -0
  152. package/dist/sdk/models/shared/action.js +15 -0
  153. package/dist/sdk/models/shared/amendedevent.d.ts +28 -0
  154. package/dist/sdk/models/shared/amendedevent.js +81 -0
  155. package/dist/sdk/models/shared/amendedusage.d.ts +16 -0
  156. package/dist/sdk/models/shared/amendedusage.js +62 -0
  157. package/dist/sdk/models/shared/amendeventresult.d.ts +10 -0
  158. package/dist/sdk/models/shared/amendeventresult.js +48 -0
  159. package/dist/sdk/models/shared/autocollection.d.ts +18 -0
  160. package/dist/sdk/models/shared/autocollection.js +66 -0
  161. package/dist/sdk/models/shared/availability.d.ts +7 -0
  162. package/dist/sdk/models/shared/availability.js +48 -0
  163. package/dist/sdk/models/shared/backfill.d.ts +27 -0
  164. package/dist/sdk/models/shared/backfill.js +104 -0
  165. package/dist/sdk/models/shared/backfills.d.ts +10 -0
  166. package/dist/sdk/models/shared/backfills.js +57 -0
  167. package/dist/sdk/models/shared/backfillstatus.d.ts +9 -0
  168. package/dist/sdk/models/shared/backfillstatus.js +16 -0
  169. package/dist/sdk/models/shared/billablemetric.d.ts +4 -0
  170. package/dist/sdk/models/shared/billablemetric.js +45 -0
  171. package/dist/sdk/models/shared/billablemetricminified.d.ts +5 -0
  172. package/dist/sdk/models/shared/billablemetricminified.js +50 -0
  173. package/dist/sdk/models/shared/bpsconfig.d.ts +8 -0
  174. package/dist/sdk/models/shared/bpsconfig.js +53 -0
  175. package/dist/sdk/models/shared/bpspriceoverride.d.ts +24 -0
  176. package/dist/sdk/models/shared/bpspriceoverride.js +74 -0
  177. package/dist/sdk/models/shared/bpstier.d.ts +7 -0
  178. package/dist/sdk/models/shared/bpstier.js +60 -0
  179. package/dist/sdk/models/shared/bulkbpsconfig.d.ts +8 -0
  180. package/dist/sdk/models/shared/bulkbpsconfig.js +50 -0
  181. package/dist/sdk/models/shared/bulkbpspriceoverride.d.ts +24 -0
  182. package/dist/sdk/models/shared/bulkbpspriceoverride.js +74 -0
  183. package/dist/sdk/models/shared/bulkbpstier.d.ts +6 -0
  184. package/dist/sdk/models/shared/bulkbpstier.js +55 -0
  185. package/dist/sdk/models/shared/bulkconfig.d.ts +8 -0
  186. package/dist/sdk/models/shared/bulkconfig.js +50 -0
  187. package/dist/sdk/models/shared/bulkpriceoverride.d.ts +24 -0
  188. package/dist/sdk/models/shared/bulkpriceoverride.js +74 -0
  189. package/dist/sdk/models/shared/bulktier.d.ts +5 -0
  190. package/dist/sdk/models/shared/bulktier.js +50 -0
  191. package/dist/sdk/models/shared/cadence.d.ts +5 -0
  192. package/dist/sdk/models/shared/cadence.js +12 -0
  193. package/dist/sdk/models/shared/canceloption.d.ts +8 -0
  194. package/dist/sdk/models/shared/canceloption.js +15 -0
  195. package/dist/sdk/models/shared/changeoption.d.ts +8 -0
  196. package/dist/sdk/models/shared/changeoption.js +15 -0
  197. package/dist/sdk/models/shared/changeoption1.d.ts +8 -0
  198. package/dist/sdk/models/shared/changeoption1.js +15 -0
  199. package/dist/sdk/models/shared/coupon.d.ts +36 -0
  200. package/dist/sdk/models/shared/coupon.js +88 -0
  201. package/dist/sdk/models/shared/coupons.d.ts +10 -0
  202. package/dist/sdk/models/shared/coupons.js +57 -0
  203. package/dist/sdk/models/shared/credit.d.ts +16 -0
  204. package/dist/sdk/models/shared/credit.js +64 -0
  205. package/dist/sdk/models/shared/creditblock.d.ts +15 -0
  206. package/dist/sdk/models/shared/creditblock.js +58 -0
  207. package/dist/sdk/models/shared/creditledgerentries.d.ts +10 -0
  208. package/dist/sdk/models/shared/creditledgerentries.js +57 -0
  209. package/dist/sdk/models/shared/creditledgerentry.d.ts +58 -0
  210. package/dist/sdk/models/shared/creditledgerentry.js +144 -0
  211. package/dist/sdk/models/shared/creditnote.d.ts +71 -0
  212. package/dist/sdk/models/shared/creditnote.js +134 -0
  213. package/dist/sdk/models/shared/creditnotelineitem.d.ts +38 -0
  214. package/dist/sdk/models/shared/creditnotelineitem.js +86 -0
  215. package/dist/sdk/models/shared/creditnotes.d.ts +10 -0
  216. package/dist/sdk/models/shared/creditnotes.js +57 -0
  217. package/dist/sdk/models/shared/creditnotesummary.d.ts +9 -0
  218. package/dist/sdk/models/shared/creditnotesummary.js +74 -0
  219. package/dist/sdk/models/shared/creditnotetype.d.ts +7 -0
  220. package/dist/sdk/models/shared/creditnotetype.js +14 -0
  221. package/dist/sdk/models/shared/credits.d.ts +10 -0
  222. package/dist/sdk/models/shared/credits.js +57 -0
  223. package/dist/sdk/models/shared/customer.d.ts +227 -0
  224. package/dist/sdk/models/shared/customer.js +364 -0
  225. package/dist/sdk/models/shared/customerbalancetransaction.d.ts +57 -0
  226. package/dist/sdk/models/shared/customerbalancetransaction.js +133 -0
  227. package/dist/sdk/models/shared/customercost.d.ts +15 -0
  228. package/dist/sdk/models/shared/customercost.js +75 -0
  229. package/dist/sdk/models/shared/customercosts.d.ts +8 -0
  230. package/dist/sdk/models/shared/customercosts.js +50 -0
  231. package/dist/sdk/models/shared/customerminified.d.ts +8 -0
  232. package/dist/sdk/models/shared/customerminified.js +53 -0
  233. package/dist/sdk/models/shared/customers.d.ts +10 -0
  234. package/dist/sdk/models/shared/customers.js +57 -0
  235. package/dist/sdk/models/shared/debug.d.ts +8 -0
  236. package/dist/sdk/models/shared/debug.js +53 -0
  237. package/dist/sdk/models/shared/deprecatedeventresult.d.ts +10 -0
  238. package/dist/sdk/models/shared/deprecatedeventresult.js +48 -0
  239. package/dist/sdk/models/shared/discount.d.ts +25 -0
  240. package/dist/sdk/models/shared/discount.js +71 -0
  241. package/dist/sdk/models/shared/discounttype.d.ts +6 -0
  242. package/dist/sdk/models/shared/discounttype.js +13 -0
  243. package/dist/sdk/models/shared/durationunit.d.ts +8 -0
  244. package/dist/sdk/models/shared/durationunit.js +15 -0
  245. package/dist/sdk/models/shared/entrystatus.d.ts +7 -0
  246. package/dist/sdk/models/shared/entrystatus.js +14 -0
  247. package/dist/sdk/models/shared/entrytype.d.ts +9 -0
  248. package/dist/sdk/models/shared/entrytype.js +16 -0
  249. package/dist/sdk/models/shared/event.d.ts +32 -0
  250. package/dist/sdk/models/shared/event.js +82 -0
  251. package/dist/sdk/models/shared/eventsearchcriteria.d.ts +11 -0
  252. package/dist/sdk/models/shared/eventsearchcriteria.js +50 -0
  253. package/dist/sdk/models/shared/eventsearchresults.d.ts +10 -0
  254. package/dist/sdk/models/shared/eventsearchresults.js +57 -0
  255. package/dist/sdk/models/shared/externalmarketplace.d.ts +8 -0
  256. package/dist/sdk/models/shared/externalmarketplace.js +15 -0
  257. package/dist/sdk/models/shared/fixedfeequantitychange.d.ts +18 -0
  258. package/dist/sdk/models/shared/fixedfeequantitychange.js +66 -0
  259. package/dist/sdk/models/shared/fixedfeequantityschedule.d.ts +7 -0
  260. package/dist/sdk/models/shared/fixedfeequantityschedule.js +68 -0
  261. package/dist/sdk/models/shared/granularity.d.ts +6 -0
  262. package/dist/sdk/models/shared/granularity.js +13 -0
  263. package/dist/sdk/models/shared/grouping.d.ts +8 -0
  264. package/dist/sdk/models/shared/grouping.js +53 -0
  265. package/dist/sdk/models/shared/index.d.ts +125 -0
  266. package/dist/sdk/models/shared/index.js +144 -0
  267. package/dist/sdk/models/shared/ingestionresponse.d.ts +13 -0
  268. package/dist/sdk/models/shared/ingestionresponse.js +57 -0
  269. package/dist/sdk/models/shared/invoice.d.ts +274 -0
  270. package/dist/sdk/models/shared/invoice.js +460 -0
  271. package/dist/sdk/models/shared/invoicelineitem.d.ts +207 -0
  272. package/dist/sdk/models/shared/invoicelineitem.js +416 -0
  273. package/dist/sdk/models/shared/invoices.d.ts +10 -0
  274. package/dist/sdk/models/shared/invoices.js +57 -0
  275. package/dist/sdk/models/shared/invoicesettings.d.ts +18 -0
  276. package/dist/sdk/models/shared/invoicesettings.js +58 -0
  277. package/dist/sdk/models/shared/invoicestatus.d.ts +10 -0
  278. package/dist/sdk/models/shared/invoicestatus.js +17 -0
  279. package/dist/sdk/models/shared/lineitem.d.ts +58 -0
  280. package/dist/sdk/models/shared/lineitem.js +147 -0
  281. package/dist/sdk/models/shared/matrixconfig.d.ts +13 -0
  282. package/dist/sdk/models/shared/matrixconfig.js +60 -0
  283. package/dist/sdk/models/shared/matrixconfig1.d.ts +10 -0
  284. package/dist/sdk/models/shared/matrixconfig1.js +48 -0
  285. package/dist/sdk/models/shared/matrixvalue.d.ts +8 -0
  286. package/dist/sdk/models/shared/matrixvalue.js +50 -0
  287. package/dist/sdk/models/shared/modeltype.d.ts +10 -0
  288. package/dist/sdk/models/shared/modeltype.js +17 -0
  289. package/dist/sdk/models/shared/newbackfill.d.ts +27 -0
  290. package/dist/sdk/models/shared/newbackfill.js +82 -0
  291. package/dist/sdk/models/shared/newcoupon.d.ts +24 -0
  292. package/dist/sdk/models/shared/newcoupon.js +69 -0
  293. package/dist/sdk/models/shared/newcreditledgerentry.d.ts +44 -0
  294. package/dist/sdk/models/shared/newcreditledgerentry.js +109 -0
  295. package/dist/sdk/models/shared/newcustomer.d.ts +202 -0
  296. package/dist/sdk/models/shared/newcustomer.js +324 -0
  297. package/dist/sdk/models/shared/newinvoicelineitem.d.ts +28 -0
  298. package/dist/sdk/models/shared/newinvoicelineitem.js +79 -0
  299. package/dist/sdk/models/shared/newsubscription.d.ts +79 -0
  300. package/dist/sdk/models/shared/newsubscription.js +145 -0
  301. package/dist/sdk/models/shared/newtransaction.d.ts +10 -0
  302. package/dist/sdk/models/shared/newtransaction.js +56 -0
  303. package/dist/sdk/models/shared/packageconfig.d.ts +8 -0
  304. package/dist/sdk/models/shared/packageconfig.js +53 -0
  305. package/dist/sdk/models/shared/packagepriceoverride.d.ts +24 -0
  306. package/dist/sdk/models/shared/packagepriceoverride.js +74 -0
  307. package/dist/sdk/models/shared/paginationmetadata.d.ts +5 -0
  308. package/dist/sdk/models/shared/paginationmetadata.js +50 -0
  309. package/dist/sdk/models/shared/perpricecost.d.ts +24 -0
  310. package/dist/sdk/models/shared/perpricecost.js +67 -0
  311. package/dist/sdk/models/shared/phaseoverride.d.ts +40 -0
  312. package/dist/sdk/models/shared/phaseoverride.js +100 -0
  313. package/dist/sdk/models/shared/plan.d.ts +101 -0
  314. package/dist/sdk/models/shared/plan.js +250 -0
  315. package/dist/sdk/models/shared/planminified.d.ts +5 -0
  316. package/dist/sdk/models/shared/planminified.js +50 -0
  317. package/dist/sdk/models/shared/planphase.d.ts +68 -0
  318. package/dist/sdk/models/shared/planphase.js +162 -0
  319. package/dist/sdk/models/shared/plans.d.ts +10 -0
  320. package/dist/sdk/models/shared/plans.js +57 -0
  321. package/dist/sdk/models/shared/price.d.ts +114 -0
  322. package/dist/sdk/models/shared/price.js +245 -0
  323. package/dist/sdk/models/shared/pricegroup.d.ts +17 -0
  324. package/dist/sdk/models/shared/pricegroup.js +65 -0
  325. package/dist/sdk/models/shared/product.d.ts +6 -0
  326. package/dist/sdk/models/shared/product.js +59 -0
  327. package/dist/sdk/models/shared/reason.d.ts +9 -0
  328. package/dist/sdk/models/shared/reason.js +16 -0
  329. package/dist/sdk/models/shared/requestvalidationerror.d.ts +20 -0
  330. package/dist/sdk/models/shared/requestvalidationerror.js +65 -0
  331. package/dist/sdk/models/shared/security.d.ts +4 -0
  332. package/dist/sdk/models/shared/security.js +45 -0
  333. package/dist/sdk/models/shared/sublineitem.d.ts +32 -0
  334. package/dist/sdk/models/shared/sublineitem.js +102 -0
  335. package/dist/sdk/models/shared/sublineitem1.d.ts +24 -0
  336. package/dist/sdk/models/shared/sublineitem1.js +75 -0
  337. package/dist/sdk/models/shared/sublineitem2.d.ts +6 -0
  338. package/dist/sdk/models/shared/sublineitem2.js +55 -0
  339. package/dist/sdk/models/shared/subscription.d.ts +95 -0
  340. package/dist/sdk/models/shared/subscription.js +207 -0
  341. package/dist/sdk/models/shared/subscriptioncancellation.d.ts +12 -0
  342. package/dist/sdk/models/shared/subscriptioncancellation.js +55 -0
  343. package/dist/sdk/models/shared/subscriptioncost.d.ts +15 -0
  344. package/dist/sdk/models/shared/subscriptioncost.js +75 -0
  345. package/dist/sdk/models/shared/subscriptioncosts.d.ts +8 -0
  346. package/dist/sdk/models/shared/subscriptioncosts.js +50 -0
  347. package/dist/sdk/models/shared/subscriptionminified.d.ts +7 -0
  348. package/dist/sdk/models/shared/subscriptionminified.js +48 -0
  349. package/dist/sdk/models/shared/subscriptionplanchange.d.ts +54 -0
  350. package/dist/sdk/models/shared/subscriptionplanchange.js +104 -0
  351. package/dist/sdk/models/shared/subscriptions.d.ts +10 -0
  352. package/dist/sdk/models/shared/subscriptions.js +57 -0
  353. package/dist/sdk/models/shared/subscriptionschedule.d.ts +10 -0
  354. package/dist/sdk/models/shared/subscriptionschedule.js +57 -0
  355. package/dist/sdk/models/shared/subscriptionscheduleitem.d.ts +7 -0
  356. package/dist/sdk/models/shared/subscriptionscheduleitem.js +65 -0
  357. package/dist/sdk/models/shared/subscriptionstatus.d.ts +5 -0
  358. package/dist/sdk/models/shared/subscriptionstatus.js +12 -0
  359. package/dist/sdk/models/shared/subscriptionusage.d.ts +8 -0
  360. package/dist/sdk/models/shared/subscriptionusage.js +50 -0
  361. package/dist/sdk/models/shared/taxamount.d.ts +15 -0
  362. package/dist/sdk/models/shared/taxamount.js +55 -0
  363. package/dist/sdk/models/shared/tier.d.ts +6 -0
  364. package/dist/sdk/models/shared/tier.js +55 -0
  365. package/dist/sdk/models/shared/tier7.d.ts +7 -0
  366. package/dist/sdk/models/shared/tier7.js +60 -0
  367. package/dist/sdk/models/shared/tierconfig.d.ts +9 -0
  368. package/dist/sdk/models/shared/tierconfig.js +58 -0
  369. package/dist/sdk/models/shared/tieredbpsconfig.d.ts +8 -0
  370. package/dist/sdk/models/shared/tieredbpsconfig.js +50 -0
  371. package/dist/sdk/models/shared/tieredbpsconfig1.d.ts +5 -0
  372. package/dist/sdk/models/shared/tieredbpsconfig1.js +47 -0
  373. package/dist/sdk/models/shared/tieredbpspriceoverride.d.ts +21 -0
  374. package/dist/sdk/models/shared/tieredbpspriceoverride.js +74 -0
  375. package/dist/sdk/models/shared/tieredconfig.d.ts +8 -0
  376. package/dist/sdk/models/shared/tieredconfig.js +50 -0
  377. package/dist/sdk/models/shared/tieredpriceoverride.d.ts +27 -0
  378. package/dist/sdk/models/shared/tieredpriceoverride.js +74 -0
  379. package/dist/sdk/models/shared/transactions.d.ts +10 -0
  380. package/dist/sdk/models/shared/transactions.js +57 -0
  381. package/dist/sdk/models/shared/transactiontype.d.ts +4 -0
  382. package/dist/sdk/models/shared/transactiontype.js +11 -0
  383. package/dist/sdk/models/shared/trialconfig.d.ts +8 -0
  384. package/dist/sdk/models/shared/trialconfig.js +54 -0
  385. package/dist/sdk/models/shared/type.d.ts +7 -0
  386. package/dist/sdk/models/shared/type.js +14 -0
  387. package/dist/sdk/models/shared/unitconfig.d.ts +7 -0
  388. package/dist/sdk/models/shared/unitconfig.js +48 -0
  389. package/dist/sdk/models/shared/unitpriceoverride.d.ts +24 -0
  390. package/dist/sdk/models/shared/unitpriceoverride.js +74 -0
  391. package/dist/sdk/models/shared/upcominginvoice.d.ts +95 -0
  392. package/dist/sdk/models/shared/upcominginvoice.js +193 -0
  393. package/dist/sdk/models/shared/updateevent.d.ts +28 -0
  394. package/dist/sdk/models/shared/updateevent.js +77 -0
  395. package/dist/sdk/models/shared/usage.d.ts +13 -0
  396. package/dist/sdk/models/shared/usage.js +69 -0
  397. package/dist/sdk/models/shared/usageitem.d.ts +6 -0
  398. package/dist/sdk/models/shared/usageitem.js +63 -0
  399. package/dist/sdk/models/shared/validationerrors.d.ts +13 -0
  400. package/dist/sdk/models/shared/validationerrors.js +59 -0
  401. package/dist/sdk/models/shared/viewmode.d.ts +7 -0
  402. package/dist/sdk/models/shared/viewmode.js +14 -0
  403. package/dist/sdk/plan.d.ts +222 -0
  404. package/dist/sdk/plan.js +422 -0
  405. package/dist/sdk/sdk.d.ts +298 -0
  406. package/dist/sdk/sdk.js +110 -0
  407. package/dist/sdk/subscription.d.ts +614 -0
  408. package/dist/sdk/subscription.js +1192 -0
  409. package/dist/sdk/types/index.d.ts +1 -0
  410. package/dist/sdk/types/index.js +20 -0
  411. package/dist/sdk/types/rfcdate.d.ts +9 -0
  412. package/dist/sdk/types/rfcdate.js +59 -0
  413. package/package.json +33 -0
@@ -0,0 +1,732 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
4
+ */
5
+ var __assign = (this && this.__assign) || function () {
6
+ __assign = Object.assign || function(t) {
7
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
8
+ s = arguments[i];
9
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
10
+ t[p] = s[p];
11
+ }
12
+ return t;
13
+ };
14
+ return __assign.apply(this, arguments);
15
+ };
16
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ var desc = Object.getOwnPropertyDescriptor(m, k);
19
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
20
+ desc = { enumerable: true, get: function() { return m[k]; } };
21
+ }
22
+ Object.defineProperty(o, k2, desc);
23
+ }) : (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ o[k2] = m[k];
26
+ }));
27
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
29
+ }) : function(o, v) {
30
+ o["default"] = v;
31
+ });
32
+ var __importStar = (this && this.__importStar) || function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
40
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
41
+ return new (P || (P = Promise))(function (resolve, reject) {
42
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
43
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
44
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
45
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
46
+ });
47
+ };
48
+ var __generator = (this && this.__generator) || function (thisArg, body) {
49
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
50
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
51
+ function verb(n) { return function (v) { return step([n, v]); }; }
52
+ function step(op) {
53
+ if (f) throw new TypeError("Generator is already executing.");
54
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
55
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
56
+ if (y = 0, t) op = [op[0] & 2, t.value];
57
+ switch (op[0]) {
58
+ case 0: case 1: t = op; break;
59
+ case 4: _.label++; return { value: op[1], done: false };
60
+ case 5: _.label++; y = op[1]; op = [0]; continue;
61
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
62
+ default:
63
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
64
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
65
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
66
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
67
+ if (t[2]) _.ops.pop();
68
+ _.trys.pop(); continue;
69
+ }
70
+ op = body.call(thisArg, _);
71
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
72
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
73
+ }
74
+ };
75
+ var __read = (this && this.__read) || function (o, n) {
76
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
77
+ if (!m) return o;
78
+ var i = m.call(o), r, ar = [], e;
79
+ try {
80
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
81
+ }
82
+ catch (error) { e = { error: error }; }
83
+ finally {
84
+ try {
85
+ if (r && !r.done && (m = i["return"])) m.call(i);
86
+ }
87
+ finally { if (e) throw e.error; }
88
+ }
89
+ return ar;
90
+ };
91
+ Object.defineProperty(exports, "__esModule", { value: true });
92
+ exports.Event = void 0;
93
+ var utils = __importStar(require("../internal/utils"));
94
+ var operations = __importStar(require("./models/operations"));
95
+ var shared = __importStar(require("./models/shared"));
96
+ /**
97
+ * The [Event](../guides/core-concepts.mdx#event) resource represents an event that has been created for a customer. Events are created when a customer's invoice is paid, and are updated when a customer's transaction is refunded.
98
+ */
99
+ var Event = /** @class */ (function () {
100
+ function Event(sdkConfig) {
101
+ this.sdkConfiguration = sdkConfig;
102
+ }
103
+ /**
104
+ * Amend event
105
+ *
106
+ * @remarks
107
+ * This endpoint is used to amend a single usage event with a given `event_id`. `event_id` refers to the `idempotency_key` passed in during ingestion. The event will maintain its existing `event_id` after the amendment.
108
+ *
109
+ * This endpoint will mark the existing event as ignored, and Orb will only use the new event passed in the body of this request as the source of truth for that `event_id`. Note that a single event can be amended any number of times, so the same event can be overwritten in subsequent calls to this endpoint, or overwritten using the [Amend customer usage](amend-usage) endpoint. Only a single event with a given `event_id` will be considered the source of truth at any given time.
110
+ *
111
+ * This is a powerful and audit-safe mechanism to retroactively update a single event in cases where you need to:
112
+ * * update an event with new metadata as you iterate on your pricing model
113
+ * * update an event based on the result of an external API call (ex. call to a payment gateway succeeded or failed)
114
+ *
115
+ * This amendment API is always audit-safe. The process will still retain the original event, though it will be ignored for billing calculations. For auditing and data fidelity purposes, Orb never overwrites or permanently deletes ingested usage data.
116
+ *
117
+ * ## Request validation
118
+ * * The `timestamp` of the new event must match the `timestamp` of the existing event already ingested. As with ingestion, all timestamps must be sent in ISO8601 format with UTC timezone offset.
119
+ * * The `customer_id` or `external_customer_id` of the new event must match the `customer_id` or `external_customer_id` of the existing event already ingested. Exactly one of `customer_id` and `external_customer_id` should be specified, and similar to ingestion, the ID must identify a Customer resource within Orb. Unlike ingestion, for event amendment, we strictly enforce that the Customer must be in the Orb system, even during the initial integration period. We do not allow updating the `Customer` an event is associated with.
120
+ * * Orb does not accept an `idempotency_key` with the event in this endpoint, since this request is by design idempotent. On retryable errors, you should retry the request and assume the amendment operation has not succeeded until receipt of a 2xx.
121
+ * * The event's `timestamp` must fall within the customer's current subscription's billing period, or within the grace period of the customer's current subscription's previous billing period.
122
+ */
123
+ Event.prototype.amend = function (req, config) {
124
+ var _a, _b;
125
+ return __awaiter(this, void 0, void 0, function () {
126
+ var baseURL, url, _c, reqBodyHeaders, reqBody, client, headers, httpRes, contentType, res, decodedRes;
127
+ var _d;
128
+ return __generator(this, function (_e) {
129
+ switch (_e.label) {
130
+ case 0:
131
+ if (!(req instanceof utils.SpeakeasyBase)) {
132
+ req = new operations.AmendEventRequest(req);
133
+ }
134
+ baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
135
+ url = utils.generateURL(baseURL, "/events/{event_id}", req);
136
+ _c = __read([{}, {}], 2), reqBodyHeaders = _c[0], reqBody = _c[1];
137
+ try {
138
+ _d = __read(utils.serializeRequestBody(req, "amendedEvent", "json"), 2), reqBodyHeaders = _d[0], reqBody = _d[1];
139
+ }
140
+ catch (e) {
141
+ if (e instanceof Error) {
142
+ throw new Error("Error serializing request body, cause: ".concat(e.message));
143
+ }
144
+ }
145
+ client = this.sdkConfiguration.securityClient || this.sdkConfiguration.defaultClient;
146
+ headers = __assign(__assign({}, reqBodyHeaders), config === null || config === void 0 ? void 0 : config.headers);
147
+ headers["Accept"] = "application/json;q=1, application/json;q=0";
148
+ headers["user-agent"] = "speakeasy-sdk/".concat(this.sdkConfiguration.language, " ").concat(this.sdkConfiguration.sdkVersion, " ").concat(this.sdkConfiguration.genVersion, " ").concat(this.sdkConfiguration.openapiDocVersion);
149
+ return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url, method: "put", headers: headers, responseType: "arraybuffer", data: reqBody }, config))];
150
+ case 1:
151
+ httpRes = _e.sent();
152
+ contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
153
+ if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
154
+ throw new Error("status code not found in response: ".concat(httpRes));
155
+ }
156
+ res = new operations.AmendEventResponse({
157
+ statusCode: httpRes.status,
158
+ contentType: contentType,
159
+ rawResponse: httpRes,
160
+ });
161
+ decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
162
+ switch (true) {
163
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
164
+ if (utils.matchContentType(contentType, "application/json")) {
165
+ res.amendEventResult = utils.objectToClass(JSON.parse(decodedRes), shared.AmendEventResult);
166
+ }
167
+ break;
168
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
169
+ if (utils.matchContentType(contentType, "application/json")) {
170
+ res.requestValidationError = utils.objectToClass(JSON.parse(decodedRes), shared.RequestValidationError);
171
+ }
172
+ break;
173
+ }
174
+ return [2 /*return*/, res];
175
+ }
176
+ });
177
+ });
178
+ };
179
+ /**
180
+ * Close backfill
181
+ *
182
+ * @remarks
183
+ * Closing a backfill makes the updated usage visible in Orb. Upon closing a backfill, Orb will asynchronously reflect the updated usage in invoice amounts and usage graphs. Once all of the updates are complete, the backfill's status will transition to `reflected`.
184
+ *
185
+ *
186
+ */
187
+ Event.prototype.closeBackfill = function (req, config) {
188
+ var _a, _b;
189
+ return __awaiter(this, void 0, void 0, function () {
190
+ var baseURL, url, client, headers, httpRes, contentType, res, decodedRes;
191
+ return __generator(this, function (_c) {
192
+ switch (_c.label) {
193
+ case 0:
194
+ if (!(req instanceof utils.SpeakeasyBase)) {
195
+ req = new operations.CloseBackfillRequest(req);
196
+ }
197
+ baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
198
+ url = utils.generateURL(baseURL, "/events/backfills/{backfill_id}/close", req);
199
+ client = this.sdkConfiguration.securityClient || this.sdkConfiguration.defaultClient;
200
+ headers = __assign({}, config === null || config === void 0 ? void 0 : config.headers);
201
+ headers["Accept"] = "application/json";
202
+ headers["user-agent"] = "speakeasy-sdk/".concat(this.sdkConfiguration.language, " ").concat(this.sdkConfiguration.sdkVersion, " ").concat(this.sdkConfiguration.genVersion, " ").concat(this.sdkConfiguration.openapiDocVersion);
203
+ return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url, method: "post", headers: headers, responseType: "arraybuffer" }, config))];
204
+ case 1:
205
+ httpRes = _c.sent();
206
+ contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
207
+ if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
208
+ throw new Error("status code not found in response: ".concat(httpRes));
209
+ }
210
+ res = new operations.CloseBackfillResponse({
211
+ statusCode: httpRes.status,
212
+ contentType: contentType,
213
+ rawResponse: httpRes,
214
+ });
215
+ decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
216
+ switch (true) {
217
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
218
+ if (utils.matchContentType(contentType, "application/json")) {
219
+ res.backfill = utils.objectToClass(JSON.parse(decodedRes), shared.Backfill);
220
+ }
221
+ break;
222
+ }
223
+ return [2 /*return*/, res];
224
+ }
225
+ });
226
+ });
227
+ };
228
+ /**
229
+ * Create backfill
230
+ *
231
+ * @remarks
232
+ * Creating the backfill enables adding or replacing past events, even those that are older than the ingestion grace period. Performing a backfill in Orb involves 3 steps:
233
+ *
234
+ * 1. Create the backfill, specifying its parameters.
235
+ * 2. [Ingest](ingest) usage events, referencing the backfill (query parameter `backfill_id`).
236
+ * 3. [Close](close-backfill) the backfill, propagating the update in past usage throughout Orb.
237
+ *
238
+ * Changes from a backfill are not reflected until the backfill is closed, so you won’t need to worry about your customers seeing partially updated usage data. Backfills are also reversible, so you’ll be able to revert a backfill if you’ve made a mistake.
239
+ *
240
+ * This endpoint will return a backfill object, which contains an `id`. That `id` can then be used as the `backfill_id` query parameter to the event ingestion endpoint to associate ingested events with this backfill. The effects (e.g. updated usage graphs) of this backfill will not take place until the backfill is closed.
241
+ *
242
+ * If the `replace_existing_events` is `true`, existing events in the backfill's timeframe will be replaced with the newly ingested events associated with the backfill. If `false`, newly ingested events will be added to the existing events.
243
+ */
244
+ Event.prototype.create = function (req, config) {
245
+ var _a, _b;
246
+ return __awaiter(this, void 0, void 0, function () {
247
+ var baseURL, url, _c, reqBodyHeaders, reqBody, client, headers, httpRes, contentType, res, decodedRes;
248
+ var _d;
249
+ return __generator(this, function (_e) {
250
+ switch (_e.label) {
251
+ case 0:
252
+ if (!(req instanceof utils.SpeakeasyBase)) {
253
+ req = new shared.NewBackfill(req);
254
+ }
255
+ baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
256
+ url = baseURL.replace(/\/$/, "") + "/events/backfills";
257
+ _c = __read([{}, {}], 2), reqBodyHeaders = _c[0], reqBody = _c[1];
258
+ try {
259
+ _d = __read(utils.serializeRequestBody(req, "request", "json"), 2), reqBodyHeaders = _d[0], reqBody = _d[1];
260
+ }
261
+ catch (e) {
262
+ if (e instanceof Error) {
263
+ throw new Error("Error serializing request body, cause: ".concat(e.message));
264
+ }
265
+ }
266
+ client = this.sdkConfiguration.securityClient || this.sdkConfiguration.defaultClient;
267
+ headers = __assign(__assign({}, reqBodyHeaders), config === null || config === void 0 ? void 0 : config.headers);
268
+ headers["Accept"] = "application/json";
269
+ headers["user-agent"] = "speakeasy-sdk/".concat(this.sdkConfiguration.language, " ").concat(this.sdkConfiguration.sdkVersion, " ").concat(this.sdkConfiguration.genVersion, " ").concat(this.sdkConfiguration.openapiDocVersion);
270
+ return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url, method: "post", headers: headers, responseType: "arraybuffer", data: reqBody }, config))];
271
+ case 1:
272
+ httpRes = _e.sent();
273
+ contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
274
+ if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
275
+ throw new Error("status code not found in response: ".concat(httpRes));
276
+ }
277
+ res = new operations.CreateBackfillResponse({
278
+ statusCode: httpRes.status,
279
+ contentType: contentType,
280
+ rawResponse: httpRes,
281
+ });
282
+ decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
283
+ switch (true) {
284
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
285
+ if (utils.matchContentType(contentType, "application/json")) {
286
+ res.backfill = utils.objectToClass(JSON.parse(decodedRes), shared.Backfill);
287
+ }
288
+ break;
289
+ }
290
+ return [2 /*return*/, res];
291
+ }
292
+ });
293
+ });
294
+ };
295
+ /**
296
+ * Deprecate event
297
+ *
298
+ * @remarks
299
+ * This endpoint is used to deprecate a single usage event with a given `event_id`. `event_id` refers to the `idempotency_key` passed in during ingestion.
300
+ *
301
+ * This endpoint will mark the existing event as ignored. Note that if you attempt to re-ingest an event with the same `event_id` as a deprecated event, Orb will return an error.
302
+ *
303
+ * This is a powerful and audit-safe mechanism to retroactively deprecate a single event in cases where you need to:
304
+ * * no longer bill for an event that was improperly reported
305
+ * * no longer bill for an event based on the result of an external API call (ex. call to a payment gateway failed and the user should not be billed)
306
+ *
307
+ * If you want to only change specific properties of an event, but keep the event as part of the billing calculation, use the [Amend single event](amend-event) endpoint instead.
308
+ *
309
+ * This API is always audit-safe. The process will still retain the deprecated event, though it will be ignored for billing calculations. For auditing and data fidelity purposes, Orb never overwrites or permanently deletes ingested usage data.
310
+ *
311
+ * ## Request validation
312
+ * * Orb does not accept an `idempotency_key` with the event in this endpoint, since this request is by design idempotent. On retryable errors, you should retry the request and assume the deprecation operation has not succeeded until receipt of a 2xx.
313
+ * * The event's `timestamp` must fall within the customer's current subscription's billing period, or within the grace period of the customer's current subscription's previous billing period. Orb does not allow deprecating events for billing periods that have already invoiced customers.
314
+ * * The `customer_id` or the `external_customer_id` of the original event ingestion request must identify a Customer resource within Orb, even if this event was ingested during the initial integration period. We do not allow deprecating events for customers not in the Orb system.
315
+ */
316
+ Event.prototype.deprecateEvent = function (req, config) {
317
+ var _a, _b;
318
+ return __awaiter(this, void 0, void 0, function () {
319
+ var baseURL, url, client, headers, httpRes, contentType, res, decodedRes;
320
+ return __generator(this, function (_c) {
321
+ switch (_c.label) {
322
+ case 0:
323
+ if (!(req instanceof utils.SpeakeasyBase)) {
324
+ req = new operations.DeprecateEventRequest(req);
325
+ }
326
+ baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
327
+ url = utils.generateURL(baseURL, "/events/{event_id}/deprecate", req);
328
+ client = this.sdkConfiguration.securityClient || this.sdkConfiguration.defaultClient;
329
+ headers = __assign({}, config === null || config === void 0 ? void 0 : config.headers);
330
+ headers["Accept"] = "application/json;q=1, application/json;q=0";
331
+ headers["user-agent"] = "speakeasy-sdk/".concat(this.sdkConfiguration.language, " ").concat(this.sdkConfiguration.sdkVersion, " ").concat(this.sdkConfiguration.genVersion, " ").concat(this.sdkConfiguration.openapiDocVersion);
332
+ return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url, method: "put", headers: headers, responseType: "arraybuffer" }, config))];
333
+ case 1:
334
+ httpRes = _c.sent();
335
+ contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
336
+ if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
337
+ throw new Error("status code not found in response: ".concat(httpRes));
338
+ }
339
+ res = new operations.DeprecateEventResponse({
340
+ statusCode: httpRes.status,
341
+ contentType: contentType,
342
+ rawResponse: httpRes,
343
+ });
344
+ decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
345
+ switch (true) {
346
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
347
+ if (utils.matchContentType(contentType, "application/json")) {
348
+ res.deprecatedEventResult = utils.objectToClass(JSON.parse(decodedRes), shared.DeprecatedEventResult);
349
+ }
350
+ break;
351
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
352
+ if (utils.matchContentType(contentType, "application/json")) {
353
+ res.requestValidationError = utils.objectToClass(JSON.parse(decodedRes), shared.RequestValidationError);
354
+ }
355
+ break;
356
+ }
357
+ return [2 /*return*/, res];
358
+ }
359
+ });
360
+ });
361
+ };
362
+ /**
363
+ * Ingest events
364
+ *
365
+ * @remarks
366
+ * Orb's event ingestion model and API is designed around two core principles:
367
+ *
368
+ * 1. **Data fidelity**: The accuracy of your billing model depends on a robust foundation of events. Orb's API protocol encourages usage patterns that ensure that your data is consistently complete and correct.
369
+ * 2. **Fast integration**: Sending events into Orb requires no tedious setup steps or explicit field schema for your event shape, making it instant to start streaming in usage in real-time.
370
+ *
371
+ *
372
+ * ## Event shape
373
+ *
374
+ * Events are the starting point for all usage calculations in the system, and are simple at their core:
375
+ *
376
+ * ```json
377
+ * {
378
+ * // customer_id and external_customer_id are used to
379
+ * // attribute usage to a given Customer. Exactly one of these
380
+ * // should be specified in a given ingestion event.
381
+ *
382
+ * // `customer_id` is the Orb generated identifier for the Customer,
383
+ * // which is returned from the Create customer API call.
384
+ * customer_id: string,
385
+ *
386
+ * // external_customer_id is an alternate identifier which is associated
387
+ * // with a Customer at creation time. This is treated as an alias for
388
+ * // customer_id, and is usually set to an identifier native to your system.
389
+ * external_customer_id: string,
390
+ *
391
+ * // A string name identifying the event, usually a usage
392
+ * // action. By convention, this should not contain any whitespace.
393
+ * event_name: string,
394
+ *
395
+ * // An ISO 8601 format date with no timezone offset.
396
+ * // This should represent the time that usage occurred
397
+ * // and is important to attribute usage to a given
398
+ * // billing period. See the notes below on determining the timestamp.
399
+ * // e.g. 2020-12-09T16:09:53Z
400
+ * timestamp: string,
401
+ *
402
+ * // A unique value, generated by the client, that is
403
+ * // used to de-duplicate events.
404
+ * // Exactly one event with a given
405
+ * // idempotency key will be ingested, which allows for
406
+ * // safe request retries.
407
+ * idempotency_key: string
408
+ *
409
+ * // Optional custom metadata to attach to the event.
410
+ * // This might include a numeric value used for aggregation,
411
+ * // or a string/boolean value used for filtering.
412
+ * // The schema of this dictionary need not be pre-declared, and
413
+ * // properties can be added at any time.
414
+ * properties: {
415
+ * [key: string]?: string | number | boolean,
416
+ * },
417
+ * }
418
+ * ```
419
+ *
420
+ * ## Required fields
421
+ * Because events streamed to Orb are meant to be as flexible as possible, there are only a few required fields in every event.
422
+ *
423
+ * - We recommend that `idempotency_key` are unique strings that you generated with V4 UUIDs, but only require that they uniquely identify an event (i.e. don’t collide).
424
+ * - The `timestamp` field in the event body will be used to determine which billable period a given event falls into. For example, with a monthly billing cycle starting from the first of December, Orb will calculate metrics based on events that fall into the range `12-01 00:00:00 <= timestamp < 01-01 00:00:00`.
425
+ *
426
+ * ## Logging metadata
427
+ *
428
+ * Orb allows tagging events with metadata using a flexible properties dictionary. Since Orb does not enforce a rigid schema for this field-set, key-value pairs can be added dynamically as your events evolve.
429
+ *
430
+ * This dictionary can be helpful for a wide variety of use cases:
431
+ *
432
+ * - Numeric properties on events like `compute_time_ms` can later be inputs to our flexible query engine to determine usage.
433
+ * - Logging a region or cluster with each event can help you provide customers more granular visibility into their usage.
434
+ *
435
+ * We encourage logging this metadata with an eye towards future use cases to ensure full coverage for historical data. The datatype of the value in the properties dictionary is important for metric creation from an event source. Values that you wish to numerically aggregate should be of numeric type in the event.
436
+ *
437
+ *
438
+ * ## Determining event timestamp
439
+ * For cases where usage is being reported in real time as it is occurring, timestamp should correspond to the time that usage occurred.
440
+ *
441
+ * In cases where usage is reported in aggregate for a historical timeframe at a regular interval, we recommend setting the event `timestamp` to the midpoint of the interval. As an example, if you have an hourly reporter that sends data once an hour for the previous hour of usage, setting the `timestamp` to the half-hour mark will ensure that the usage is counted within the correct period.
442
+ *
443
+ * Note that other time-related fields (e.g. time elapsed) can be added to the properties dictionary as necessary.
444
+ *
445
+ * In cases where usage is reported in aggregate for a historical timeframe, the timestamp must be within the grace period set for your account. Events with `timestamp < current_time - grace_period` will not be accepted as a valid event, and will throw validation errors. Enforcing the grace period enables Orb to accurately map usage to the correct billing cycle and ensure that all usage is billed for in the corresponding billing period.
446
+ *
447
+ * ## Event validation
448
+ *
449
+ * Orb’s validation ensures that you recognize errors in your events as quickly as possible, and the API provides informative error messages to help you fix problems quickly.
450
+ *
451
+ * We validate the following:
452
+ *
453
+ * - Exactly one of `customer_id` and `external_customer_id` should be specified.
454
+ * - If specified, `customer_id` must identify a Customer resource within Orb. We do not support sending events for customers that have not been provisioned. Similarly, if specified, `external_customer_id` must be an identifier that is associated with an Orb Customer resource. Note: During our initial integration period, this enforcement will be temporarily turned into a warning to ensure smooth customer migration.
455
+ * - `timestamp` must conform to ISO 8601 and represent a timestamp at most 1 hour in the future. This timestamp should be sent in UTC timezone (no timezone offset).
456
+ *
457
+ * ## Idempotency and retry semantics
458
+ *
459
+ * Orb's idempotency guarantees allow you to implement safe retry logic in the event of network or machine failures, ensuring data fidelity. Each event in the request payload is associated with an idempotency key, and Orb guarantees that a single idempotency key will be successfully ingested at most once.
460
+ *
461
+ * - Successful responses return a 200 HTTP status code. The response contains information about previously processed events.
462
+ * - Requests that return a `4xx` HTTP status code indicate a payload error and contain at least one event with a validation failure. An event with a validation failure can be re-sent to the ingestion endpoint (after the payload is fixed) with the original idempotency key since that key is not marked as processed.
463
+ * - Requests that return a `5xx` HTTP status code indicate a server-side failure. These requests should be retried in their entirety.
464
+ *
465
+ *
466
+ * ## API usage and limits
467
+ * The ingestion API is designed made for real-time streaming ingestion and architected for high throughput. Even if events are later deemed unnecessary or filtered out, we encourage you to log them to Orb if they may be relevant to billing calculations in the future.
468
+ *
469
+ * To take advantage of the real-time features of the Orb platform and avoid any chance of dropped events by producers, we recommend reporting events to Orb frequently. Optionally, events can also be briefly aggregated at the source, as this API accepts an array of event bodies.
470
+ *
471
+ * Orb does not currently enforce a hard rate-limit for API usage or a maximum request payload size, but please give us a heads up if you’re changing either of these factors by an order of magnitude from initial setup.
472
+ *
473
+ * ## Testing in debug mode
474
+ * The ingestion API supports a debug mode, which returns additional verbose output to indicate which event idempotency keys were newly ingested or duplicates from previous requests. To enable this mode, mark `debug=true` as a query parameter.
475
+ *
476
+ * If `debug=true` is not specified, the response will only contain `validation_failed`. Orb will still honor the idempotency guarantees set [here](../guides/events-and-metrics/event-ingestion#event-volume-and-concurrency) in all cases.
477
+ *
478
+ * We strongly recommend that you only use debug mode as part of testing your initial Orb integration. Once you're ready to switch to production, disable debug mode to take advantage of improved performance and maximal throughput.
479
+ *
480
+ * #### Example: ingestion response with `debug=true`
481
+ *
482
+ * ```json
483
+ * {
484
+ * "debug": {
485
+ * "duplicate": [],
486
+ * "ingested": [
487
+ * "B7E83HDMfJPAunXW",
488
+ * "SJs5DQJ3TnwSqEZE",
489
+ * "8SivfDsNKwCeAXim"
490
+ * ]
491
+ * },
492
+ * "validation_failed": []
493
+ * }
494
+ * ```
495
+ *
496
+ * #### Example: ingestion response with `debug=false`
497
+ *
498
+ * ```json
499
+ * {
500
+ * "validation_failed": []
501
+ * }
502
+ * ```
503
+ */
504
+ Event.prototype.ingest = function (req, config) {
505
+ var _a, _b;
506
+ return __awaiter(this, void 0, void 0, function () {
507
+ var baseURL, url, _c, reqBodyHeaders, reqBody, client, headers, queryParams, httpRes, contentType, res, decodedRes;
508
+ var _d;
509
+ return __generator(this, function (_e) {
510
+ switch (_e.label) {
511
+ case 0:
512
+ if (!(req instanceof utils.SpeakeasyBase)) {
513
+ req = new operations.IngestRequest(req);
514
+ }
515
+ baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
516
+ url = baseURL.replace(/\/$/, "") + "/ingest";
517
+ _c = __read([{}, {}], 2), reqBodyHeaders = _c[0], reqBody = _c[1];
518
+ try {
519
+ _d = __read(utils.serializeRequestBody(req, "requestBody", "json"), 2), reqBodyHeaders = _d[0], reqBody = _d[1];
520
+ }
521
+ catch (e) {
522
+ if (e instanceof Error) {
523
+ throw new Error("Error serializing request body, cause: ".concat(e.message));
524
+ }
525
+ }
526
+ client = this.sdkConfiguration.securityClient || this.sdkConfiguration.defaultClient;
527
+ headers = __assign(__assign({}, reqBodyHeaders), config === null || config === void 0 ? void 0 : config.headers);
528
+ queryParams = utils.serializeQueryParams(req);
529
+ if (reqBody == null || Object.keys(reqBody).length === 0)
530
+ throw new Error("request body is required");
531
+ headers["Accept"] = "application/json;q=1, application/json;q=0";
532
+ headers["user-agent"] = "speakeasy-sdk/".concat(this.sdkConfiguration.language, " ").concat(this.sdkConfiguration.sdkVersion, " ").concat(this.sdkConfiguration.genVersion, " ").concat(this.sdkConfiguration.openapiDocVersion);
533
+ return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url + queryParams, method: "post", headers: headers, responseType: "arraybuffer", data: reqBody }, config))];
534
+ case 1:
535
+ httpRes = _e.sent();
536
+ contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
537
+ if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
538
+ throw new Error("status code not found in response: ".concat(httpRes));
539
+ }
540
+ res = new operations.IngestResponse({
541
+ statusCode: httpRes.status,
542
+ contentType: contentType,
543
+ rawResponse: httpRes,
544
+ });
545
+ decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
546
+ switch (true) {
547
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
548
+ if (utils.matchContentType(contentType, "application/json")) {
549
+ res.ingestionResponse = utils.objectToClass(JSON.parse(decodedRes), shared.IngestionResponse);
550
+ }
551
+ break;
552
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 400:
553
+ if (utils.matchContentType(contentType, "application/json")) {
554
+ res.requestValidationError = utils.objectToClass(JSON.parse(decodedRes), shared.RequestValidationError);
555
+ }
556
+ break;
557
+ }
558
+ return [2 /*return*/, res];
559
+ }
560
+ });
561
+ });
562
+ };
563
+ /**
564
+ * List backfills
565
+ *
566
+ * @remarks
567
+ * This endpoint returns a list of all backfills in a list format.
568
+ *
569
+ * The list of backfills is ordered starting from the most recently created backfill. The response also includes [`pagination_metadata`](../reference/pagination), which lets the caller retrieve the next page of results if they exist. More information about pagination can be found in the [Pagination-metadata schema](pagination).
570
+ */
571
+ Event.prototype.listBackfills = function (req, config) {
572
+ var _a, _b;
573
+ return __awaiter(this, void 0, void 0, function () {
574
+ var baseURL, url, client, headers, queryParams, httpRes, contentType, res, decodedRes;
575
+ return __generator(this, function (_c) {
576
+ switch (_c.label) {
577
+ case 0:
578
+ if (!(req instanceof utils.SpeakeasyBase)) {
579
+ req = new operations.ListBackfillsRequest(req);
580
+ }
581
+ baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
582
+ url = baseURL.replace(/\/$/, "") + "/events/backfills";
583
+ client = this.sdkConfiguration.securityClient || this.sdkConfiguration.defaultClient;
584
+ headers = __assign({}, config === null || config === void 0 ? void 0 : config.headers);
585
+ queryParams = utils.serializeQueryParams(req);
586
+ headers["Accept"] = "application/json";
587
+ headers["user-agent"] = "speakeasy-sdk/".concat(this.sdkConfiguration.language, " ").concat(this.sdkConfiguration.sdkVersion, " ").concat(this.sdkConfiguration.genVersion, " ").concat(this.sdkConfiguration.openapiDocVersion);
588
+ return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url + queryParams, method: "get", headers: headers, responseType: "arraybuffer" }, config))];
589
+ case 1:
590
+ httpRes = _c.sent();
591
+ contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
592
+ if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
593
+ throw new Error("status code not found in response: ".concat(httpRes));
594
+ }
595
+ res = new operations.ListBackfillsResponse({
596
+ statusCode: httpRes.status,
597
+ contentType: contentType,
598
+ rawResponse: httpRes,
599
+ });
600
+ decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
601
+ switch (true) {
602
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
603
+ if (utils.matchContentType(contentType, "application/json")) {
604
+ res.backfills = utils.objectToClass(JSON.parse(decodedRes), shared.Backfills);
605
+ }
606
+ break;
607
+ }
608
+ return [2 /*return*/, res];
609
+ }
610
+ });
611
+ });
612
+ };
613
+ /**
614
+ * Revert backfill
615
+ *
616
+ * @remarks
617
+ * Reverting a backfill undoes all the effects of closing the backfill. If the backfill is reflected, the status will transition to `pending_revert` while the effects of the backfill are undone. Once all effects are undone, the backfill will transition to `reverted`.
618
+ *
619
+ * If a backfill is reverted before its closed, no usage will be updated as a result of the backfill and it will immediately transition to `reverted`.
620
+ */
621
+ Event.prototype.revertBackfill = function (req, config) {
622
+ var _a, _b;
623
+ return __awaiter(this, void 0, void 0, function () {
624
+ var baseURL, url, client, headers, httpRes, contentType, res, decodedRes;
625
+ return __generator(this, function (_c) {
626
+ switch (_c.label) {
627
+ case 0:
628
+ if (!(req instanceof utils.SpeakeasyBase)) {
629
+ req = new operations.RevertBackfillRequest(req);
630
+ }
631
+ baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
632
+ url = utils.generateURL(baseURL, "/events/backfills/{backfill_id}/revert", req);
633
+ client = this.sdkConfiguration.securityClient || this.sdkConfiguration.defaultClient;
634
+ headers = __assign({}, config === null || config === void 0 ? void 0 : config.headers);
635
+ headers["Accept"] = "application/json";
636
+ headers["user-agent"] = "speakeasy-sdk/".concat(this.sdkConfiguration.language, " ").concat(this.sdkConfiguration.sdkVersion, " ").concat(this.sdkConfiguration.genVersion, " ").concat(this.sdkConfiguration.openapiDocVersion);
637
+ return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url, method: "post", headers: headers, responseType: "arraybuffer" }, config))];
638
+ case 1:
639
+ httpRes = _c.sent();
640
+ contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
641
+ if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
642
+ throw new Error("status code not found in response: ".concat(httpRes));
643
+ }
644
+ res = new operations.RevertBackfillResponse({
645
+ statusCode: httpRes.status,
646
+ contentType: contentType,
647
+ rawResponse: httpRes,
648
+ });
649
+ decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
650
+ switch (true) {
651
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
652
+ if (utils.matchContentType(contentType, "application/json")) {
653
+ res.backfill = utils.objectToClass(JSON.parse(decodedRes), shared.Backfill);
654
+ }
655
+ break;
656
+ }
657
+ return [2 /*return*/, res];
658
+ }
659
+ });
660
+ });
661
+ };
662
+ /**
663
+ * Search events
664
+ *
665
+ * @remarks
666
+ * This endpoint returns a filtered set of events for an account in a [paginated list format](../reference/pagination).
667
+ *
668
+ * Note that this is a `POST` endpoint rather than a `GET` endpoint because it employs a JSON body for search criteria rather than query parameters, allowing for a more flexible search syntax.
669
+ *
670
+ * Note that a search criteria _must_ be specified. Currently, Orb supports the following criteria:
671
+ * - `event_ids`: This is an explicit array of IDs to filter by. Note that an event's ID is the `idempotency_key` that was originally used for ingestion.
672
+ * - `invoice_id`: This is an issued Orb invoice ID (see also [List Invoices](list-invoices)). Orb will fetch all events that were used to calculate the invoice. In the common case, this will be a list of events whose `timestamp` property falls within the billing period specified by the invoice.
673
+ *
674
+ * By default, Orb does not return _deprecated_ events in this endpoint.
675
+ *
676
+ * By default, Orb will not throw a `404` if no events matched, Orb will return an empty array for `data` instead.
677
+ */
678
+ Event.prototype.search = function (req, config) {
679
+ var _a, _b;
680
+ return __awaiter(this, void 0, void 0, function () {
681
+ var baseURL, url, _c, reqBodyHeaders, reqBody, client, headers, queryParams, httpRes, contentType, res, decodedRes;
682
+ var _d;
683
+ return __generator(this, function (_e) {
684
+ switch (_e.label) {
685
+ case 0:
686
+ if (!(req instanceof utils.SpeakeasyBase)) {
687
+ req = new operations.SearchEventsRequest(req);
688
+ }
689
+ baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
690
+ url = baseURL.replace(/\/$/, "") + "/events/search";
691
+ _c = __read([{}, {}], 2), reqBodyHeaders = _c[0], reqBody = _c[1];
692
+ try {
693
+ _d = __read(utils.serializeRequestBody(req, "eventSearchCriteria", "json"), 2), reqBodyHeaders = _d[0], reqBody = _d[1];
694
+ }
695
+ catch (e) {
696
+ if (e instanceof Error) {
697
+ throw new Error("Error serializing request body, cause: ".concat(e.message));
698
+ }
699
+ }
700
+ client = this.sdkConfiguration.securityClient || this.sdkConfiguration.defaultClient;
701
+ headers = __assign(__assign({}, reqBodyHeaders), config === null || config === void 0 ? void 0 : config.headers);
702
+ queryParams = utils.serializeQueryParams(req);
703
+ headers["Accept"] = "application/json";
704
+ headers["user-agent"] = "speakeasy-sdk/".concat(this.sdkConfiguration.language, " ").concat(this.sdkConfiguration.sdkVersion, " ").concat(this.sdkConfiguration.genVersion, " ").concat(this.sdkConfiguration.openapiDocVersion);
705
+ return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url + queryParams, method: "post", headers: headers, responseType: "arraybuffer", data: reqBody }, config))];
706
+ case 1:
707
+ httpRes = _e.sent();
708
+ contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
709
+ if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
710
+ throw new Error("status code not found in response: ".concat(httpRes));
711
+ }
712
+ res = new operations.SearchEventsResponse({
713
+ statusCode: httpRes.status,
714
+ contentType: contentType,
715
+ rawResponse: httpRes,
716
+ });
717
+ decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
718
+ switch (true) {
719
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
720
+ if (utils.matchContentType(contentType, "application/json")) {
721
+ res.eventSearchResults = utils.objectToClass(JSON.parse(decodedRes), shared.EventSearchResults);
722
+ }
723
+ break;
724
+ }
725
+ return [2 /*return*/, res];
726
+ }
727
+ });
728
+ });
729
+ };
730
+ return Event;
731
+ }());
732
+ exports.Event = Event;