orb-billing 0.1.0.pre.alpha.37 → 0.1.0.pre.alpha.39

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 (402) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +29 -5
  3. data/lib/orb/client.rb +4 -0
  4. data/lib/orb/internal/page.rb +6 -2
  5. data/lib/orb/internal/transport/base_client.rb +3 -3
  6. data/lib/orb/internal/transport/pooled_net_requester.rb +2 -2
  7. data/lib/orb/internal/type/array_of.rb +5 -3
  8. data/lib/orb/internal/type/base_model.rb +19 -16
  9. data/lib/orb/internal/type/base_page.rb +4 -1
  10. data/lib/orb/internal/type/{boolean_model.rb → boolean.rb} +2 -2
  11. data/lib/orb/internal/type/converter.rb +26 -23
  12. data/lib/orb/internal/type/enum.rb +10 -8
  13. data/lib/orb/internal/type/hash_of.rb +3 -1
  14. data/lib/orb/internal/util.rb +29 -50
  15. data/lib/orb/models/alert.rb +10 -10
  16. data/lib/orb/models/alert_create_for_customer_params.rb +3 -3
  17. data/lib/orb/models/alert_create_for_external_customer_params.rb +3 -3
  18. data/lib/orb/models/alert_create_for_subscription_params.rb +3 -3
  19. data/lib/orb/models/alert_list_params.rb +5 -5
  20. data/lib/orb/models/alert_update_params.rb +3 -3
  21. data/lib/orb/models/amount_discount.rb +1 -1
  22. data/lib/orb/models/billable_metric.rb +7 -7
  23. data/lib/orb/models/coupon.rb +7 -7
  24. data/lib/orb/models/coupon_create_params.rb +2 -2
  25. data/lib/orb/models/coupon_list_params.rb +3 -3
  26. data/lib/orb/models/coupons/subscription_list_params.rb +1 -1
  27. data/lib/orb/models/credit_note.rb +1 -1
  28. data/lib/orb/models/credit_note_list_params.rb +5 -5
  29. data/lib/orb/models/customer.rb +237 -237
  30. data/lib/orb/models/customer_create_params.rb +229 -229
  31. data/lib/orb/models/customer_list_params.rb +5 -5
  32. data/lib/orb/models/customer_update_by_external_id_params.rb +230 -230
  33. data/lib/orb/models/customer_update_params.rb +230 -230
  34. data/lib/orb/models/customers/balance_transaction_create_response.rb +2 -2
  35. data/lib/orb/models/customers/balance_transaction_list_params.rb +5 -5
  36. data/lib/orb/models/customers/balance_transaction_list_response.rb +2 -2
  37. data/lib/orb/models/customers/cost_list_by_external_id_params.rb +6 -6
  38. data/lib/orb/models/customers/cost_list_params.rb +6 -6
  39. data/lib/orb/models/customers/credit_list_by_external_id_params.rb +3 -3
  40. data/lib/orb/models/customers/credit_list_params.rb +3 -3
  41. data/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_params.rb +22 -22
  42. data/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_response.rb +22 -22
  43. data/lib/orb/models/customers/credits/ledger_create_entry_params.rb +22 -22
  44. data/lib/orb/models/customers/credits/ledger_create_entry_response.rb +22 -22
  45. data/lib/orb/models/customers/credits/ledger_list_by_external_id_params.rb +5 -5
  46. data/lib/orb/models/customers/credits/ledger_list_by_external_id_response.rb +22 -22
  47. data/lib/orb/models/customers/credits/ledger_list_params.rb +5 -5
  48. data/lib/orb/models/customers/credits/ledger_list_response.rb +22 -22
  49. data/lib/orb/models/customers/credits/top_up_create_by_external_id_params.rb +10 -10
  50. data/lib/orb/models/customers/credits/top_up_create_by_external_id_response.rb +9 -9
  51. data/lib/orb/models/customers/credits/top_up_create_params.rb +10 -10
  52. data/lib/orb/models/customers/credits/top_up_create_response.rb +9 -9
  53. data/lib/orb/models/customers/credits/top_up_list_by_external_id_params.rb +1 -1
  54. data/lib/orb/models/customers/credits/top_up_list_by_external_id_response.rb +9 -9
  55. data/lib/orb/models/customers/credits/top_up_list_params.rb +1 -1
  56. data/lib/orb/models/customers/credits/top_up_list_response.rb +9 -9
  57. data/lib/orb/models/dimensional_price_group.rb +7 -7
  58. data/lib/orb/models/dimensional_price_group_create_params.rb +2 -2
  59. data/lib/orb/models/dimensional_price_group_list_params.rb +1 -1
  60. data/lib/orb/models/evaluate_price_group.rb +1 -1
  61. data/lib/orb/models/event_ingest_params.rb +8 -8
  62. data/lib/orb/models/event_ingest_response.rb +4 -4
  63. data/lib/orb/models/event_search_params.rb +5 -5
  64. data/lib/orb/models/event_search_response.rb +9 -9
  65. data/lib/orb/models/event_update_params.rb +4 -4
  66. data/lib/orb/models/events/backfill_close_response.rb +8 -8
  67. data/lib/orb/models/events/backfill_create_params.rb +12 -12
  68. data/lib/orb/models/events/backfill_create_response.rb +8 -8
  69. data/lib/orb/models/events/backfill_fetch_response.rb +8 -8
  70. data/lib/orb/models/events/backfill_list_params.rb +1 -1
  71. data/lib/orb/models/events/backfill_list_response.rb +8 -8
  72. data/lib/orb/models/events/backfill_revert_response.rb +8 -8
  73. data/lib/orb/models/events/event_volumes.rb +1 -1
  74. data/lib/orb/models/events/volume_list_params.rb +7 -7
  75. data/lib/orb/models/invoice.rb +278 -278
  76. data/lib/orb/models/invoice_create_params.rb +13 -12
  77. data/lib/orb/models/invoice_fetch_upcoming_response.rb +274 -274
  78. data/lib/orb/models/invoice_issue_params.rb +5 -5
  79. data/lib/orb/models/invoice_line_item_create_params.rb +1 -1
  80. data/lib/orb/models/invoice_line_item_create_response.rb +32 -32
  81. data/lib/orb/models/invoice_list_params.rb +13 -13
  82. data/lib/orb/models/invoice_update_params.rb +2 -2
  83. data/lib/orb/models/item.rb +2 -2
  84. data/lib/orb/models/item_list_params.rb +1 -1
  85. data/lib/orb/models/metric_create_params.rb +2 -2
  86. data/lib/orb/models/metric_list_params.rb +5 -5
  87. data/lib/orb/models/metric_update_params.rb +2 -2
  88. data/lib/orb/models/pagination_metadata.rb +1 -1
  89. data/lib/orb/models/percentage_discount.rb +2 -2
  90. data/lib/orb/models/plan.rb +40 -40
  91. data/lib/orb/models/plan_create_params.rb +292 -292
  92. data/lib/orb/models/plan_list_params.rb +5 -5
  93. data/lib/orb/models/plan_update_params.rb +4 -4
  94. data/lib/orb/models/plans/external_plan_id_update_params.rb +4 -4
  95. data/lib/orb/models/price.rb +186 -186
  96. data/lib/orb/models/price_create_params.rb +21 -21
  97. data/lib/orb/models/price_evaluate_params.rb +4 -4
  98. data/lib/orb/models/price_list_params.rb +1 -1
  99. data/lib/orb/models/price_update_params.rb +2 -2
  100. data/lib/orb/models/prices/external_price_id_update_params.rb +2 -2
  101. data/lib/orb/models/subscription.rb +120 -93
  102. data/lib/orb/models/subscription_cancel_params.rb +4 -4
  103. data/lib/orb/models/subscription_cancel_response.rb +156 -78
  104. data/lib/orb/models/subscription_change_apply_params.rb +33 -0
  105. data/lib/orb/models/subscription_change_apply_response.rb +1372 -0
  106. data/lib/orb/models/subscription_change_cancel_params.rb +19 -0
  107. data/lib/orb/models/subscription_change_cancel_response.rb +1372 -0
  108. data/lib/orb/models/subscription_change_retrieve_params.rb +19 -0
  109. data/lib/orb/models/subscription_change_retrieve_response.rb +1372 -0
  110. data/lib/orb/models/subscription_create_params.rb +705 -705
  111. data/lib/orb/models/subscription_create_response.rb +156 -78
  112. data/lib/orb/models/subscription_fetch_costs_params.rb +6 -6
  113. data/lib/orb/models/subscription_fetch_schedule_params.rb +5 -5
  114. data/lib/orb/models/subscription_fetch_schedule_response.rb +2 -2
  115. data/lib/orb/models/subscription_fetch_usage_params.rb +8 -8
  116. data/lib/orb/models/subscription_list_params.rb +5 -5
  117. data/lib/orb/models/subscription_price_intervals_params.rb +358 -358
  118. data/lib/orb/models/subscription_price_intervals_response.rb +158 -78
  119. data/lib/orb/models/subscription_schedule_plan_change_params.rb +715 -715
  120. data/lib/orb/models/subscription_schedule_plan_change_response.rb +158 -78
  121. data/lib/orb/models/subscription_trigger_phase_params.rb +4 -4
  122. data/lib/orb/models/subscription_trigger_phase_response.rb +158 -78
  123. data/lib/orb/models/subscription_unschedule_cancellation_response.rb +158 -78
  124. data/lib/orb/models/subscription_unschedule_fixed_fee_quantity_updates_response.rb +159 -79
  125. data/lib/orb/models/subscription_unschedule_pending_plan_changes_response.rb +158 -78
  126. data/lib/orb/models/subscription_update_fixed_fee_quantity_params.rb +9 -9
  127. data/lib/orb/models/subscription_update_fixed_fee_quantity_response.rb +158 -78
  128. data/lib/orb/models/subscription_update_params.rb +11 -11
  129. data/lib/orb/models/subscription_update_trial_params.rb +4 -4
  130. data/lib/orb/models/subscription_update_trial_response.rb +158 -78
  131. data/lib/orb/models/trial_discount.rb +1 -1
  132. data/lib/orb/models/usage_discount.rb +2 -2
  133. data/lib/orb/request_options.rb +7 -7
  134. data/lib/orb/resources/alerts.rb +40 -35
  135. data/lib/orb/resources/coupons/subscriptions.rb +3 -3
  136. data/lib/orb/resources/coupons.rb +9 -9
  137. data/lib/orb/resources/credit_notes.rb +10 -5
  138. data/lib/orb/resources/customers/balance_transactions.rb +28 -23
  139. data/lib/orb/resources/customers/costs.rb +232 -232
  140. data/lib/orb/resources/customers/credits/ledger.rb +348 -338
  141. data/lib/orb/resources/customers/credits/top_ups.rb +12 -12
  142. data/lib/orb/resources/customers/credits.rb +8 -8
  143. data/lib/orb/resources/customers.rb +61 -56
  144. data/lib/orb/resources/dimensional_price_groups.rb +6 -6
  145. data/lib/orb/resources/events/backfills.rb +49 -49
  146. data/lib/orb/resources/events/volume.rb +10 -10
  147. data/lib/orb/resources/events.rb +295 -295
  148. data/lib/orb/resources/invoice_line_items.rb +1 -1
  149. data/lib/orb/resources/invoices.rb +40 -31
  150. data/lib/orb/resources/items.rb +1 -1
  151. data/lib/orb/resources/metrics.rb +13 -8
  152. data/lib/orb/resources/plans/external_plan_id.rb +14 -14
  153. data/lib/orb/resources/plans.rb +24 -19
  154. data/lib/orb/resources/prices/external_price_id.rb +4 -4
  155. data/lib/orb/resources/prices.rb +30 -30
  156. data/lib/orb/resources/subscription_changes.rb +87 -0
  157. data/lib/orb/resources/subscriptions.rb +817 -807
  158. data/lib/orb/resources/top_level.rb +4 -4
  159. data/lib/orb/version.rb +1 -1
  160. data/lib/orb.rb +8 -1
  161. data/rbi/lib/orb/client.rbi +5 -4
  162. data/rbi/lib/orb/errors.rbi +3 -6
  163. data/rbi/lib/orb/internal/page.rbi +3 -6
  164. data/rbi/lib/orb/internal/transport/base_client.rbi +13 -27
  165. data/rbi/lib/orb/internal/transport/pooled_net_requester.rbi +7 -13
  166. data/rbi/lib/orb/internal/type/array_of.rbi +10 -18
  167. data/rbi/lib/orb/internal/type/base_model.rbi +45 -64
  168. data/rbi/lib/orb/internal/type/base_page.rbi +5 -10
  169. data/rbi/lib/orb/internal/type/{boolean_model.rbi → boolean.rbi} +5 -9
  170. data/rbi/lib/orb/internal/type/converter.rbi +25 -31
  171. data/rbi/lib/orb/internal/type/enum.rbi +14 -20
  172. data/rbi/lib/orb/internal/type/hash_of.rbi +8 -16
  173. data/rbi/lib/orb/internal/type/request_parameters.rbi +1 -2
  174. data/rbi/lib/orb/internal/type/union.rbi +10 -20
  175. data/rbi/lib/orb/internal/type/unknown.rbi +4 -8
  176. data/rbi/lib/orb/internal/util.rbi +40 -72
  177. data/rbi/lib/orb/internal.rbi +1 -1
  178. data/rbi/lib/orb/models/alert.rbi +21 -33
  179. data/rbi/lib/orb/models/alert_create_for_customer_params.rbi +8 -13
  180. data/rbi/lib/orb/models/alert_create_for_external_customer_params.rbi +8 -13
  181. data/rbi/lib/orb/models/alert_create_for_subscription_params.rbi +8 -13
  182. data/rbi/lib/orb/models/alert_disable_params.rbi +2 -4
  183. data/rbi/lib/orb/models/alert_enable_params.rbi +2 -4
  184. data/rbi/lib/orb/models/alert_list_params.rbi +3 -6
  185. data/rbi/lib/orb/models/alert_retrieve_params.rbi +2 -4
  186. data/rbi/lib/orb/models/alert_update_params.rbi +7 -11
  187. data/rbi/lib/orb/models/amount_discount.rbi +4 -7
  188. data/rbi/lib/orb/models/billable_metric.rbi +10 -13
  189. data/rbi/lib/orb/models/billing_cycle_relative_date.rbi +1 -2
  190. data/rbi/lib/orb/models/coupon.rbi +9 -11
  191. data/rbi/lib/orb/models/coupon_archive_params.rbi +2 -4
  192. data/rbi/lib/orb/models/coupon_create_params.rbi +8 -14
  193. data/rbi/lib/orb/models/coupon_fetch_params.rbi +2 -4
  194. data/rbi/lib/orb/models/coupon_list_params.rbi +3 -4
  195. data/rbi/lib/orb/models/coupons/subscription_list_params.rbi +3 -5
  196. data/rbi/lib/orb/models/credit_note.rbi +22 -45
  197. data/rbi/lib/orb/models/credit_note_create_params.rbi +5 -10
  198. data/rbi/lib/orb/models/credit_note_fetch_params.rbi +2 -4
  199. data/rbi/lib/orb/models/credit_note_list_params.rbi +3 -6
  200. data/rbi/lib/orb/models/customer.rbi +256 -281
  201. data/rbi/lib/orb/models/customer_create_params.rbi +251 -276
  202. data/rbi/lib/orb/models/customer_delete_params.rbi +2 -4
  203. data/rbi/lib/orb/models/customer_fetch_by_external_id_params.rbi +2 -4
  204. data/rbi/lib/orb/models/customer_fetch_params.rbi +2 -4
  205. data/rbi/lib/orb/models/customer_list_params.rbi +3 -6
  206. data/rbi/lib/orb/models/customer_sync_payment_methods_from_gateway_by_external_customer_id_params.rbi +2 -4
  207. data/rbi/lib/orb/models/customer_sync_payment_methods_from_gateway_params.rbi +2 -4
  208. data/rbi/lib/orb/models/customer_update_by_external_id_params.rbi +252 -277
  209. data/rbi/lib/orb/models/customer_update_params.rbi +252 -277
  210. data/rbi/lib/orb/models/customers/balance_transaction_create_params.rbi +3 -6
  211. data/rbi/lib/orb/models/customers/balance_transaction_create_response.rbi +10 -19
  212. data/rbi/lib/orb/models/customers/balance_transaction_list_params.rbi +3 -6
  213. data/rbi/lib/orb/models/customers/balance_transaction_list_response.rbi +10 -19
  214. data/rbi/lib/orb/models/customers/cost_list_by_external_id_params.rbi +8 -10
  215. data/rbi/lib/orb/models/customers/cost_list_by_external_id_response.rbi +6 -12
  216. data/rbi/lib/orb/models/customers/cost_list_params.rbi +8 -10
  217. data/rbi/lib/orb/models/customers/cost_list_response.rbi +6 -12
  218. data/rbi/lib/orb/models/customers/credit_list_by_external_id_params.rbi +3 -4
  219. data/rbi/lib/orb/models/customers/credit_list_by_external_id_response.rbi +2 -4
  220. data/rbi/lib/orb/models/customers/credit_list_params.rbi +3 -4
  221. data/rbi/lib/orb/models/customers/credit_list_response.rbi +2 -4
  222. data/rbi/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_params.rbi +26 -33
  223. data/rbi/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_response.rbi +79 -136
  224. data/rbi/lib/orb/models/customers/credits/ledger_create_entry_params.rbi +26 -33
  225. data/rbi/lib/orb/models/customers/credits/ledger_create_entry_response.rbi +78 -135
  226. data/rbi/lib/orb/models/customers/credits/ledger_list_by_external_id_params.rbi +5 -10
  227. data/rbi/lib/orb/models/customers/credits/ledger_list_by_external_id_response.rbi +79 -136
  228. data/rbi/lib/orb/models/customers/credits/ledger_list_params.rbi +5 -10
  229. data/rbi/lib/orb/models/customers/credits/ledger_list_response.rbi +74 -131
  230. data/rbi/lib/orb/models/customers/credits/top_up_create_by_external_id_params.rbi +13 -19
  231. data/rbi/lib/orb/models/customers/credits/top_up_create_by_external_id_response.rbi +12 -18
  232. data/rbi/lib/orb/models/customers/credits/top_up_create_params.rbi +13 -19
  233. data/rbi/lib/orb/models/customers/credits/top_up_create_response.rbi +12 -18
  234. data/rbi/lib/orb/models/customers/credits/top_up_delete_by_external_id_params.rbi +2 -4
  235. data/rbi/lib/orb/models/customers/credits/top_up_delete_params.rbi +2 -4
  236. data/rbi/lib/orb/models/customers/credits/top_up_list_by_external_id_params.rbi +3 -5
  237. data/rbi/lib/orb/models/customers/credits/top_up_list_by_external_id_response.rbi +12 -18
  238. data/rbi/lib/orb/models/customers/credits/top_up_list_params.rbi +3 -5
  239. data/rbi/lib/orb/models/customers/credits/top_up_list_response.rbi +12 -18
  240. data/rbi/lib/orb/models/dimensional_price_group.rbi +8 -9
  241. data/rbi/lib/orb/models/dimensional_price_group_create_params.rbi +4 -7
  242. data/rbi/lib/orb/models/dimensional_price_group_list_params.rbi +3 -5
  243. data/rbi/lib/orb/models/dimensional_price_group_retrieve_params.rbi +2 -4
  244. data/rbi/lib/orb/models/dimensional_price_groups/external_dimensional_price_group_id_retrieve_params.rbi +2 -4
  245. data/rbi/lib/orb/models/dimensional_price_groups.rbi +2 -4
  246. data/rbi/lib/orb/models/discount.rbi +1 -2
  247. data/rbi/lib/orb/models/evaluate_price_group.rbi +3 -6
  248. data/rbi/lib/orb/models/event_deprecate_params.rbi +2 -4
  249. data/rbi/lib/orb/models/event_deprecate_response.rbi +2 -4
  250. data/rbi/lib/orb/models/event_ingest_params.rbi +10 -13
  251. data/rbi/lib/orb/models/event_ingest_response.rbi +10 -16
  252. data/rbi/lib/orb/models/event_search_params.rbi +7 -9
  253. data/rbi/lib/orb/models/event_search_response.rbi +11 -14
  254. data/rbi/lib/orb/models/event_update_params.rbi +5 -6
  255. data/rbi/lib/orb/models/event_update_response.rbi +2 -4
  256. data/rbi/lib/orb/models/events/backfill_close_params.rbi +2 -4
  257. data/rbi/lib/orb/models/events/backfill_close_response.rbi +10 -14
  258. data/rbi/lib/orb/models/events/backfill_create_params.rbi +13 -16
  259. data/rbi/lib/orb/models/events/backfill_create_response.rbi +10 -14
  260. data/rbi/lib/orb/models/events/backfill_fetch_params.rbi +2 -4
  261. data/rbi/lib/orb/models/events/backfill_fetch_response.rbi +10 -14
  262. data/rbi/lib/orb/models/events/backfill_list_params.rbi +3 -5
  263. data/rbi/lib/orb/models/events/backfill_list_response.rbi +10 -14
  264. data/rbi/lib/orb/models/events/backfill_revert_params.rbi +2 -4
  265. data/rbi/lib/orb/models/events/backfill_revert_response.rbi +10 -14
  266. data/rbi/lib/orb/models/events/event_volumes.rbi +5 -9
  267. data/rbi/lib/orb/models/events/volume_list_params.rbi +9 -11
  268. data/rbi/lib/orb/models/invoice.rbi +388 -465
  269. data/rbi/lib/orb/models/invoice_create_params.rbi +19 -26
  270. data/rbi/lib/orb/models/invoice_fetch_params.rbi +2 -4
  271. data/rbi/lib/orb/models/invoice_fetch_upcoming_params.rbi +2 -4
  272. data/rbi/lib/orb/models/invoice_fetch_upcoming_response.rbi +381 -460
  273. data/rbi/lib/orb/models/invoice_issue_params.rbi +6 -8
  274. data/rbi/lib/orb/models/invoice_level_discount.rbi +1 -2
  275. data/rbi/lib/orb/models/invoice_line_item_create_params.rbi +3 -5
  276. data/rbi/lib/orb/models/invoice_line_item_create_response.rbi +101 -143
  277. data/rbi/lib/orb/models/invoice_list_params.rbi +8 -13
  278. data/rbi/lib/orb/models/invoice_mark_paid_params.rbi +2 -4
  279. data/rbi/lib/orb/models/invoice_pay_params.rbi +2 -4
  280. data/rbi/lib/orb/models/invoice_update_params.rbi +4 -6
  281. data/rbi/lib/orb/models/invoice_void_params.rbi +2 -4
  282. data/rbi/lib/orb/models/item.rbi +7 -12
  283. data/rbi/lib/orb/models/item_create_params.rbi +2 -4
  284. data/rbi/lib/orb/models/item_fetch_params.rbi +2 -4
  285. data/rbi/lib/orb/models/item_list_params.rbi +3 -5
  286. data/rbi/lib/orb/models/item_update_params.rbi +5 -10
  287. data/rbi/lib/orb/models/metric_create_params.rbi +4 -6
  288. data/rbi/lib/orb/models/metric_fetch_params.rbi +2 -4
  289. data/rbi/lib/orb/models/metric_list_params.rbi +3 -6
  290. data/rbi/lib/orb/models/metric_update_params.rbi +4 -6
  291. data/rbi/lib/orb/models/pagination_metadata.rbi +2 -4
  292. data/rbi/lib/orb/models/percentage_discount.rbi +5 -8
  293. data/rbi/lib/orb/models/plan.rbi +180 -219
  294. data/rbi/lib/orb/models/plan_create_params.rbi +670 -951
  295. data/rbi/lib/orb/models/plan_fetch_params.rbi +2 -4
  296. data/rbi/lib/orb/models/plan_list_params.rbi +4 -8
  297. data/rbi/lib/orb/models/plan_update_params.rbi +6 -8
  298. data/rbi/lib/orb/models/plans/external_plan_id_fetch_params.rbi +2 -4
  299. data/rbi/lib/orb/models/plans/external_plan_id_update_params.rbi +6 -8
  300. data/rbi/lib/orb/models/price.rbi +827 -1494
  301. data/rbi/lib/orb/models/price_create_params.rbi +60 -101
  302. data/rbi/lib/orb/models/price_evaluate_params.rbi +6 -9
  303. data/rbi/lib/orb/models/price_evaluate_response.rbi +2 -4
  304. data/rbi/lib/orb/models/price_fetch_params.rbi +2 -4
  305. data/rbi/lib/orb/models/price_list_params.rbi +3 -5
  306. data/rbi/lib/orb/models/price_update_params.rbi +4 -6
  307. data/rbi/lib/orb/models/prices/external_price_id_fetch_params.rbi +2 -4
  308. data/rbi/lib/orb/models/prices/external_price_id_update_params.rbi +4 -6
  309. data/rbi/lib/orb/models/subscription.rbi +167 -187
  310. data/rbi/lib/orb/models/subscription_cancel_params.rbi +5 -7
  311. data/rbi/lib/orb/models/subscription_cancel_response.rbi +224 -178
  312. data/rbi/lib/orb/models/subscription_change_apply_params.rbi +40 -0
  313. data/rbi/lib/orb/models/subscription_change_apply_response.rbi +1554 -0
  314. data/rbi/lib/orb/models/subscription_change_cancel_params.rbi +18 -0
  315. data/rbi/lib/orb/models/subscription_change_cancel_response.rbi +1565 -0
  316. data/rbi/lib/orb/models/subscription_change_retrieve_params.rbi +18 -0
  317. data/rbi/lib/orb/models/subscription_change_retrieve_response.rbi +1581 -0
  318. data/rbi/lib/orb/models/subscription_create_params.rbi +1372 -1968
  319. data/rbi/lib/orb/models/subscription_create_response.rbi +224 -178
  320. data/rbi/lib/orb/models/subscription_fetch_costs_params.rbi +8 -10
  321. data/rbi/lib/orb/models/subscription_fetch_costs_response.rbi +6 -12
  322. data/rbi/lib/orb/models/subscription_fetch_params.rbi +2 -4
  323. data/rbi/lib/orb/models/subscription_fetch_schedule_params.rbi +3 -6
  324. data/rbi/lib/orb/models/subscription_fetch_schedule_response.rbi +6 -10
  325. data/rbi/lib/orb/models/subscription_fetch_usage_params.rbi +12 -17
  326. data/rbi/lib/orb/models/subscription_list_params.rbi +4 -8
  327. data/rbi/lib/orb/models/subscription_price_intervals_params.rbi +772 -1124
  328. data/rbi/lib/orb/models/subscription_price_intervals_response.rbi +228 -178
  329. data/rbi/lib/orb/models/subscription_schedule_plan_change_params.rbi +1396 -1993
  330. data/rbi/lib/orb/models/subscription_schedule_plan_change_response.rbi +238 -182
  331. data/rbi/lib/orb/models/subscription_trigger_phase_params.rbi +5 -7
  332. data/rbi/lib/orb/models/subscription_trigger_phase_response.rbi +224 -178
  333. data/rbi/lib/orb/models/subscription_unschedule_cancellation_params.rbi +2 -4
  334. data/rbi/lib/orb/models/subscription_unschedule_cancellation_response.rbi +238 -182
  335. data/rbi/lib/orb/models/subscription_unschedule_fixed_fee_quantity_updates_params.rbi +2 -4
  336. data/rbi/lib/orb/models/subscription_unschedule_fixed_fee_quantity_updates_response.rbi +265 -199
  337. data/rbi/lib/orb/models/subscription_unschedule_pending_plan_changes_params.rbi +2 -4
  338. data/rbi/lib/orb/models/subscription_unschedule_pending_plan_changes_response.rbi +264 -198
  339. data/rbi/lib/orb/models/subscription_update_fixed_fee_quantity_params.rbi +11 -15
  340. data/rbi/lib/orb/models/subscription_update_fixed_fee_quantity_response.rbi +238 -182
  341. data/rbi/lib/orb/models/subscription_update_params.rbi +12 -15
  342. data/rbi/lib/orb/models/subscription_update_trial_params.rbi +6 -9
  343. data/rbi/lib/orb/models/subscription_update_trial_response.rbi +224 -178
  344. data/rbi/lib/orb/models/subscription_usage.rbi +24 -43
  345. data/rbi/lib/orb/models/subscriptions.rbi +2 -4
  346. data/rbi/lib/orb/models/top_level_ping_params.rbi +2 -4
  347. data/rbi/lib/orb/models/top_level_ping_response.rbi +2 -4
  348. data/rbi/lib/orb/models/trial_discount.rbi +4 -8
  349. data/rbi/lib/orb/models/usage_discount.rbi +5 -8
  350. data/rbi/lib/orb/request_options.rbi +9 -11
  351. data/rbi/lib/orb/resources/alerts.rbi +44 -60
  352. data/rbi/lib/orb/resources/coupons/subscriptions.rbi +6 -9
  353. data/rbi/lib/orb/resources/coupons.rbi +18 -25
  354. data/rbi/lib/orb/resources/credit_notes.rbi +9 -15
  355. data/rbi/lib/orb/resources/customers/balance_transactions.rbi +26 -31
  356. data/rbi/lib/orb/resources/customers/costs.rbi +241 -246
  357. data/rbi/lib/orb/resources/customers/credits/ledger.rbi +387 -396
  358. data/rbi/lib/orb/resources/customers/credits/top_ups.rbi +29 -40
  359. data/rbi/lib/orb/resources/customers/credits.rbi +15 -20
  360. data/rbi/lib/orb/resources/customers.rbi +407 -417
  361. data/rbi/lib/orb/resources/dimensional_price_groups/external_dimensional_price_group_id.rbi +2 -4
  362. data/rbi/lib/orb/resources/dimensional_price_groups.rbi +13 -19
  363. data/rbi/lib/orb/resources/events/backfills.rbi +61 -69
  364. data/rbi/lib/orb/resources/events/volume.rbi +19 -22
  365. data/rbi/lib/orb/resources/events.rbi +311 -319
  366. data/rbi/lib/orb/resources/invoice_line_items.rbi +4 -7
  367. data/rbi/lib/orb/resources/invoices.rbi +62 -76
  368. data/rbi/lib/orb/resources/items.rbi +7 -14
  369. data/rbi/lib/orb/resources/metrics.rbi +17 -25
  370. data/rbi/lib/orb/resources/plans/external_plan_id.rbi +21 -25
  371. data/rbi/lib/orb/resources/plans.rbi +63 -71
  372. data/rbi/lib/orb/resources/prices/external_price_id.rbi +9 -13
  373. data/rbi/lib/orb/resources/prices.rbi +77 -87
  374. data/rbi/lib/orb/resources/subscription_changes.rbi +61 -0
  375. data/rbi/lib/orb/resources/subscriptions.rbi +933 -963
  376. data/rbi/lib/orb/resources/top_level.rbi +6 -8
  377. data/rbi/lib/orb/version.rbi +1 -1
  378. data/sig/orb/client.rbs +2 -0
  379. data/sig/orb/internal/type/array_of.rbs +2 -2
  380. data/sig/orb/internal/type/{boolean_model.rbs → boolean.rbs} +1 -1
  381. data/sig/orb/internal/util.rbs +5 -5
  382. data/sig/orb/models/subscription.rbs +14 -0
  383. data/sig/orb/models/subscription_cancel_response.rbs +47 -2
  384. data/sig/orb/models/subscription_change_apply_params.rbs +24 -0
  385. data/sig/orb/models/subscription_change_apply_response.rbs +784 -0
  386. data/sig/orb/models/subscription_change_cancel_params.rbs +15 -0
  387. data/sig/orb/models/subscription_change_cancel_response.rbs +784 -0
  388. data/sig/orb/models/subscription_change_retrieve_params.rbs +15 -0
  389. data/sig/orb/models/subscription_change_retrieve_response.rbs +784 -0
  390. data/sig/orb/models/subscription_create_response.rbs +47 -2
  391. data/sig/orb/models/subscription_price_intervals_response.rbs +47 -2
  392. data/sig/orb/models/subscription_schedule_plan_change_response.rbs +47 -2
  393. data/sig/orb/models/subscription_trigger_phase_response.rbs +47 -2
  394. data/sig/orb/models/subscription_unschedule_cancellation_response.rbs +47 -2
  395. data/sig/orb/models/subscription_unschedule_fixed_fee_quantity_updates_response.rbs +47 -2
  396. data/sig/orb/models/subscription_unschedule_pending_plan_changes_response.rbs +47 -2
  397. data/sig/orb/models/subscription_update_fixed_fee_quantity_response.rbs +47 -2
  398. data/sig/orb/models/subscription_update_trial_response.rbs +47 -2
  399. data/sig/orb/resources/customers.rbs +2 -2
  400. data/sig/orb/resources/subscription_changes.rbs +24 -0
  401. data/sig/orb/version.rbs +1 -1
  402. metadata +26 -5
