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,142 @@
1
+ import * as operations from "./models/operations";
2
+ import { SDKConfiguration } from "./sdk";
3
+ import { AxiosRequestConfig } from "axios";
4
+ /**
5
+ * The Credits resource represents a customer's credits. Credits are created when a customer's invoice is paid, and are updated when a customer's transaction is refunded.
6
+ */
7
+ export declare class Credit {
8
+ private sdkConfiguration;
9
+ constructor(sdkConfig: SDKConfiguration);
10
+ /**
11
+ * Create ledger entry by external ID
12
+ *
13
+ * @remarks
14
+ * This endpoint's resource and semantics exactly mirror [Add credit ledger entry](create-ledger-entry) but operates on an [external customer ID](../guides/events-and-metrics/customer-aliases) rather than an Orb issued identifier.
15
+ */
16
+ addByExternalId(req: operations.AddLedgerEntryExternalIdRequest, config?: AxiosRequestConfig): Promise<operations.AddLedgerEntryExternalIdResponse>;
17
+ /**
18
+ * Create ledger entry
19
+ *
20
+ * @remarks
21
+ * This endpoint allows you to create a new ledger entry for a specified customer's balance. This can be used to increment balance, deduct credits, and change the expiry date of existing credits.
22
+ *
23
+ * ## Effects of adding a ledger entry
24
+ * 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits) will return a credit block that represents the changes (i.e. balance changes or transfers).
25
+ * 2. A ledger entry will be added to the credits ledger for this customer, and therefore returned in the [View Credits Ledger](fetch-customer-credits) response as well as serialized in the response to this request. In the case of deductions without a specified block, multiple ledger entries may be created if the deduction spans credit blocks.
26
+ * 3. If `invoice_settings` is specified, an invoice will be created that reflects the cost of the credits (based on `amount` and `per_unit_cost_basis`).
27
+ *
28
+ * ## Adding credits
29
+ * Adding credits is done by creating an entry of type `increment`. This requires the caller to specify a number of credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb also recommends specifying a description to assist with auditing. When adding credits, the caller can also specify a cost basis per-credit, to indicate how much in USD a customer paid for a single credit in a block. This can later be used for revenue recognition.
30
+ *
31
+ * The following snippet illustrates a sample request body to increment credits which will expire in January of 2022.
32
+ *
33
+ * ```json
34
+ * {
35
+ * "entry_type": "increment",
36
+ * "amount": 100,
37
+ * "expiry_date": "2022-12-28",
38
+ * "per_unit_cost_basis": "0.20",
39
+ * "description": "Purchased 100 credits"
40
+ * }
41
+ * ```
42
+ *
43
+ * Note that by default, Orb will always first increment any _negative_ balance in existing blocks before adding the remaining amount to the desired credit block.
44
+ *
45
+ * ### Invoicing for credits
46
+ * By default, Orb manipulates the credit ledger but does not charge for credits. However, if you pass `invoice_settings` in the body of this request, Orb will also generate a one-off invoice for the customer for the credits pre-purchase. Note that you _must_ provide the `per_unit_cost_basis`, since the total charges on the invoice are calculated by multiplying the cost basis with the number of credit units added.
47
+ *
48
+ * ## Deducting Credits
49
+ * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb matches the algorithm for automatic deductions for determining which credit blocks to decrement from. In the case that the deduction leads to multiple ledger entries, the response from this endpoint will be the final deduction. Orb also optionally allows specifying a description to assist with auditing.
50
+ *
51
+ * The following snippet illustrates a sample request body to decrement credits.
52
+ *
53
+ * ```json
54
+ * {
55
+ * "entry_type": "decrement",
56
+ * "amount": 20,
57
+ * "description": "Removing excess credits"
58
+ * }
59
+ * ```
60
+ *
61
+ * ## Changing credits expiry
62
+ * If you'd like to change when existing credits expire, you should create a ledger entry of type `expiration_change`. For this entry, the required parameter `expiry_date` identifies the _originating_ block, and the required parameter `target_expiry_date` identifies when the transferred credits should now expire. A new credit block will be created with expiry date `target_expiry_date`, with the same cost basis data as the original credit block, if present.
63
+ *
64
+ * Note that the balance of the block with the given `expiry_date` must be at least equal to the desired transfer amount determined by the `amount` parameter.
65
+ *
66
+ * The following snippet illustrates a sample request body to extend the expiration date of credits by one year:
67
+ *
68
+ * ```json
69
+ * {
70
+ * "entry_type": "expiration_change",
71
+ * "amount": 10,
72
+ * "expiry_date": "2022-12-28",
73
+ * "block_id": "UiUhFWeLHPrBY4Ad",
74
+ * "target_expiry_date": "2023-12-28",
75
+ * "description": "Extending credit validity"
76
+ * }
77
+ * ```
78
+ */
79
+ create(req: operations.CreateLedgerEntryRequest, config?: AxiosRequestConfig): Promise<operations.CreateLedgerEntryResponse>;
80
+ /**
81
+ * Fetch customer credit balance
82
+ *
83
+ * @remarks
84
+ * This [paginated endpoint](../reference/pagination) can be used to fetch the current state of credit balance for the specified `customer_id`.
85
+ *
86
+ * Orb keeps track of credit balances in _credit blocks_, where each block is optionally associated with an `expiry_date`. Each time credits are added, a new credit block is created. Credits which do not expire have an `expiry_date` of `null`. To aid in revenue recognition, credit blocks can optionally have a `per_unit_cost_basis`, to indicate how much in USD a customer paid for a single credit in a block.
87
+ *
88
+ * Orb only returns _unexpired_ credit blocks in this response. For credits that have already expired, you can view this deduction from the customer's balance in the [Credit Ledger](fetch-customer-credits-ledger) response.
89
+ */
90
+ fetch(req: operations.FetchCustomerCreditsRequest, config?: AxiosRequestConfig): Promise<operations.FetchCustomerCreditsResponse>;
91
+ /**
92
+ * Fetch customer credit balance by external customer id
93
+ *
94
+ * @remarks
95
+ * This endpoint's resource and semantics exactly mirror [Retrieve credit balance](fetch-customer-credits) but operates on an [external customer ID](../guides/events-and-metrics/customer-aliases) rather than an Orb issued identifier.
96
+ */
97
+ fetchByExternalId(req: operations.FetchCustomerCreditsExternalIdRequest, config?: AxiosRequestConfig): Promise<operations.FetchCustomerCreditsExternalIdResponse>;
98
+ /**
99
+ * Fetch customer credits ledger
100
+ *
101
+ * @remarks
102
+ * The credits ledger provides _auditing_ functionality over Orb's credits system with a list of actions that have taken place to modify a customer's credit balance. This [paginated endpoint](../reference/pagination) lists these entries, starting from the most recent ledger entry.
103
+ *
104
+ * More details on using Orb's real-time credit feature are [here](../guides/product-catalog/prepurchase.md).
105
+ *
106
+ * There are four major types of modifications to credit balance, detailed below.
107
+ *
108
+ * ## Increment
109
+ * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger Entry](create-ledger-entry)). The ledger entry for such an action will always contain the total eligible starting and ending balance for the customer at the time the entry was added to the ledger.
110
+ *
111
+ * ## Decrement
112
+ *
113
+ * Deductions can occur as a result of an API call to create a ledger entry (see [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. Both ledger entries present the `decrement` entry type.
114
+ *
115
+ * As usage for a customer is reported into Orb, credits may be deducted according to the customer's plan configuration. An automated deduction of this type will result in a ledger entry, also with a starting and ending balance. In order to provide better tracing capabilities for automatic deductions, Orb always associates each automatic deduction with the `event_id` at the time of ingestion, used to pinpoint _why_ credit deduction took place and to ensure that credits are never deducted without an associated usage event.
116
+ *
117
+ * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring credit block* first in order to ensure that all credits are utilized appropriately. As an example, if trial credits with an expiration date of 2 weeks from now are present for a customer, they will be used before any deductions take place from a non-expiring credit block.
118
+ *
119
+ * If there are multiple blocks with the same expiration date, Orb will deduct from the block with the *lower cost basis* first (ex. trial credits with a $0 cost basis before paid credits with a $5.00 cost basis).
120
+ *
121
+ * It's also possible for a single usage event's deduction to _span_ credit blocks. In this case, Orb will deduct from the next block, ending at the credit block which consists of unexpiring credits. Each of these deductions will lead to a _separate_ ledger entry, one per credit block that is deducted from. By default, the customer's total credit balance in Orb can be negative as a result of a decrement.
122
+ *
123
+ * ## Expiration change
124
+ *
125
+ * The expiry of credits can be changed as a result of the API (See [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the balance as well as the initial and target expiry dates.
126
+ *
127
+ * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the `amount` represents the balance transferred. The credit block linked to the ledger entry is the source credit block from which there was an expiration change.
128
+ *
129
+ *
130
+ * ## Credits expiry
131
+ *
132
+ * When a set of credits expire on pre-set expiration date, the customer's balance automatically reflects this change and adds an entry to the ledger indicating this event. Note that credit expiry should always happen close to a date boundary in the customer's timezone.
133
+ */
134
+ fetchLedger(req: operations.FetchCustomerCreditsLedgerRequest, config?: AxiosRequestConfig): Promise<operations.FetchCustomerCreditsLedgerResponse>;
135
+ /**
136
+ * Fetch credits ledger by external ID
137
+ *
138
+ * @remarks
139
+ * This endpoint's resource and semantics exactly mirror [View credits ledger](fetch-customer-credits-ledger) but operates on an [external customer ID](../guides/events-and-metrics/customer-aliases) rather than an Orb issued identifier.
140
+ */
141
+ fetchLedgerExternalId(req: operations.FetchCustomerCreditsLedgerExternalIdRequest, config?: AxiosRequestConfig): Promise<operations.FetchCustomerCreditsLedgerExternalIdResponse>;
142
+ }
@@ -0,0 +1,501 @@
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.Credit = 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 Credits resource represents a customer's credits. Credits are created when a customer's invoice is paid, and are updated when a customer's transaction is refunded.
98
+ */
99
+ var Credit = /** @class */ (function () {
100
+ function Credit(sdkConfig) {
101
+ this.sdkConfiguration = sdkConfig;
102
+ }
103
+ /**
104
+ * Create ledger entry by external ID
105
+ *
106
+ * @remarks
107
+ * This endpoint's resource and semantics exactly mirror [Add credit ledger entry](create-ledger-entry) but operates on an [external customer ID](../guides/events-and-metrics/customer-aliases) rather than an Orb issued identifier.
108
+ */
109
+ Credit.prototype.addByExternalId = function (req, config) {
110
+ var _a, _b;
111
+ return __awaiter(this, void 0, void 0, function () {
112
+ var baseURL, url, _c, reqBodyHeaders, reqBody, client, headers, httpRes, contentType, res, decodedRes;
113
+ var _d;
114
+ return __generator(this, function (_e) {
115
+ switch (_e.label) {
116
+ case 0:
117
+ if (!(req instanceof utils.SpeakeasyBase)) {
118
+ req = new operations.AddLedgerEntryExternalIdRequest(req);
119
+ }
120
+ baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
121
+ url = utils.generateURL(baseURL, "/customers/external_customer_id/{external_customer_id}/credits/ledger_entry", req);
122
+ _c = __read([{}, {}], 2), reqBodyHeaders = _c[0], reqBody = _c[1];
123
+ try {
124
+ _d = __read(utils.serializeRequestBody(req, "newCreditLedgerEntry", "json"), 2), reqBodyHeaders = _d[0], reqBody = _d[1];
125
+ }
126
+ catch (e) {
127
+ if (e instanceof Error) {
128
+ throw new Error("Error serializing request body, cause: ".concat(e.message));
129
+ }
130
+ }
131
+ client = this.sdkConfiguration.securityClient || this.sdkConfiguration.defaultClient;
132
+ headers = __assign(__assign({}, reqBodyHeaders), config === null || config === void 0 ? void 0 : config.headers);
133
+ headers["Accept"] = "application/json";
134
+ headers["user-agent"] = "speakeasy-sdk/".concat(this.sdkConfiguration.language, " ").concat(this.sdkConfiguration.sdkVersion, " ").concat(this.sdkConfiguration.genVersion, " ").concat(this.sdkConfiguration.openapiDocVersion);
135
+ return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url, method: "post", headers: headers, responseType: "arraybuffer", data: reqBody }, config))];
136
+ case 1:
137
+ httpRes = _e.sent();
138
+ 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 : "";
139
+ if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
140
+ throw new Error("status code not found in response: ".concat(httpRes));
141
+ }
142
+ res = new operations.AddLedgerEntryExternalIdResponse({
143
+ statusCode: httpRes.status,
144
+ contentType: contentType,
145
+ rawResponse: httpRes,
146
+ });
147
+ decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
148
+ switch (true) {
149
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
150
+ if (utils.matchContentType(contentType, "application/json")) {
151
+ res.creditLedgerEntry = utils.objectToClass(JSON.parse(decodedRes), shared.CreditLedgerEntry);
152
+ }
153
+ break;
154
+ }
155
+ return [2 /*return*/, res];
156
+ }
157
+ });
158
+ });
159
+ };
160
+ /**
161
+ * Create ledger entry
162
+ *
163
+ * @remarks
164
+ * This endpoint allows you to create a new ledger entry for a specified customer's balance. This can be used to increment balance, deduct credits, and change the expiry date of existing credits.
165
+ *
166
+ * ## Effects of adding a ledger entry
167
+ * 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits) will return a credit block that represents the changes (i.e. balance changes or transfers).
168
+ * 2. A ledger entry will be added to the credits ledger for this customer, and therefore returned in the [View Credits Ledger](fetch-customer-credits) response as well as serialized in the response to this request. In the case of deductions without a specified block, multiple ledger entries may be created if the deduction spans credit blocks.
169
+ * 3. If `invoice_settings` is specified, an invoice will be created that reflects the cost of the credits (based on `amount` and `per_unit_cost_basis`).
170
+ *
171
+ * ## Adding credits
172
+ * Adding credits is done by creating an entry of type `increment`. This requires the caller to specify a number of credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb also recommends specifying a description to assist with auditing. When adding credits, the caller can also specify a cost basis per-credit, to indicate how much in USD a customer paid for a single credit in a block. This can later be used for revenue recognition.
173
+ *
174
+ * The following snippet illustrates a sample request body to increment credits which will expire in January of 2022.
175
+ *
176
+ * ```json
177
+ * {
178
+ * "entry_type": "increment",
179
+ * "amount": 100,
180
+ * "expiry_date": "2022-12-28",
181
+ * "per_unit_cost_basis": "0.20",
182
+ * "description": "Purchased 100 credits"
183
+ * }
184
+ * ```
185
+ *
186
+ * Note that by default, Orb will always first increment any _negative_ balance in existing blocks before adding the remaining amount to the desired credit block.
187
+ *
188
+ * ### Invoicing for credits
189
+ * By default, Orb manipulates the credit ledger but does not charge for credits. However, if you pass `invoice_settings` in the body of this request, Orb will also generate a one-off invoice for the customer for the credits pre-purchase. Note that you _must_ provide the `per_unit_cost_basis`, since the total charges on the invoice are calculated by multiplying the cost basis with the number of credit units added.
190
+ *
191
+ * ## Deducting Credits
192
+ * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb matches the algorithm for automatic deductions for determining which credit blocks to decrement from. In the case that the deduction leads to multiple ledger entries, the response from this endpoint will be the final deduction. Orb also optionally allows specifying a description to assist with auditing.
193
+ *
194
+ * The following snippet illustrates a sample request body to decrement credits.
195
+ *
196
+ * ```json
197
+ * {
198
+ * "entry_type": "decrement",
199
+ * "amount": 20,
200
+ * "description": "Removing excess credits"
201
+ * }
202
+ * ```
203
+ *
204
+ * ## Changing credits expiry
205
+ * If you'd like to change when existing credits expire, you should create a ledger entry of type `expiration_change`. For this entry, the required parameter `expiry_date` identifies the _originating_ block, and the required parameter `target_expiry_date` identifies when the transferred credits should now expire. A new credit block will be created with expiry date `target_expiry_date`, with the same cost basis data as the original credit block, if present.
206
+ *
207
+ * Note that the balance of the block with the given `expiry_date` must be at least equal to the desired transfer amount determined by the `amount` parameter.
208
+ *
209
+ * The following snippet illustrates a sample request body to extend the expiration date of credits by one year:
210
+ *
211
+ * ```json
212
+ * {
213
+ * "entry_type": "expiration_change",
214
+ * "amount": 10,
215
+ * "expiry_date": "2022-12-28",
216
+ * "block_id": "UiUhFWeLHPrBY4Ad",
217
+ * "target_expiry_date": "2023-12-28",
218
+ * "description": "Extending credit validity"
219
+ * }
220
+ * ```
221
+ */
222
+ Credit.prototype.create = function (req, config) {
223
+ var _a, _b;
224
+ return __awaiter(this, void 0, void 0, function () {
225
+ var baseURL, url, _c, reqBodyHeaders, reqBody, client, headers, httpRes, contentType, res, decodedRes;
226
+ var _d;
227
+ return __generator(this, function (_e) {
228
+ switch (_e.label) {
229
+ case 0:
230
+ if (!(req instanceof utils.SpeakeasyBase)) {
231
+ req = new operations.CreateLedgerEntryRequest(req);
232
+ }
233
+ baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
234
+ url = utils.generateURL(baseURL, "/customers/{customer_id}/credits/ledger_entry", req);
235
+ _c = __read([{}, {}], 2), reqBodyHeaders = _c[0], reqBody = _c[1];
236
+ try {
237
+ _d = __read(utils.serializeRequestBody(req, "newCreditLedgerEntry", "json"), 2), reqBodyHeaders = _d[0], reqBody = _d[1];
238
+ }
239
+ catch (e) {
240
+ if (e instanceof Error) {
241
+ throw new Error("Error serializing request body, cause: ".concat(e.message));
242
+ }
243
+ }
244
+ client = this.sdkConfiguration.securityClient || this.sdkConfiguration.defaultClient;
245
+ headers = __assign(__assign({}, reqBodyHeaders), config === null || config === void 0 ? void 0 : config.headers);
246
+ headers["Accept"] = "application/json";
247
+ headers["user-agent"] = "speakeasy-sdk/".concat(this.sdkConfiguration.language, " ").concat(this.sdkConfiguration.sdkVersion, " ").concat(this.sdkConfiguration.genVersion, " ").concat(this.sdkConfiguration.openapiDocVersion);
248
+ return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url, method: "post", headers: headers, responseType: "arraybuffer", data: reqBody }, config))];
249
+ case 1:
250
+ httpRes = _e.sent();
251
+ 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 : "";
252
+ if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
253
+ throw new Error("status code not found in response: ".concat(httpRes));
254
+ }
255
+ res = new operations.CreateLedgerEntryResponse({
256
+ statusCode: httpRes.status,
257
+ contentType: contentType,
258
+ rawResponse: httpRes,
259
+ });
260
+ decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
261
+ switch (true) {
262
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
263
+ if (utils.matchContentType(contentType, "application/json")) {
264
+ res.creditLedgerEntry = utils.objectToClass(JSON.parse(decodedRes), shared.CreditLedgerEntry);
265
+ }
266
+ break;
267
+ }
268
+ return [2 /*return*/, res];
269
+ }
270
+ });
271
+ });
272
+ };
273
+ /**
274
+ * Fetch customer credit balance
275
+ *
276
+ * @remarks
277
+ * This [paginated endpoint](../reference/pagination) can be used to fetch the current state of credit balance for the specified `customer_id`.
278
+ *
279
+ * Orb keeps track of credit balances in _credit blocks_, where each block is optionally associated with an `expiry_date`. Each time credits are added, a new credit block is created. Credits which do not expire have an `expiry_date` of `null`. To aid in revenue recognition, credit blocks can optionally have a `per_unit_cost_basis`, to indicate how much in USD a customer paid for a single credit in a block.
280
+ *
281
+ * Orb only returns _unexpired_ credit blocks in this response. For credits that have already expired, you can view this deduction from the customer's balance in the [Credit Ledger](fetch-customer-credits-ledger) response.
282
+ */
283
+ Credit.prototype.fetch = function (req, config) {
284
+ var _a, _b;
285
+ return __awaiter(this, void 0, void 0, function () {
286
+ var baseURL, url, client, headers, queryParams, httpRes, contentType, res, decodedRes;
287
+ return __generator(this, function (_c) {
288
+ switch (_c.label) {
289
+ case 0:
290
+ if (!(req instanceof utils.SpeakeasyBase)) {
291
+ req = new operations.FetchCustomerCreditsRequest(req);
292
+ }
293
+ baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
294
+ url = utils.generateURL(baseURL, "/customers/{customer_id}/credits", req);
295
+ client = this.sdkConfiguration.securityClient || this.sdkConfiguration.defaultClient;
296
+ headers = __assign({}, config === null || config === void 0 ? void 0 : config.headers);
297
+ queryParams = utils.serializeQueryParams(req);
298
+ headers["Accept"] = "application/json";
299
+ headers["user-agent"] = "speakeasy-sdk/".concat(this.sdkConfiguration.language, " ").concat(this.sdkConfiguration.sdkVersion, " ").concat(this.sdkConfiguration.genVersion, " ").concat(this.sdkConfiguration.openapiDocVersion);
300
+ return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url + queryParams, method: "get", headers: headers, responseType: "arraybuffer" }, config))];
301
+ case 1:
302
+ httpRes = _c.sent();
303
+ 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 : "";
304
+ if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
305
+ throw new Error("status code not found in response: ".concat(httpRes));
306
+ }
307
+ res = new operations.FetchCustomerCreditsResponse({
308
+ statusCode: httpRes.status,
309
+ contentType: contentType,
310
+ rawResponse: httpRes,
311
+ });
312
+ decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
313
+ switch (true) {
314
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
315
+ if (utils.matchContentType(contentType, "application/json")) {
316
+ res.credits = utils.objectToClass(JSON.parse(decodedRes), shared.Credits);
317
+ }
318
+ break;
319
+ }
320
+ return [2 /*return*/, res];
321
+ }
322
+ });
323
+ });
324
+ };
325
+ /**
326
+ * Fetch customer credit balance by external customer id
327
+ *
328
+ * @remarks
329
+ * This endpoint's resource and semantics exactly mirror [Retrieve credit balance](fetch-customer-credits) but operates on an [external customer ID](../guides/events-and-metrics/customer-aliases) rather than an Orb issued identifier.
330
+ */
331
+ Credit.prototype.fetchByExternalId = function (req, config) {
332
+ var _a, _b;
333
+ return __awaiter(this, void 0, void 0, function () {
334
+ var baseURL, url, client, headers, queryParams, httpRes, contentType, res, decodedRes;
335
+ return __generator(this, function (_c) {
336
+ switch (_c.label) {
337
+ case 0:
338
+ if (!(req instanceof utils.SpeakeasyBase)) {
339
+ req = new operations.FetchCustomerCreditsExternalIdRequest(req);
340
+ }
341
+ baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
342
+ url = utils.generateURL(baseURL, "/customers/external_customer_id/{external_customer_id}/credits", req);
343
+ client = this.sdkConfiguration.securityClient || this.sdkConfiguration.defaultClient;
344
+ headers = __assign({}, config === null || config === void 0 ? void 0 : config.headers);
345
+ queryParams = utils.serializeQueryParams(req);
346
+ headers["Accept"] = "application/json";
347
+ headers["user-agent"] = "speakeasy-sdk/".concat(this.sdkConfiguration.language, " ").concat(this.sdkConfiguration.sdkVersion, " ").concat(this.sdkConfiguration.genVersion, " ").concat(this.sdkConfiguration.openapiDocVersion);
348
+ return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url + queryParams, method: "get", headers: headers, responseType: "arraybuffer" }, config))];
349
+ case 1:
350
+ httpRes = _c.sent();
351
+ 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 : "";
352
+ if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
353
+ throw new Error("status code not found in response: ".concat(httpRes));
354
+ }
355
+ res = new operations.FetchCustomerCreditsExternalIdResponse({
356
+ statusCode: httpRes.status,
357
+ contentType: contentType,
358
+ rawResponse: httpRes,
359
+ });
360
+ decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
361
+ switch (true) {
362
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
363
+ if (utils.matchContentType(contentType, "application/json")) {
364
+ res.credits = utils.objectToClass(JSON.parse(decodedRes), shared.Credits);
365
+ }
366
+ break;
367
+ }
368
+ return [2 /*return*/, res];
369
+ }
370
+ });
371
+ });
372
+ };
373
+ /**
374
+ * Fetch customer credits ledger
375
+ *
376
+ * @remarks
377
+ * The credits ledger provides _auditing_ functionality over Orb's credits system with a list of actions that have taken place to modify a customer's credit balance. This [paginated endpoint](../reference/pagination) lists these entries, starting from the most recent ledger entry.
378
+ *
379
+ * More details on using Orb's real-time credit feature are [here](../guides/product-catalog/prepurchase.md).
380
+ *
381
+ * There are four major types of modifications to credit balance, detailed below.
382
+ *
383
+ * ## Increment
384
+ * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger Entry](create-ledger-entry)). The ledger entry for such an action will always contain the total eligible starting and ending balance for the customer at the time the entry was added to the ledger.
385
+ *
386
+ * ## Decrement
387
+ *
388
+ * Deductions can occur as a result of an API call to create a ledger entry (see [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. Both ledger entries present the `decrement` entry type.
389
+ *
390
+ * As usage for a customer is reported into Orb, credits may be deducted according to the customer's plan configuration. An automated deduction of this type will result in a ledger entry, also with a starting and ending balance. In order to provide better tracing capabilities for automatic deductions, Orb always associates each automatic deduction with the `event_id` at the time of ingestion, used to pinpoint _why_ credit deduction took place and to ensure that credits are never deducted without an associated usage event.
391
+ *
392
+ * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring credit block* first in order to ensure that all credits are utilized appropriately. As an example, if trial credits with an expiration date of 2 weeks from now are present for a customer, they will be used before any deductions take place from a non-expiring credit block.
393
+ *
394
+ * If there are multiple blocks with the same expiration date, Orb will deduct from the block with the *lower cost basis* first (ex. trial credits with a $0 cost basis before paid credits with a $5.00 cost basis).
395
+ *
396
+ * It's also possible for a single usage event's deduction to _span_ credit blocks. In this case, Orb will deduct from the next block, ending at the credit block which consists of unexpiring credits. Each of these deductions will lead to a _separate_ ledger entry, one per credit block that is deducted from. By default, the customer's total credit balance in Orb can be negative as a result of a decrement.
397
+ *
398
+ * ## Expiration change
399
+ *
400
+ * The expiry of credits can be changed as a result of the API (See [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the balance as well as the initial and target expiry dates.
401
+ *
402
+ * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the `amount` represents the balance transferred. The credit block linked to the ledger entry is the source credit block from which there was an expiration change.
403
+ *
404
+ *
405
+ * ## Credits expiry
406
+ *
407
+ * When a set of credits expire on pre-set expiration date, the customer's balance automatically reflects this change and adds an entry to the ledger indicating this event. Note that credit expiry should always happen close to a date boundary in the customer's timezone.
408
+ */
409
+ Credit.prototype.fetchLedger = function (req, config) {
410
+ var _a, _b;
411
+ return __awaiter(this, void 0, void 0, function () {
412
+ var baseURL, url, client, headers, queryParams, httpRes, contentType, res, decodedRes;
413
+ return __generator(this, function (_c) {
414
+ switch (_c.label) {
415
+ case 0:
416
+ if (!(req instanceof utils.SpeakeasyBase)) {
417
+ req = new operations.FetchCustomerCreditsLedgerRequest(req);
418
+ }
419
+ baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
420
+ url = utils.generateURL(baseURL, "/customers/{customer_id}/credits/ledger", req);
421
+ client = this.sdkConfiguration.securityClient || this.sdkConfiguration.defaultClient;
422
+ headers = __assign({}, config === null || config === void 0 ? void 0 : config.headers);
423
+ queryParams = utils.serializeQueryParams(req);
424
+ headers["Accept"] = "application/json";
425
+ headers["user-agent"] = "speakeasy-sdk/".concat(this.sdkConfiguration.language, " ").concat(this.sdkConfiguration.sdkVersion, " ").concat(this.sdkConfiguration.genVersion, " ").concat(this.sdkConfiguration.openapiDocVersion);
426
+ return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url + queryParams, method: "get", headers: headers, responseType: "arraybuffer" }, config))];
427
+ case 1:
428
+ httpRes = _c.sent();
429
+ 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 : "";
430
+ if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
431
+ throw new Error("status code not found in response: ".concat(httpRes));
432
+ }
433
+ res = new operations.FetchCustomerCreditsLedgerResponse({
434
+ statusCode: httpRes.status,
435
+ contentType: contentType,
436
+ rawResponse: httpRes,
437
+ });
438
+ decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
439
+ switch (true) {
440
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
441
+ if (utils.matchContentType(contentType, "application/json")) {
442
+ res.creditLedgerEntries = utils.objectToClass(JSON.parse(decodedRes), shared.CreditLedgerEntries);
443
+ }
444
+ break;
445
+ }
446
+ return [2 /*return*/, res];
447
+ }
448
+ });
449
+ });
450
+ };
451
+ /**
452
+ * Fetch credits ledger by external ID
453
+ *
454
+ * @remarks
455
+ * This endpoint's resource and semantics exactly mirror [View credits ledger](fetch-customer-credits-ledger) but operates on an [external customer ID](../guides/events-and-metrics/customer-aliases) rather than an Orb issued identifier.
456
+ */
457
+ Credit.prototype.fetchLedgerExternalId = function (req, config) {
458
+ var _a, _b;
459
+ return __awaiter(this, void 0, void 0, function () {
460
+ var baseURL, url, client, headers, queryParams, httpRes, contentType, res, decodedRes;
461
+ return __generator(this, function (_c) {
462
+ switch (_c.label) {
463
+ case 0:
464
+ if (!(req instanceof utils.SpeakeasyBase)) {
465
+ req = new operations.FetchCustomerCreditsLedgerExternalIdRequest(req);
466
+ }
467
+ baseURL = utils.templateUrl(this.sdkConfiguration.serverURL, this.sdkConfiguration.serverDefaults);
468
+ url = utils.generateURL(baseURL, "/customers/external_customer_id/{external_customer_id}/credits/ledger", req);
469
+ client = this.sdkConfiguration.securityClient || this.sdkConfiguration.defaultClient;
470
+ headers = __assign({}, config === null || config === void 0 ? void 0 : config.headers);
471
+ queryParams = utils.serializeQueryParams(req);
472
+ headers["Accept"] = "application/json";
473
+ headers["user-agent"] = "speakeasy-sdk/".concat(this.sdkConfiguration.language, " ").concat(this.sdkConfiguration.sdkVersion, " ").concat(this.sdkConfiguration.genVersion, " ").concat(this.sdkConfiguration.openapiDocVersion);
474
+ return [4 /*yield*/, client.request(__assign({ validateStatus: function () { return true; }, url: url + queryParams, method: "get", headers: headers, responseType: "arraybuffer" }, config))];
475
+ case 1:
476
+ httpRes = _c.sent();
477
+ 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 : "";
478
+ if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null) {
479
+ throw new Error("status code not found in response: ".concat(httpRes));
480
+ }
481
+ res = new operations.FetchCustomerCreditsLedgerExternalIdResponse({
482
+ statusCode: httpRes.status,
483
+ contentType: contentType,
484
+ rawResponse: httpRes,
485
+ });
486
+ decodedRes = new TextDecoder().decode(httpRes === null || httpRes === void 0 ? void 0 : httpRes.data);
487
+ switch (true) {
488
+ case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
489
+ if (utils.matchContentType(contentType, "application/json")) {
490
+ res.creditLedgerEntries = utils.objectToClass(JSON.parse(decodedRes), shared.CreditLedgerEntries);
491
+ }
492
+ break;
493
+ }
494
+ return [2 /*return*/, res];
495
+ }
496
+ });
497
+ });
498
+ };
499
+ return Credit;
500
+ }());
501
+ exports.Credit = Credit;