@@ -6,86 +6,86 @@ module Orb
6
6
  class Credits
7
7
  class Ledger
8
8
  # The credits ledger provides _auditing_ functionality over Orb's credits system
9
- # with a list of actions that have taken place to modify a customer's credit
10
- # balance. This [paginated endpoint](/api-reference/pagination) lists these
11
- # entries, starting from the most recent ledger entry.
9
+ # with a list of actions that have taken place to modify a customer's credit
10
+ # balance. This [paginated endpoint](/api-reference/pagination) lists these
11
+ # entries, starting from the most recent ledger entry.
12
12
  #
13
- # More details on using Orb's real-time credit feature are
14
- # [here](/product-catalog/prepurchase).
13
+ # More details on using Orb's real-time credit feature are
14
+ # [here](/product-catalog/prepurchase).
15
15
  #
16
- # There are four major types of modifications to credit balance, detailed below.
16
+ # There are four major types of modifications to credit balance, detailed below.
17
17
  #
18
- # ## Increment
18
+ # ## Increment
19
19
  #
20
- # Credits (which optionally expire on a future date) can be added via the API
21
- # ([Add Ledger Entry](create-ledger-entry)). The ledger entry for such an action
22
- # will always contain the total eligible starting and ending balance for the
23
- # customer at the time the entry was added to the ledger.
20
+ # Credits (which optionally expire on a future date) can be added via the API
21
+ # ([Add Ledger Entry](create-ledger-entry)). The ledger entry for such an action
22
+ # will always contain the total eligible starting and ending balance for the
23
+ # customer at the time the entry was added to the ledger.
24
24
  #
25
- # ## Decrement
25
+ # ## Decrement
26
26
  #
27
- # Deductions can occur as a result of an API call to create a ledger entry (see
28
- # [Add Ledger Entry](create-ledger-entry)), or automatically as a result of
29
- # incurring usage. Both ledger entries present the `decrement` entry type.
27
+ # Deductions can occur as a result of an API call to create a ledger entry (see
28
+ # [Add Ledger Entry](create-ledger-entry)), or automatically as a result of
29
+ # incurring usage. Both ledger entries present the `decrement` entry type.
30
30
  #
31
- # As usage for a customer is reported into Orb, credits may be deducted according
32
- # to the customer's plan configuration. An automated deduction of this type will
33
- # result in a ledger entry, also with a starting and ending balance. In order to
34
- # provide better tracing capabilities for automatic deductions, Orb always
35
- # associates each automatic deduction with the `event_id` at the time of
36
- # ingestion, used to pinpoint _why_ credit deduction took place and to ensure that
37
- # credits are never deducted without an associated usage event.
31
+ # As usage for a customer is reported into Orb, credits may be deducted according
32
+ # to the customer's plan configuration. An automated deduction of this type will
33
+ # result in a ledger entry, also with a starting and ending balance. In order to
34
+ # provide better tracing capabilities for automatic deductions, Orb always
35
+ # associates each automatic deduction with the `event_id` at the time of
36
+ # ingestion, used to pinpoint _why_ credit deduction took place and to ensure that
37
+ # credits are never deducted without an associated usage event.
38
38
  #
39
- # By default, Orb uses an algorithm that automatically deducts from the _soonest
40
- # expiring credit block_ first in order to ensure that all credits are utilized
41
- # appropriately. As an example, if trial credits with an expiration date of 2
42
- # weeks from now are present for a customer, they will be used before any
43
- # deductions take place from a non-expiring credit block.
39
+ # By default, Orb uses an algorithm that automatically deducts from the _soonest
40
+ # expiring credit block_ first in order to ensure that all credits are utilized
41
+ # appropriately. As an example, if trial credits with an expiration date of 2
42
+ # weeks from now are present for a customer, they will be used before any
43
+ # deductions take place from a non-expiring credit block.
44
44
  #
45
- # If there are multiple blocks with the same expiration date, Orb will deduct from
46
- # the block with the _lower cost basis_ first (e.g. trial credits with a $0 cost
47
- # basis before paid credits with a $5.00 cost basis).
45
+ # If there are multiple blocks with the same expiration date, Orb will deduct from
46
+ # the block with the _lower cost basis_ first (e.g. trial credits with a $0 cost
47
+ # basis before paid credits with a $5.00 cost basis).
48
48
  #
49
- # It's also possible for a single usage event's deduction to _span_ credit blocks.
50
- # In this case, Orb will deduct from the next block, ending at the credit block
51
- # which consists of unexpiring credits. Each of these deductions will lead to a
52
- # _separate_ ledger entry, one per credit block that is deducted from. By default,
53
- # the customer's total credit balance in Orb can be negative as a result of a
54
- # decrement.
49
+ # It's also possible for a single usage event's deduction to _span_ credit blocks.
50
+ # In this case, Orb will deduct from the next block, ending at the credit block
51
+ # which consists of unexpiring credits. Each of these deductions will lead to a
52
+ # _separate_ ledger entry, one per credit block that is deducted from. By default,
53
+ # the customer's total credit balance in Orb can be negative as a result of a
54
+ # decrement.
55
55
  #
56
- # ## Expiration change
56
+ # ## Expiration change
57
57
  #
58
- # The expiry of credits can be changed as a result of the API (See
59
- # [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that
60
- # specifies the balance as well as the initial and target expiry dates.
58
+ # The expiry of credits can be changed as a result of the API (See
59
+ # [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that
60
+ # specifies the balance as well as the initial and target expiry dates.
61
61
  #
62
- # Note that for this entry type, `starting_balance` will equal `ending_balance`,
63
- # and the `amount` represents the balance transferred. The credit block linked to
64
- # the ledger entry is the source credit block from which there was an expiration
65
- # change
62
+ # Note that for this entry type, `starting_balance` will equal `ending_balance`,
63
+ # and the `amount` represents the balance transferred. The credit block linked to
64
+ # the ledger entry is the source credit block from which there was an expiration
65
+ # change
66
66
  #
67
- # ## Credits expiry
67
+ # ## Credits expiry
68
68
  #
69
- # When a set of credits expire on pre-set expiration date, the customer's balance
70
- # automatically reflects this change and adds an entry to the ledger indicating
71
- # this event. Note that credit expiry should always happen close to a date
72
- # boundary in the customer's timezone.
69
+ # When a set of credits expire on pre-set expiration date, the customer's balance
70
+ # automatically reflects this change and adds an entry to the ledger indicating
71
+ # this event. Note that credit expiry should always happen close to a date
72
+ # boundary in the customer's timezone.
73
73
  #
74
- # ## Void initiated
74
+ # ## Void initiated
75
75
  #
76
- # Credit blocks can be voided via the API. The `amount` on this entry corresponds
77
- # to the number of credits that were remaining in the block at time of void.
78
- # `void_reason` will be populated if the void is created with a reason.
76
+ # Credit blocks can be voided via the API. The `amount` on this entry corresponds
77
+ # to the number of credits that were remaining in the block at time of void.
78
+ # `void_reason` will be populated if the void is created with a reason.
79
79
  #
80
- # ## Void
80
+ # ## Void
81
81
  #
82
- # When a set of credits is voided, the customer's balance automatically reflects
83
- # this change and adds an entry to the ledger indicating this event.
82
+ # When a set of credits is voided, the customer's balance automatically reflects
83
+ # this change and adds an entry to the ledger indicating this event.
84
84
  #
85
- # ## Amendment
85
+ # ## Amendment
86
86
  #
87
- # When credits are added to a customer's balance as a result of a correction, this
88
- # entry will be added to the ledger to indicate the adjustment of credits.
87
+ # When credits are added to a customer's balance as a result of a correction, this
88
+ # entry will be added to the ledger to indicate the adjustment of credits.
89
89
  #
90
90
  # @overload list(customer_id, created_at_gt: nil, created_at_gte: nil, created_at_lt: nil, created_at_lte: nil, currency: nil, cursor: nil, entry_status: nil, entry_type: nil, limit: nil, minimum_amount: nil, request_options: {})
91
91
  #
@@ -110,7 +110,12 @@ module Orb
110
110
  @client.request(
111
111
  method: :get,
112
112
  path: ["customers/%1$s/credits/ledger", customer_id],
113
- query: parsed,
113
+ query: parsed.transform_keys(
114
+ created_at_gt: "created_at[gt]",
115
+ created_at_gte: "created_at[gte]",
116
+ created_at_lt: "created_at[lt]",
117
+ created_at_lte: "created_at[lte]"
118
+ ),
114
119
  page: Orb::Internal::Page,
115
120
  model: Orb::Models::Customers::Credits::LedgerListResponse,
116
121
  options: options
@@ -118,115 +123,115 @@ module Orb
118
123
  end
119
124
 
120
125
  # This endpoint allows you to create a new ledger entry for a specified customer's
121
- # balance. This can be used to increment balance, deduct credits, and change the
122
- # expiry date of existing credits.
123
- #
124
- # ## Effects of adding a ledger entry
125
- #
126
- # 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits)
127
- # will return a credit block that represents the changes (i.e. balance changes
128
- # or transfers).
129
- # 2. A ledger entry will be added to the credits ledger for this customer, and
130
- # therefore returned in the
131
- # [View Credits Ledger](fetch-customer-credits-ledger) response as well as
132
- # serialized in the response to this request. In the case of deductions without
133
- # a specified block, multiple ledger entries may be created if the deduction
134
- # spans credit blocks.
135
- # 3. If `invoice_settings` is specified, an invoice will be created that reflects
136
- # the cost of the credits (based on `amount` and `per_unit_cost_basis`).
137
- #
138
- # ## Adding credits
139
- #
140
- # Adding credits is done by creating an entry of type `increment`. This requires
141
- # the caller to specify a number of credits as well as an optional expiry date in
142
- # `YYYY-MM-DD` format. Orb also recommends specifying a description to assist with
143
- # auditing. When adding credits, the caller can also specify a cost basis
144
- # per-credit, to indicate how much in USD a customer paid for a single credit in a
145
- # block. This can later be used for revenue recognition.
146
- #
147
- # The following snippet illustrates a sample request body to increment credits
148
- # which will expire in January of 2022.
149
- #
150
- # ```json
151
- # {
152
- # "entry_type": "increment",
153
- # "amount": 100,
154
- # "expiry_date": "2022-12-28",
155
- # "per_unit_cost_basis": "0.20",
156
- # "description": "Purchased 100 credits"
157
- # }
158
- # ```
159
- #
160
- # Note that by default, Orb will always first increment any _negative_ balance in
161
- # existing blocks before adding the remaining amount to the desired credit block.
162
- #
163
- # ### Invoicing for credits
164
- #
165
- # By default, Orb manipulates the credit ledger but does not charge for credits.
166
- # However, if you pass `invoice_settings` in the body of this request, Orb will
167
- # also generate a one-off invoice for the customer for the credits pre-purchase.
168
- # Note that you _must_ provide the `per_unit_cost_basis`, since the total charges
169
- # on the invoice are calculated by multiplying the cost basis with the number of
170
- # credit units added.
171
- #
172
- # ## Deducting Credits
173
- #
174
- # Orb allows you to deduct credits from a customer by creating an entry of type
175
- # `decrement`. Orb matches the algorithm for automatic deductions for determining
176
- # which credit blocks to decrement from. In the case that the deduction leads to
177
- # multiple ledger entries, the response from this endpoint will be the final
178
- # deduction. Orb also optionally allows specifying a description to assist with
179
- # auditing.
180
- #
181
- # The following snippet illustrates a sample request body to decrement credits.
182
- #
183
- # ```json
184
- # {
185
- # "entry_type": "decrement",
186
- # "amount": 20,
187
- # "description": "Removing excess credits"
188
- # }
189
- # ```
190
- #
191
- # ## Changing credits expiry
192
- #
193
- # If you'd like to change when existing credits expire, you should create a ledger
194
- # entry of type `expiration_change`. For this entry, the required parameter
195
- # `expiry_date` identifies the _originating_ block, and the required parameter
196
- # `target_expiry_date` identifies when the transferred credits should now expire.
197
- # A new credit block will be created with expiry date `target_expiry_date`, with
198
- # the same cost basis data as the original credit block, if present.
199
- #
200
- # Note that the balance of the block with the given `expiry_date` must be at least
201
- # equal to the desired transfer amount determined by the `amount` parameter.
202
- #
203
- # The following snippet illustrates a sample request body to extend the expiration
204
- # date of credits by one year:
205
- #
206
- # ```json
207
- # {
208
- # "entry_type": "expiration_change",
209
- # "amount": 10,
210
- # "expiry_date": "2022-12-28",
211
- # "block_id": "UiUhFWeLHPrBY4Ad",
212
- # "target_expiry_date": "2023-12-28",
213
- # "description": "Extending credit validity"
214
- # }
215
- # ```
216
- #
217
- # ## Voiding credits
218
- #
219
- # If you'd like to void a credit block, create a ledger entry of type `void`. For
220
- # this entry, `block_id` is required to identify the block, and `amount` indicates
221
- # how many credits to void, up to the block's initial balance. Pass in a
222
- # `void_reason` of `refund` if the void is due to a refund.
223
- #
224
- # ## Amendment
225
- #
226
- # If you'd like to undo a decrement on a credit block, create a ledger entry of
227
- # type `amendment`. For this entry, `block_id` is required to identify the block
228
- # that was originally decremented from, and `amount` indicates how many credits to
229
- # return to the customer, up to the block's initial balance.
126
+ # balance. This can be used to increment balance, deduct credits, and change the
127
+ # expiry date of existing credits.
128
+ #
129
+ # ## Effects of adding a ledger entry
130
+ #
131
+ # 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits)
132
+ # will return a credit block that represents the changes (i.e. balance changes
133
+ # or transfers).
134
+ # 2. A ledger entry will be added to the credits ledger for this customer, and
135
+ # therefore returned in the
136
+ # [View Credits Ledger](fetch-customer-credits-ledger) response as well as
137
+ # serialized in the response to this request. In the case of deductions without
138
+ # a specified block, multiple ledger entries may be created if the deduction
139
+ # spans credit blocks.
140
+ # 3. If `invoice_settings` is specified, an invoice will be created that reflects
141
+ # the cost of the credits (based on `amount` and `per_unit_cost_basis`).
142
+ #
143
+ # ## Adding credits
144
+ #
145
+ # Adding credits is done by creating an entry of type `increment`. This requires
146
+ # the caller to specify a number of credits as well as an optional expiry date in
147
+ # `YYYY-MM-DD` format. Orb also recommends specifying a description to assist with
148
+ # auditing. When adding credits, the caller can also specify a cost basis
149
+ # per-credit, to indicate how much in USD a customer paid for a single credit in a
150
+ # block. This can later be used for revenue recognition.
151
+ #
152
+ # The following snippet illustrates a sample request body to increment credits
153
+ # which will expire in January of 2022.
154
+ #
155
+ # ```json
156
+ # {
157
+ # "entry_type": "increment",
158
+ # "amount": 100,
159
+ # "expiry_date": "2022-12-28",
160
+ # "per_unit_cost_basis": "0.20",
161
+ # "description": "Purchased 100 credits"
162
+ # }
163
+ # ```
164
+ #
165
+ # Note that by default, Orb will always first increment any _negative_ balance in
166
+ # existing blocks before adding the remaining amount to the desired credit block.
167
+ #
168
+ # ### Invoicing for credits
169
+ #
170
+ # By default, Orb manipulates the credit ledger but does not charge for credits.
171
+ # However, if you pass `invoice_settings` in the body of this request, Orb will
172
+ # also generate a one-off invoice for the customer for the credits pre-purchase.
173
+ # Note that you _must_ provide the `per_unit_cost_basis`, since the total charges
174
+ # on the invoice are calculated by multiplying the cost basis with the number of
175
+ # credit units added.
176
+ #
177
+ # ## Deducting Credits
178
+ #
179
+ # Orb allows you to deduct credits from a customer by creating an entry of type
180
+ # `decrement`. Orb matches the algorithm for automatic deductions for determining
181
+ # which credit blocks to decrement from. In the case that the deduction leads to
182
+ # multiple ledger entries, the response from this endpoint will be the final
183
+ # deduction. Orb also optionally allows specifying a description to assist with
184
+ # auditing.
185
+ #
186
+ # The following snippet illustrates a sample request body to decrement credits.
187
+ #
188
+ # ```json
189
+ # {
190
+ # "entry_type": "decrement",
191
+ # "amount": 20,
192
+ # "description": "Removing excess credits"
193
+ # }
194
+ # ```
195
+ #
196
+ # ## Changing credits expiry
197
+ #
198
+ # If you'd like to change when existing credits expire, you should create a ledger
199
+ # entry of type `expiration_change`. For this entry, the required parameter
200
+ # `expiry_date` identifies the _originating_ block, and the required parameter
201
+ # `target_expiry_date` identifies when the transferred credits should now expire.
202
+ # A new credit block will be created with expiry date `target_expiry_date`, with
203
+ # the same cost basis data as the original credit block, if present.
204
+ #
205
+ # Note that the balance of the block with the given `expiry_date` must be at least
206
+ # equal to the desired transfer amount determined by the `amount` parameter.
207
+ #
208
+ # The following snippet illustrates a sample request body to extend the expiration
209
+ # 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
+ # ## Voiding credits
223
+ #
224
+ # If you'd like to void a credit block, create a ledger entry of type `void`. For
225
+ # this entry, `block_id` is required to identify the block, and `amount` indicates
226
+ # how many credits to void, up to the block's initial balance. Pass in a
227
+ # `void_reason` of `refund` if the void is due to a refund.
228
+ #
229
+ # ## Amendment
230
+ #
231
+ # If you'd like to undo a decrement on a credit block, create a ledger entry of
232
+ # type `amendment`. For this entry, `block_id` is required to identify the block
233
+ # that was originally decremented from, and `amount` indicates how many credits to
234
+ # return to the customer, up to the block's initial balance.
230
235
  #
231
236
  # @overload create_entry(customer_id, amount:, entry_type:, expiry_date:, target_expiry_date:, block_id:, currency: nil, description: nil, effective_date: nil, invoice_settings: nil, metadata: nil, per_unit_cost_basis: nil, void_reason: nil, request_options: {})
232
237
  #
@@ -260,115 +265,115 @@ module Orb
260
265
  end
261
266
 
262
267
  # This endpoint allows you to create a new ledger entry for a specified customer's
263
- # balance. This can be used to increment balance, deduct credits, and change the
264
- # expiry date of existing credits.
265
- #
266
- # ## Effects of adding a ledger entry
267
- #
268
- # 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits)
269
- # will return a credit block that represents the changes (i.e. balance changes
270
- # or transfers).
271
- # 2. A ledger entry will be added to the credits ledger for this customer, and
272
- # therefore returned in the
273
- # [View Credits Ledger](fetch-customer-credits-ledger) response as well as
274
- # serialized in the response to this request. In the case of deductions without
275
- # a specified block, multiple ledger entries may be created if the deduction
276
- # spans credit blocks.
277
- # 3. If `invoice_settings` is specified, an invoice will be created that reflects
278
- # the cost of the credits (based on `amount` and `per_unit_cost_basis`).
279
- #
280
- # ## Adding credits
281
- #
282
- # Adding credits is done by creating an entry of type `increment`. This requires
283
- # the caller to specify a number of credits as well as an optional expiry date in
284
- # `YYYY-MM-DD` format. Orb also recommends specifying a description to assist with
285
- # auditing. When adding credits, the caller can also specify a cost basis
286
- # per-credit, to indicate how much in USD a customer paid for a single credit in a
287
- # block. This can later be used for revenue recognition.
288
- #
289
- # The following snippet illustrates a sample request body to increment credits
290
- # which will expire in January of 2022.
291
- #
292
- # ```json
293
- # {
294
- # "entry_type": "increment",
295
- # "amount": 100,
296
- # "expiry_date": "2022-12-28",
297
- # "per_unit_cost_basis": "0.20",
298
- # "description": "Purchased 100 credits"
299
- # }
300
- # ```
301
- #
302
- # Note that by default, Orb will always first increment any _negative_ balance in
303
- # existing blocks before adding the remaining amount to the desired credit block.
304
- #
305
- # ### Invoicing for credits
306
- #
307
- # By default, Orb manipulates the credit ledger but does not charge for credits.
308
- # However, if you pass `invoice_settings` in the body of this request, Orb will
309
- # also generate a one-off invoice for the customer for the credits pre-purchase.
310
- # Note that you _must_ provide the `per_unit_cost_basis`, since the total charges
311
- # on the invoice are calculated by multiplying the cost basis with the number of
312
- # credit units added.
313
- #
314
- # ## Deducting Credits
315
- #
316
- # Orb allows you to deduct credits from a customer by creating an entry of type
317
- # `decrement`. Orb matches the algorithm for automatic deductions for determining
318
- # which credit blocks to decrement from. In the case that the deduction leads to
319
- # multiple ledger entries, the response from this endpoint will be the final
320
- # deduction. Orb also optionally allows specifying a description to assist with
321
- # auditing.
322
- #
323
- # The following snippet illustrates a sample request body to decrement credits.
324
- #
325
- # ```json
326
- # {
327
- # "entry_type": "decrement",
328
- # "amount": 20,
329
- # "description": "Removing excess credits"
330
- # }
331
- # ```
332
- #
333
- # ## Changing credits expiry
334
- #
335
- # If you'd like to change when existing credits expire, you should create a ledger
336
- # entry of type `expiration_change`. For this entry, the required parameter
337
- # `expiry_date` identifies the _originating_ block, and the required parameter
338
- # `target_expiry_date` identifies when the transferred credits should now expire.
339
- # A new credit block will be created with expiry date `target_expiry_date`, with
340
- # the same cost basis data as the original credit block, if present.
341
- #
342
- # Note that the balance of the block with the given `expiry_date` must be at least
343
- # equal to the desired transfer amount determined by the `amount` parameter.
344
- #
345
- # The following snippet illustrates a sample request body to extend the expiration
346
- # date of credits by one year:
347
- #
348
- # ```json
349
- # {
350
- # "entry_type": "expiration_change",
351
- # "amount": 10,
352
- # "expiry_date": "2022-12-28",
353
- # "block_id": "UiUhFWeLHPrBY4Ad",
354
- # "target_expiry_date": "2023-12-28",
355
- # "description": "Extending credit validity"
356
- # }
357
- # ```
358
- #
359
- # ## Voiding credits
360
- #
361
- # If you'd like to void a credit block, create a ledger entry of type `void`. For
362
- # this entry, `block_id` is required to identify the block, and `amount` indicates
363
- # how many credits to void, up to the block's initial balance. Pass in a
364
- # `void_reason` of `refund` if the void is due to a refund.
365
- #
366
- # ## Amendment
367
- #
368
- # If you'd like to undo a decrement on a credit block, create a ledger entry of
369
- # type `amendment`. For this entry, `block_id` is required to identify the block
370
- # that was originally decremented from, and `amount` indicates how many credits to
371
- # return to the customer, up to the block's initial balance.
268
+ # balance. This can be used to increment balance, deduct credits, and change the
269
+ # expiry date of existing credits.
270
+ #
271
+ # ## Effects of adding a ledger entry
272
+ #
273
+ # 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits)
274
+ # will return a credit block that represents the changes (i.e. balance changes
275
+ # or transfers).
276
+ # 2. A ledger entry will be added to the credits ledger for this customer, and
277
+ # therefore returned in the
278
+ # [View Credits Ledger](fetch-customer-credits-ledger) response as well as
279
+ # serialized in the response to this request. In the case of deductions without
280
+ # a specified block, multiple ledger entries may be created if the deduction
281
+ # spans credit blocks.
282
+ # 3. If `invoice_settings` is specified, an invoice will be created that reflects
283
+ # the cost of the credits (based on `amount` and `per_unit_cost_basis`).
284
+ #
285
+ # ## Adding credits
286
+ #
287
+ # Adding credits is done by creating an entry of type `increment`. This requires
288
+ # the caller to specify a number of credits as well as an optional expiry date in
289
+ # `YYYY-MM-DD` format. Orb also recommends specifying a description to assist with
290
+ # auditing. When adding credits, the caller can also specify a cost basis
291
+ # per-credit, to indicate how much in USD a customer paid for a single credit in a
292
+ # block. This can later be used for revenue recognition.
293
+ #
294
+ # The following snippet illustrates a sample request body to increment credits
295
+ # which will expire in January of 2022.
296
+ #
297
+ # ```json
298
+ # {
299
+ # "entry_type": "increment",
300
+ # "amount": 100,
301
+ # "expiry_date": "2022-12-28",
302
+ # "per_unit_cost_basis": "0.20",
303
+ # "description": "Purchased 100 credits"
304
+ # }
305
+ # ```
306
+ #
307
+ # Note that by default, Orb will always first increment any _negative_ balance in
308
+ # existing blocks before adding the remaining amount to the desired credit block.
309
+ #
310
+ # ### Invoicing for credits
311
+ #
312
+ # By default, Orb manipulates the credit ledger but does not charge for credits.
313
+ # However, if you pass `invoice_settings` in the body of this request, Orb will
314
+ # also generate a one-off invoice for the customer for the credits pre-purchase.
315
+ # Note that you _must_ provide the `per_unit_cost_basis`, since the total charges
316
+ # on the invoice are calculated by multiplying the cost basis with the number of
317
+ # credit units added.
318
+ #
319
+ # ## Deducting Credits
320
+ #
321
+ # Orb allows you to deduct credits from a customer by creating an entry of type
322
+ # `decrement`. Orb matches the algorithm for automatic deductions for determining
323
+ # which credit blocks to decrement from. In the case that the deduction leads to
324
+ # multiple ledger entries, the response from this endpoint will be the final
325
+ # deduction. Orb also optionally allows specifying a description to assist with
326
+ # auditing.
327
+ #
328
+ # The following snippet illustrates a sample request body to decrement credits.
329
+ #
330
+ # ```json
331
+ # {
332
+ # "entry_type": "decrement",
333
+ # "amount": 20,
334
+ # "description": "Removing excess credits"
335
+ # }
336
+ # ```
337
+ #
338
+ # ## Changing credits expiry
339
+ #
340
+ # If you'd like to change when existing credits expire, you should create a ledger
341
+ # entry of type `expiration_change`. For this entry, the required parameter
342
+ # `expiry_date` identifies the _originating_ block, and the required parameter
343
+ # `target_expiry_date` identifies when the transferred credits should now expire.
344
+ # A new credit block will be created with expiry date `target_expiry_date`, with
345
+ # the same cost basis data as the original credit block, if present.
346
+ #
347
+ # Note that the balance of the block with the given `expiry_date` must be at least
348
+ # equal to the desired transfer amount determined by the `amount` parameter.
349
+ #
350
+ # The following snippet illustrates a sample request body to extend the expiration
351
+ # date of credits by one year:
352
+ #
353
+ # ```json
354
+ # {
355
+ # "entry_type": "expiration_change",
356
+ # "amount": 10,
357
+ # "expiry_date": "2022-12-28",
358
+ # "block_id": "UiUhFWeLHPrBY4Ad",
359
+ # "target_expiry_date": "2023-12-28",
360
+ # "description": "Extending credit validity"
361
+ # }
362
+ # ```
363
+ #
364
+ # ## Voiding credits
365
+ #
366
+ # If you'd like to void a credit block, create a ledger entry of type `void`. For
367
+ # this entry, `block_id` is required to identify the block, and `amount` indicates
368
+ # how many credits to void, up to the block's initial balance. Pass in a
369
+ # `void_reason` of `refund` if the void is due to a refund.
370
+ #
371
+ # ## Amendment
372
+ #
373
+ # If you'd like to undo a decrement on a credit block, create a ledger entry of
374
+ # type `amendment`. For this entry, `block_id` is required to identify the block
375
+ # that was originally decremented from, and `amount` indicates how many credits to
376
+ # return to the customer, up to the block's initial balance.
372
377
  #
373
378
  # @overload create_entry_by_external_id(external_customer_id, amount:, entry_type:, expiry_date:, target_expiry_date:, block_id:, currency: nil, description: nil, effective_date: nil, invoice_settings: nil, metadata: nil, per_unit_cost_basis: nil, void_reason: nil, request_options: {})
374
379
  #
@@ -403,86 +408,86 @@ module Orb
403
408
  end
404
409
 
405
410
  # The credits ledger provides _auditing_ functionality over Orb's credits system
406
- # with a list of actions that have taken place to modify a customer's credit
407
- # balance. This [paginated endpoint](/api-reference/pagination) lists these
408
- # entries, starting from the most recent ledger entry.
411
+ # with a list of actions that have taken place to modify a customer's credit
412
+ # balance. This [paginated endpoint](/api-reference/pagination) lists these
413
+ # entries, starting from the most recent ledger entry.
409
414
  #
410
- # More details on using Orb's real-time credit feature are
411
- # [here](/product-catalog/prepurchase).
415
+ # More details on using Orb's real-time credit feature are
416
+ # [here](/product-catalog/prepurchase).
412
417
  #
413
- # There are four major types of modifications to credit balance, detailed below.
418
+ # There are four major types of modifications to credit balance, detailed below.
414
419
  #
415
- # ## Increment
420
+ # ## Increment
416
421
  #
417
- # Credits (which optionally expire on a future date) can be added via the API
418
- # ([Add Ledger Entry](create-ledger-entry)). The ledger entry for such an action
419
- # will always contain the total eligible starting and ending balance for the
420
- # customer at the time the entry was added to the ledger.
422
+ # Credits (which optionally expire on a future date) can be added via the API
423
+ # ([Add Ledger Entry](create-ledger-entry)). The ledger entry for such an action
424
+ # will always contain the total eligible starting and ending balance for the
425
+ # customer at the time the entry was added to the ledger.
421
426
  #
422
- # ## Decrement
427
+ # ## Decrement
423
428
  #
424
- # Deductions can occur as a result of an API call to create a ledger entry (see
425
- # [Add Ledger Entry](create-ledger-entry)), or automatically as a result of
426
- # incurring usage. Both ledger entries present the `decrement` entry type.
429
+ # Deductions can occur as a result of an API call to create a ledger entry (see
430
+ # [Add Ledger Entry](create-ledger-entry)), or automatically as a result of
431
+ # incurring usage. Both ledger entries present the `decrement` entry type.
427
432
  #
428
- # As usage for a customer is reported into Orb, credits may be deducted according
429
- # to the customer's plan configuration. An automated deduction of this type will
430
- # result in a ledger entry, also with a starting and ending balance. In order to
431
- # provide better tracing capabilities for automatic deductions, Orb always
432
- # associates each automatic deduction with the `event_id` at the time of
433
- # ingestion, used to pinpoint _why_ credit deduction took place and to ensure that
434
- # credits are never deducted without an associated usage event.
433
+ # As usage for a customer is reported into Orb, credits may be deducted according
434
+ # to the customer's plan configuration. An automated deduction of this type will
435
+ # result in a ledger entry, also with a starting and ending balance. In order to
436
+ # provide better tracing capabilities for automatic deductions, Orb always
437
+ # associates each automatic deduction with the `event_id` at the time of
438
+ # ingestion, used to pinpoint _why_ credit deduction took place and to ensure that
439
+ # credits are never deducted without an associated usage event.
435
440
  #
436
- # By default, Orb uses an algorithm that automatically deducts from the _soonest
437
- # expiring credit block_ first in order to ensure that all credits are utilized
438
- # appropriately. As an example, if trial credits with an expiration date of 2
439
- # weeks from now are present for a customer, they will be used before any
440
- # deductions take place from a non-expiring credit block.
441
+ # By default, Orb uses an algorithm that automatically deducts from the _soonest
442
+ # expiring credit block_ first in order to ensure that all credits are utilized
443
+ # appropriately. As an example, if trial credits with an expiration date of 2
444
+ # weeks from now are present for a customer, they will be used before any
445
+ # deductions take place from a non-expiring credit block.
441
446
  #
442
- # If there are multiple blocks with the same expiration date, Orb will deduct from
443
- # the block with the _lower cost basis_ first (e.g. trial credits with a $0 cost
444
- # basis before paid credits with a $5.00 cost basis).
447
+ # If there are multiple blocks with the same expiration date, Orb will deduct from
448
+ # the block with the _lower cost basis_ first (e.g. trial credits with a $0 cost
449
+ # basis before paid credits with a $5.00 cost basis).
445
450
  #
446
- # It's also possible for a single usage event's deduction to _span_ credit blocks.
447
- # In this case, Orb will deduct from the next block, ending at the credit block
448
- # which consists of unexpiring credits. Each of these deductions will lead to a
449
- # _separate_ ledger entry, one per credit block that is deducted from. By default,
450
- # the customer's total credit balance in Orb can be negative as a result of a
451
- # decrement.
451
+ # It's also possible for a single usage event's deduction to _span_ credit blocks.
452
+ # In this case, Orb will deduct from the next block, ending at the credit block
453
+ # which consists of unexpiring credits. Each of these deductions will lead to a
454
+ # _separate_ ledger entry, one per credit block that is deducted from. By default,
455
+ # the customer's total credit balance in Orb can be negative as a result of a
456
+ # decrement.
452
457
  #
453
- # ## Expiration change
458
+ # ## Expiration change
454
459
  #
455
- # The expiry of credits can be changed as a result of the API (See
456
- # [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that
457
- # specifies the balance as well as the initial and target expiry dates.
460
+ # The expiry of credits can be changed as a result of the API (See
461
+ # [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that
462
+ # specifies the balance as well as the initial and target expiry dates.
458
463
  #
459
- # Note that for this entry type, `starting_balance` will equal `ending_balance`,
460
- # and the `amount` represents the balance transferred. The credit block linked to
461
- # the ledger entry is the source credit block from which there was an expiration
462
- # change
464
+ # Note that for this entry type, `starting_balance` will equal `ending_balance`,
465
+ # and the `amount` represents the balance transferred. The credit block linked to
466
+ # the ledger entry is the source credit block from which there was an expiration
467
+ # change
463
468
  #
464
- # ## Credits expiry
469
+ # ## Credits expiry
465
470
  #
466
- # When a set of credits expire on pre-set expiration date, the customer's balance
467
- # automatically reflects this change and adds an entry to the ledger indicating
468
- # this event. Note that credit expiry should always happen close to a date
469
- # boundary in the customer's timezone.
471
+ # When a set of credits expire on pre-set expiration date, the customer's balance
472
+ # automatically reflects this change and adds an entry to the ledger indicating
473
+ # this event. Note that credit expiry should always happen close to a date
474
+ # boundary in the customer's timezone.
470
475
  #
471
- # ## Void initiated
476
+ # ## Void initiated
472
477
  #
473
- # Credit blocks can be voided via the API. The `amount` on this entry corresponds
474
- # to the number of credits that were remaining in the block at time of void.
475
- # `void_reason` will be populated if the void is created with a reason.
478
+ # Credit blocks can be voided via the API. The `amount` on this entry corresponds
479
+ # to the number of credits that were remaining in the block at time of void.
480
+ # `void_reason` will be populated if the void is created with a reason.
476
481
  #
477
- # ## Void
482
+ # ## Void
478
483
  #
479
- # When a set of credits is voided, the customer's balance automatically reflects
480
- # this change and adds an entry to the ledger indicating this event.
484
+ # When a set of credits is voided, the customer's balance automatically reflects
485
+ # this change and adds an entry to the ledger indicating this event.
481
486
  #
482
- # ## Amendment
487
+ # ## Amendment
483
488
  #
484
- # When credits are added to a customer's balance as a result of a correction, this
485
- # entry will be added to the ledger to indicate the adjustment of credits.
489
+ # When credits are added to a customer's balance as a result of a correction, this
490
+ # entry will be added to the ledger to indicate the adjustment of credits.
486
491
  #
487
492
  # @overload list_by_external_id(external_customer_id, created_at_gt: nil, created_at_gte: nil, created_at_lt: nil, created_at_lte: nil, currency: nil, cursor: nil, entry_status: nil, entry_type: nil, limit: nil, minimum_amount: nil, request_options: {})
488
493
  #
@@ -507,7 +512,12 @@ module Orb
507
512
  @client.request(
508
513
  method: :get,
509
514
  path: ["customers/external_customer_id/%1$s/credits/ledger", external_customer_id],
510
- query: parsed,
515
+ query: parsed.transform_keys(
516
+ created_at_gt: "created_at[gt]",
517
+ created_at_gte: "created_at[gte]",
518
+ created_at_lt: "created_at[lt]",
519
+ created_at_lte: "created_at[lte]"
520
+ ),
511
521
  page: Orb::Internal::Page,
512
522
  model: Orb::Models::Customers::Credits::LedgerListByExternalIDResponse,
513
523
  options: options