orb-billing 0.2.0 → 0.3.0

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 (374) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -0
  3. data/README.md +59 -49
  4. data/lib/orb/client.rb +4 -4
  5. data/lib/orb/file_part.rb +55 -0
  6. data/lib/orb/internal/page.rb +4 -8
  7. data/lib/orb/internal/transport/base_client.rb +7 -7
  8. data/lib/orb/internal/transport/pooled_net_requester.rb +2 -2
  9. data/lib/orb/internal/type/array_of.rb +11 -0
  10. data/lib/orb/internal/type/base_model.rb +32 -14
  11. data/lib/orb/internal/type/base_page.rb +9 -1
  12. data/lib/orb/internal/type/boolean.rb +4 -0
  13. data/lib/orb/internal/type/converter.rb +4 -1
  14. data/lib/orb/internal/type/enum.rb +9 -5
  15. data/lib/orb/internal/type/{io_like.rb → file_input.rb} +33 -15
  16. data/lib/orb/internal/type/hash_of.rb +11 -0
  17. data/lib/orb/internal/type/request_parameters.rb +1 -2
  18. data/lib/orb/internal/type/union.rb +10 -1
  19. data/lib/orb/internal/type/unknown.rb +4 -0
  20. data/lib/orb/internal/util.rb +69 -61
  21. data/lib/orb/internal.rb +0 -1
  22. data/lib/orb/models/alert.rb +68 -71
  23. data/lib/orb/models/alert_create_for_customer_params.rb +20 -25
  24. data/lib/orb/models/alert_create_for_external_customer_params.rb +20 -25
  25. data/lib/orb/models/alert_create_for_subscription_params.rb +20 -25
  26. data/lib/orb/models/alert_disable_params.rb +5 -9
  27. data/lib/orb/models/alert_enable_params.rb +5 -9
  28. data/lib/orb/models/alert_list_params.rb +26 -36
  29. data/lib/orb/models/alert_retrieve_params.rb +3 -8
  30. data/lib/orb/models/alert_update_params.rb +14 -18
  31. data/lib/orb/models/amount_discount.rb +14 -14
  32. data/lib/orb/models/billable_metric.rb +23 -20
  33. data/lib/orb/models/billing_cycle_relative_date.rb +2 -5
  34. data/lib/orb/models/coupon.rb +28 -21
  35. data/lib/orb/models/coupon_archive_params.rb +3 -8
  36. data/lib/orb/models/coupon_create_params.rb +24 -29
  37. data/lib/orb/models/coupon_fetch_params.rb +3 -8
  38. data/lib/orb/models/coupon_list_params.rb +17 -17
  39. data/lib/orb/models/coupons/subscription_list_params.rb +12 -15
  40. data/lib/orb/models/credit_note.rb +100 -166
  41. data/lib/orb/models/credit_note_create_params.rb +15 -23
  42. data/lib/orb/models/credit_note_fetch_params.rb +3 -8
  43. data/lib/orb/models/credit_note_list_params.rb +20 -30
  44. data/lib/orb/models/customer.rb +224 -271
  45. data/lib/orb/models/customer_create_params.rb +211 -252
  46. data/lib/orb/models/customer_delete_params.rb +3 -8
  47. data/lib/orb/models/customer_fetch_by_external_id_params.rb +3 -8
  48. data/lib/orb/models/customer_fetch_params.rb +3 -8
  49. data/lib/orb/models/customer_list_params.rb +20 -30
  50. data/lib/orb/models/customer_sync_payment_methods_from_gateway_by_external_customer_id_params.rb +3 -8
  51. data/lib/orb/models/customer_sync_payment_methods_from_gateway_params.rb +3 -8
  52. data/lib/orb/models/customer_update_by_external_id_params.rb +207 -250
  53. data/lib/orb/models/customer_update_params.rb +207 -250
  54. data/lib/orb/models/customers/balance_transaction_create_params.rb +11 -16
  55. data/lib/orb/models/customers/balance_transaction_create_response.rb +33 -51
  56. data/lib/orb/models/customers/balance_transaction_list_params.rb +20 -30
  57. data/lib/orb/models/customers/balance_transaction_list_response.rb +33 -51
  58. data/lib/orb/models/customers/cost_list_by_external_id_params.rb +17 -17
  59. data/lib/orb/models/customers/cost_list_by_external_id_response.rb +22 -26
  60. data/lib/orb/models/customers/cost_list_params.rb +17 -17
  61. data/lib/orb/models/customers/cost_list_response.rb +22 -26
  62. data/lib/orb/models/customers/credit_list_by_external_id_params.rb +18 -22
  63. data/lib/orb/models/customers/credit_list_by_external_id_response.rb +10 -17
  64. data/lib/orb/models/customers/credit_list_params.rb +18 -22
  65. data/lib/orb/models/customers/credit_list_response.rb +10 -17
  66. data/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_params.rb +64 -66
  67. data/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_response.rb +300 -406
  68. data/lib/orb/models/customers/credits/ledger_create_entry_params.rb +63 -66
  69. data/lib/orb/models/customers/credits/ledger_create_entry_response.rb +300 -406
  70. data/lib/orb/models/customers/credits/ledger_list_by_external_id_params.rb +33 -48
  71. data/lib/orb/models/customers/credits/ledger_list_by_external_id_response.rb +300 -406
  72. data/lib/orb/models/customers/credits/ledger_list_params.rb +32 -48
  73. data/lib/orb/models/customers/credits/ledger_list_response.rb +300 -406
  74. data/lib/orb/models/customers/credits/top_up_create_by_external_id_params.rb +47 -50
  75. data/lib/orb/models/customers/credits/top_up_create_by_external_id_response.rb +43 -46
  76. data/lib/orb/models/customers/credits/top_up_create_params.rb +46 -50
  77. data/lib/orb/models/customers/credits/top_up_create_response.rb +42 -46
  78. data/lib/orb/models/customers/credits/top_up_delete_by_external_id_params.rb +4 -9
  79. data/lib/orb/models/customers/credits/top_up_delete_params.rb +4 -9
  80. data/lib/orb/models/customers/credits/top_up_list_by_external_id_params.rb +12 -15
  81. data/lib/orb/models/customers/credits/top_up_list_by_external_id_response.rb +43 -46
  82. data/lib/orb/models/customers/credits/top_up_list_params.rb +12 -15
  83. data/lib/orb/models/customers/credits/top_up_list_response.rb +42 -46
  84. data/lib/orb/models/dimensional_price_group.rb +21 -15
  85. data/lib/orb/models/dimensional_price_group_create_params.rb +17 -23
  86. data/lib/orb/models/dimensional_price_group_list_params.rb +12 -15
  87. data/lib/orb/models/dimensional_price_group_retrieve_params.rb +3 -8
  88. data/lib/orb/models/dimensional_price_groups/external_dimensional_price_group_id_retrieve_params.rb +3 -8
  89. data/lib/orb/models/dimensional_price_groups.rb +3 -7
  90. data/lib/orb/models/discount.rb +2 -3
  91. data/lib/orb/models/evaluate_price_group.rb +8 -11
  92. data/lib/orb/models/event_deprecate_params.rb +3 -8
  93. data/lib/orb/models/event_deprecate_response.rb +2 -6
  94. data/lib/orb/models/event_ingest_params.rb +33 -27
  95. data/lib/orb/models/event_ingest_response.rb +23 -24
  96. data/lib/orb/models/event_search_params.rb +15 -11
  97. data/lib/orb/models/event_search_response.rb +27 -22
  98. data/lib/orb/models/event_update_params.rb +19 -13
  99. data/lib/orb/models/event_update_response.rb +2 -6
  100. data/lib/orb/models/events/backfill_close_params.rb +3 -8
  101. data/lib/orb/models/events/backfill_close_response.rb +34 -39
  102. data/lib/orb/models/events/backfill_create_params.rb +28 -32
  103. data/lib/orb/models/events/backfill_create_response.rb +34 -39
  104. data/lib/orb/models/events/backfill_fetch_params.rb +3 -8
  105. data/lib/orb/models/events/backfill_fetch_response.rb +34 -39
  106. data/lib/orb/models/events/backfill_list_params.rb +12 -15
  107. data/lib/orb/models/events/backfill_list_response.rb +34 -39
  108. data/lib/orb/models/events/backfill_revert_params.rb +3 -8
  109. data/lib/orb/models/events/backfill_revert_response.rb +34 -39
  110. data/lib/orb/models/events/event_volumes.rb +11 -17
  111. data/lib/orb/models/events/volume_list_params.rb +19 -22
  112. data/lib/orb/models/invoice.rb +589 -637
  113. data/lib/orb/models/invoice_create_params.rb +52 -61
  114. data/lib/orb/models/invoice_fetch_params.rb +3 -8
  115. data/lib/orb/models/invoice_fetch_upcoming_params.rb +4 -9
  116. data/lib/orb/models/invoice_fetch_upcoming_response.rb +584 -631
  117. data/lib/orb/models/invoice_issue_params.rb +10 -14
  118. data/lib/orb/models/invoice_level_discount.rb +2 -3
  119. data/lib/orb/models/invoice_line_item_create_params.rb +19 -14
  120. data/lib/orb/models/invoice_line_item_create_response.rb +247 -269
  121. data/lib/orb/models/invoice_list_params.rb +51 -66
  122. data/lib/orb/models/invoice_mark_paid_params.rb +9 -11
  123. data/lib/orb/models/invoice_pay_params.rb +3 -8
  124. data/lib/orb/models/invoice_update_params.rb +9 -9
  125. data/lib/orb/models/invoice_void_params.rb +3 -8
  126. data/lib/orb/models/item.rb +14 -25
  127. data/lib/orb/models/item_create_params.rb +5 -9
  128. data/lib/orb/models/item_fetch_params.rb +3 -8
  129. data/lib/orb/models/item_list_params.rb +12 -15
  130. data/lib/orb/models/item_update_params.rb +10 -22
  131. data/lib/orb/models/metric_create_params.rb +17 -13
  132. data/lib/orb/models/metric_fetch_params.rb +3 -8
  133. data/lib/orb/models/metric_list_params.rb +20 -30
  134. data/lib/orb/models/metric_update_params.rb +9 -9
  135. data/lib/orb/models/pagination_metadata.rb +3 -7
  136. data/lib/orb/models/percentage_discount.rb +15 -14
  137. data/lib/orb/models/plan.rb +250 -279
  138. data/lib/orb/models/plan_create_params.rb +1623 -1984
  139. data/lib/orb/models/plan_fetch_params.rb +3 -8
  140. data/lib/orb/models/plan_list_params.rb +25 -42
  141. data/lib/orb/models/plan_update_params.rb +12 -10
  142. data/lib/orb/models/plans/external_plan_id_fetch_params.rb +3 -8
  143. data/lib/orb/models/plans/external_plan_id_update_params.rb +12 -10
  144. data/lib/orb/models/price.rb +2709 -3820
  145. data/lib/orb/models/price_create_params.rb +203 -244
  146. data/lib/orb/models/price_evaluate_params.rb +21 -30
  147. data/lib/orb/models/price_evaluate_response.rb +2 -6
  148. data/lib/orb/models/price_fetch_params.rb +3 -8
  149. data/lib/orb/models/price_list_params.rb +12 -15
  150. data/lib/orb/models/price_update_params.rb +9 -9
  151. data/lib/orb/models/prices/external_price_id_fetch_params.rb +3 -8
  152. data/lib/orb/models/prices/external_price_id_update_params.rb +9 -9
  153. data/lib/orb/models/subscription.rb +343 -382
  154. data/lib/orb/models/subscription_cancel_params.rb +16 -16
  155. data/lib/orb/models/subscription_cancel_response.rb +339 -377
  156. data/lib/orb/models/subscription_change_apply_params.rb +7 -10
  157. data/lib/orb/models/subscription_change_apply_response.rb +365 -398
  158. data/lib/orb/models/subscription_change_cancel_params.rb +3 -8
  159. data/lib/orb/models/subscription_change_cancel_response.rb +365 -398
  160. data/lib/orb/models/subscription_change_retrieve_params.rb +3 -8
  161. data/lib/orb/models/subscription_change_retrieve_response.rb +366 -398
  162. data/lib/orb/models/subscription_create_params.rb +3771 -4402
  163. data/lib/orb/models/subscription_create_response.rb +339 -377
  164. data/lib/orb/models/subscription_fetch_costs_params.rb +17 -17
  165. data/lib/orb/models/subscription_fetch_costs_response.rb +22 -26
  166. data/lib/orb/models/subscription_fetch_params.rb +3 -8
  167. data/lib/orb/models/subscription_fetch_schedule_params.rb +20 -30
  168. data/lib/orb/models/subscription_fetch_schedule_response.rb +15 -17
  169. data/lib/orb/models/subscription_fetch_usage_params.rb +32 -43
  170. data/lib/orb/models/subscription_list_params.rb +28 -41
  171. data/lib/orb/models/subscription_price_intervals_params.rb +2018 -2472
  172. data/lib/orb/models/subscription_price_intervals_response.rb +342 -377
  173. data/lib/orb/models/subscription_schedule_plan_change_params.rb +3764 -4392
  174. data/lib/orb/models/subscription_schedule_plan_change_response.rb +342 -377
  175. data/lib/orb/models/subscription_trigger_phase_params.rb +12 -10
  176. data/lib/orb/models/subscription_trigger_phase_response.rb +341 -377
  177. data/lib/orb/models/subscription_unschedule_cancellation_params.rb +3 -8
  178. data/lib/orb/models/subscription_unschedule_cancellation_response.rb +342 -377
  179. data/lib/orb/models/subscription_unschedule_fixed_fee_quantity_updates_params.rb +5 -9
  180. data/lib/orb/models/subscription_unschedule_fixed_fee_quantity_updates_response.rb +343 -377
  181. data/lib/orb/models/subscription_unschedule_pending_plan_changes_params.rb +3 -8
  182. data/lib/orb/models/subscription_unschedule_pending_plan_changes_response.rb +343 -377
  183. data/lib/orb/models/subscription_update_fixed_fee_quantity_params.rb +22 -33
  184. data/lib/orb/models/subscription_update_fixed_fee_quantity_response.rb +342 -377
  185. data/lib/orb/models/subscription_update_params.rb +21 -23
  186. data/lib/orb/models/subscription_update_trial_params.rb +15 -18
  187. data/lib/orb/models/subscription_update_trial_response.rb +341 -377
  188. data/lib/orb/models/subscription_usage.rb +37 -80
  189. data/lib/orb/models/subscriptions.rb +3 -7
  190. data/lib/orb/models/top_level_ping_params.rb +3 -8
  191. data/lib/orb/models/top_level_ping_response.rb +2 -6
  192. data/lib/orb/models/trial_discount.rb +16 -24
  193. data/lib/orb/models/usage_discount.rb +15 -14
  194. data/lib/orb/request_options.rb +3 -4
  195. data/lib/orb/resources/alerts.rb +48 -17
  196. data/lib/orb/resources/coupons/subscriptions.rb +9 -2
  197. data/lib/orb/resources/coupons.rb +25 -7
  198. data/lib/orb/resources/credit_notes.rb +17 -4
  199. data/lib/orb/resources/customers/balance_transactions.rb +18 -3
  200. data/lib/orb/resources/customers/costs.rb +26 -8
  201. data/lib/orb/resources/customers/credits/ledger.rb +108 -28
  202. data/lib/orb/resources/customers/credits/top_ups.rb +67 -20
  203. data/lib/orb/resources/customers/credits.rb +28 -8
  204. data/lib/orb/resources/customers.rb +135 -36
  205. data/lib/orb/resources/dimensional_price_groups.rb +19 -4
  206. data/lib/orb/resources/events/backfills.rb +32 -9
  207. data/lib/orb/resources/events/volume.rb +14 -4
  208. data/lib/orb/resources/events.rb +40 -11
  209. data/lib/orb/resources/invoice_line_items.rb +16 -6
  210. data/lib/orb/resources/invoices.rb +77 -17
  211. data/lib/orb/resources/items.rb +10 -3
  212. data/lib/orb/resources/metrics.rb +33 -8
  213. data/lib/orb/resources/plans/external_plan_id.rb +10 -2
  214. data/lib/orb/resources/plans.rb +47 -11
  215. data/lib/orb/resources/prices/external_price_id.rb +7 -1
  216. data/lib/orb/resources/prices.rb +97 -22
  217. data/lib/orb/resources/subscription_changes.rb +5 -2
  218. data/lib/orb/resources/subscriptions.rb +292 -78
  219. data/lib/orb/version.rb +1 -1
  220. data/lib/orb.rb +2 -10
  221. data/rbi/lib/orb/client.rbi +4 -4
  222. data/rbi/lib/orb/file_part.rbi +34 -0
  223. data/rbi/lib/orb/internal/transport/base_client.rbi +17 -3
  224. data/rbi/lib/orb/internal/type/array_of.rbi +3 -0
  225. data/rbi/lib/orb/internal/type/base_model.rbi +7 -1
  226. data/rbi/lib/orb/internal/type/base_page.rbi +2 -0
  227. data/rbi/lib/orb/internal/type/enum.rbi +3 -6
  228. data/rbi/lib/orb/internal/type/{io_like.rbi → file_input.rbi} +5 -2
  229. data/rbi/lib/orb/internal/type/hash_of.rbi +3 -0
  230. data/rbi/lib/orb/internal/type/union.rbi +3 -0
  231. data/rbi/lib/orb/internal/util.rbi +24 -19
  232. data/rbi/lib/orb/internal.rbi +0 -1
  233. data/rbi/lib/orb/models/alert.rbi +28 -8
  234. data/rbi/lib/orb/models/alert_create_for_customer_params.rbi +16 -6
  235. data/rbi/lib/orb/models/alert_create_for_external_customer_params.rbi +16 -6
  236. data/rbi/lib/orb/models/alert_create_for_subscription_params.rbi +16 -6
  237. data/rbi/lib/orb/models/alert_disable_params.rbi +5 -2
  238. data/rbi/lib/orb/models/alert_enable_params.rbi +5 -2
  239. data/rbi/lib/orb/models/alert_list_params.rbi +6 -0
  240. data/rbi/lib/orb/models/alert_update_params.rbi +11 -4
  241. data/rbi/lib/orb/models/amount_discount.rbi +10 -4
  242. data/rbi/lib/orb/models/billable_metric.rbi +16 -3
  243. data/rbi/lib/orb/models/billing_cycle_relative_date.rbi +1 -1
  244. data/rbi/lib/orb/models/coupon.rbi +10 -3
  245. data/rbi/lib/orb/models/coupon_create_params.rbi +6 -3
  246. data/rbi/lib/orb/models/coupon_list_params.rbi +13 -3
  247. data/rbi/lib/orb/models/coupons/subscription_list_params.rbi +8 -2
  248. data/rbi/lib/orb/models/credit_note.rbi +44 -12
  249. data/rbi/lib/orb/models/credit_note_create_params.rbi +15 -6
  250. data/rbi/lib/orb/models/credit_note_list_params.rbi +3 -0
  251. data/rbi/lib/orb/models/customer.rbi +130 -11
  252. data/rbi/lib/orb/models/customer_create_params.rbi +142 -8
  253. data/rbi/lib/orb/models/customer_list_params.rbi +3 -0
  254. data/rbi/lib/orb/models/customer_update_by_external_id_params.rbi +140 -8
  255. data/rbi/lib/orb/models/customer_update_params.rbi +140 -8
  256. data/rbi/lib/orb/models/customers/balance_transaction_create_params.rbi +8 -4
  257. data/rbi/lib/orb/models/customers/balance_transaction_create_response.rbi +18 -8
  258. data/rbi/lib/orb/models/customers/balance_transaction_list_params.rbi +3 -0
  259. data/rbi/lib/orb/models/customers/balance_transaction_list_response.rbi +18 -8
  260. data/rbi/lib/orb/models/customers/cost_list_by_external_id_params.rbi +9 -5
  261. data/rbi/lib/orb/models/customers/cost_list_by_external_id_response.rbi +21 -4
  262. data/rbi/lib/orb/models/customers/cost_list_params.rbi +9 -5
  263. data/rbi/lib/orb/models/customers/cost_list_response.rbi +21 -4
  264. data/rbi/lib/orb/models/customers/credit_list_by_external_id_params.rbi +13 -3
  265. data/rbi/lib/orb/models/customers/credit_list_by_external_id_response.rbi +1 -2
  266. data/rbi/lib/orb/models/customers/credit_list_params.rbi +13 -3
  267. data/rbi/lib/orb/models/customers/credit_list_response.rbi +1 -2
  268. data/rbi/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_params.rbi +40 -18
  269. data/rbi/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_response.rbi +35 -56
  270. data/rbi/lib/orb/models/customers/credits/ledger_create_entry_params.rbi +40 -6
  271. data/rbi/lib/orb/models/customers/credits/ledger_create_entry_response.rbi +35 -56
  272. data/rbi/lib/orb/models/customers/credits/ledger_list_by_external_id_params.rbi +6 -16
  273. data/rbi/lib/orb/models/customers/credits/ledger_list_by_external_id_response.rbi +35 -56
  274. data/rbi/lib/orb/models/customers/credits/ledger_list_params.rbi +6 -4
  275. data/rbi/lib/orb/models/customers/credits/ledger_list_response.rbi +35 -56
  276. data/rbi/lib/orb/models/customers/credits/top_up_create_by_external_id_params.rbi +27 -10
  277. data/rbi/lib/orb/models/customers/credits/top_up_create_by_external_id_response.rbi +25 -10
  278. data/rbi/lib/orb/models/customers/credits/top_up_create_params.rbi +27 -4
  279. data/rbi/lib/orb/models/customers/credits/top_up_create_response.rbi +25 -10
  280. data/rbi/lib/orb/models/customers/credits/top_up_list_by_external_id_params.rbi +8 -2
  281. data/rbi/lib/orb/models/customers/credits/top_up_list_by_external_id_response.rbi +25 -10
  282. data/rbi/lib/orb/models/customers/credits/top_up_list_params.rbi +8 -2
  283. data/rbi/lib/orb/models/customers/credits/top_up_list_response.rbi +25 -4
  284. data/rbi/lib/orb/models/dimensional_price_group.rbi +11 -3
  285. data/rbi/lib/orb/models/dimensional_price_group_create_params.rbi +4 -0
  286. data/rbi/lib/orb/models/dimensional_price_group_list_params.rbi +8 -2
  287. data/rbi/lib/orb/models/evaluate_price_group.rbi +8 -2
  288. data/rbi/lib/orb/models/event_deprecate_response.rbi +4 -2
  289. data/rbi/lib/orb/models/event_ingest_params.rbi +22 -5
  290. data/rbi/lib/orb/models/event_ingest_response.rbi +15 -4
  291. data/rbi/lib/orb/models/event_search_params.rbi +14 -2
  292. data/rbi/lib/orb/models/event_search_response.rbi +14 -3
  293. data/rbi/lib/orb/models/event_update_params.rbi +10 -3
  294. data/rbi/lib/orb/models/event_update_response.rbi +4 -2
  295. data/rbi/lib/orb/models/events/backfill_close_response.rbi +14 -2
  296. data/rbi/lib/orb/models/events/backfill_create_params.rbi +18 -0
  297. data/rbi/lib/orb/models/events/backfill_create_response.rbi +14 -2
  298. data/rbi/lib/orb/models/events/backfill_fetch_response.rbi +14 -2
  299. data/rbi/lib/orb/models/events/backfill_list_params.rbi +8 -2
  300. data/rbi/lib/orb/models/events/backfill_list_response.rbi +14 -2
  301. data/rbi/lib/orb/models/events/backfill_revert_response.rbi +14 -2
  302. data/rbi/lib/orb/models/events/event_volumes.rbi +6 -2
  303. data/rbi/lib/orb/models/events/volume_list_params.rbi +18 -2
  304. data/rbi/lib/orb/models/invoice.rbi +375 -46
  305. data/rbi/lib/orb/models/invoice_create_params.rbi +38 -6
  306. data/rbi/lib/orb/models/invoice_fetch_upcoming_response.rbi +375 -66
  307. data/rbi/lib/orb/models/invoice_issue_params.rbi +9 -2
  308. data/rbi/lib/orb/models/invoice_line_item_create_params.rbi +16 -2
  309. data/rbi/lib/orb/models/invoice_line_item_create_response.rbi +141 -20
  310. data/rbi/lib/orb/models/invoice_list_params.rbi +9 -2
  311. data/rbi/lib/orb/models/invoice_mark_paid_params.rbi +9 -2
  312. data/rbi/lib/orb/models/invoice_update_params.rbi +7 -2
  313. data/rbi/lib/orb/models/item.rbi +1 -2
  314. data/rbi/lib/orb/models/item_create_params.rbi +5 -2
  315. data/rbi/lib/orb/models/item_list_params.rbi +8 -2
  316. data/rbi/lib/orb/models/item_update_params.rbi +1 -8
  317. data/rbi/lib/orb/models/metric_create_params.rbi +15 -2
  318. data/rbi/lib/orb/models/metric_list_params.rbi +3 -0
  319. data/rbi/lib/orb/models/metric_update_params.rbi +7 -2
  320. data/rbi/lib/orb/models/percentage_discount.rbi +11 -4
  321. data/rbi/lib/orb/models/plan.rbi +102 -15
  322. data/rbi/lib/orb/models/plan_create_params.rbi +997 -679
  323. data/rbi/lib/orb/models/plan_list_params.rbi +5 -1
  324. data/rbi/lib/orb/models/plan_update_params.rbi +11 -2
  325. data/rbi/lib/orb/models/plans/external_plan_id_update_params.rbi +11 -2
  326. data/rbi/lib/orb/models/price.rbi +717 -688
  327. data/rbi/lib/orb/models/price_create_params.rbi +137 -53
  328. data/rbi/lib/orb/models/price_evaluate_params.rbi +10 -0
  329. data/rbi/lib/orb/models/price_list_params.rbi +8 -2
  330. data/rbi/lib/orb/models/price_update_params.rbi +7 -2
  331. data/rbi/lib/orb/models/prices/external_price_id_update_params.rbi +7 -2
  332. data/rbi/lib/orb/models/subscription.rbi +174 -11
  333. data/rbi/lib/orb/models/subscription_cancel_params.rbi +8 -5
  334. data/rbi/lib/orb/models/subscription_cancel_response.rbi +187 -14
  335. data/rbi/lib/orb/models/subscription_change_apply_params.rbi +7 -2
  336. data/rbi/lib/orb/models/subscription_change_apply_response.rbi +199 -18
  337. data/rbi/lib/orb/models/subscription_change_cancel_response.rbi +199 -18
  338. data/rbi/lib/orb/models/subscription_change_retrieve_response.rbi +199 -18
  339. data/rbi/lib/orb/models/subscription_create_params.rbi +2282 -1536
  340. data/rbi/lib/orb/models/subscription_create_response.rbi +187 -14
  341. data/rbi/lib/orb/models/subscription_fetch_costs_params.rbi +9 -5
  342. data/rbi/lib/orb/models/subscription_fetch_costs_response.rbi +21 -4
  343. data/rbi/lib/orb/models/subscription_fetch_schedule_params.rbi +3 -0
  344. data/rbi/lib/orb/models/subscription_fetch_schedule_response.rbi +8 -2
  345. data/rbi/lib/orb/models/subscription_fetch_usage_params.rbi +13 -4
  346. data/rbi/lib/orb/models/subscription_list_params.rbi +4 -2
  347. data/rbi/lib/orb/models/subscription_price_intervals_params.rbi +1228 -861
  348. data/rbi/lib/orb/models/subscription_price_intervals_response.rbi +187 -14
  349. data/rbi/lib/orb/models/subscription_schedule_plan_change_params.rbi +2288 -1544
  350. data/rbi/lib/orb/models/subscription_schedule_plan_change_response.rbi +187 -14
  351. data/rbi/lib/orb/models/subscription_trigger_phase_params.rbi +10 -2
  352. data/rbi/lib/orb/models/subscription_trigger_phase_response.rbi +187 -14
  353. data/rbi/lib/orb/models/subscription_unschedule_cancellation_response.rbi +187 -14
  354. data/rbi/lib/orb/models/subscription_unschedule_fixed_fee_quantity_updates_params.rbi +5 -2
  355. data/rbi/lib/orb/models/subscription_unschedule_fixed_fee_quantity_updates_response.rbi +187 -20
  356. data/rbi/lib/orb/models/subscription_unschedule_pending_plan_changes_response.rbi +187 -14
  357. data/rbi/lib/orb/models/subscription_update_fixed_fee_quantity_params.rbi +11 -2
  358. data/rbi/lib/orb/models/subscription_update_fixed_fee_quantity_response.rbi +187 -14
  359. data/rbi/lib/orb/models/subscription_update_params.rbi +15 -0
  360. data/rbi/lib/orb/models/subscription_update_trial_params.rbi +11 -5
  361. data/rbi/lib/orb/models/subscription_update_trial_response.rbi +187 -14
  362. data/rbi/lib/orb/models/subscription_usage.rbi +2 -16
  363. data/rbi/lib/orb/models/trial_discount.rbi +5 -1
  364. data/rbi/lib/orb/models/usage_discount.rbi +11 -3
  365. data/sig/orb/file_part.rbs +21 -0
  366. data/sig/orb/internal/transport/base_client.rbs +9 -3
  367. data/sig/orb/internal/type/array_of.rbs +2 -0
  368. data/sig/orb/internal/type/base_model.rbs +4 -0
  369. data/sig/orb/internal/type/enum.rbs +2 -2
  370. data/sig/orb/internal/type/{io_like.rbs → file_input.rbs} +1 -1
  371. data/sig/orb/internal/type/hash_of.rbs +2 -0
  372. data/sig/orb/internal/type/union.rbs +2 -0
  373. data/sig/orb/internal/util.rbs +14 -12
  374. metadata +8 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b20102d8611954dcd1c5682addb7eb5d7b54314f2a38a14ac662e61fdd3084d5
4
- data.tar.gz: '0857f6afda9adda33b5370837b17c5ab08e2bead3d708a3554e0c23c4398c2de'
3
+ metadata.gz: 6367789d025f1cbcd45171eca19809e1cb2cdff2c24af5335fac8641c876b093
4
+ data.tar.gz: 57a3c5bcb71ebf4f3e78b4412b386616cc1e37fc6adc682f38f13a129bc9aed4
5
5
  SHA512:
6
- metadata.gz: a2641bfb912356b7b5458ffa63da5c444a75c651dc14984a863badfb4b461e1b06da20ac25153dfa4d1e8176411268b541777f631cf75300b1704dfc0316a417
7
- data.tar.gz: 51816a9538c1d9e475afd9bc3e027aa4ef09874850ebb0d12d0c3b662c63315ef1a61e28e3d271ad83e3c529d8dddb545eace95b2fafa4c6e6689edbd63cb2a2
6
+ metadata.gz: 62f9112f730c3b05638d410aba2302c4ce137f46ad72e4a888636eff8eacc0f6649a41d69726f05e05ffb82d2de1fe9996f72556e537f065b43d415ffeb1024d
7
+ data.tar.gz: a0f8bd39183054afa8f172d776b20c54c08019b04001b00b33878fb4a69e6c0a0b54038bd7072e930fb85b2a070012fabf6319b4b2ce34195844b9f3b2cbe90a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.0 (2025-04-25)
4
+
5
+ Full Changelog: [v0.2.0...v0.3.0](https://github.com/orbcorp/orb-ruby/compare/v0.2.0...v0.3.0)
6
+
7
+ ### Features
8
+
9
+ * implement `#hash` for data containers ([ba49d29](https://github.com/orbcorp/orb-ruby/commit/ba49d294bfa09eca64b9a137c730c452318a56d4))
10
+ * support specifying content-type with FilePart class ([200103f](https://github.com/orbcorp/orb-ruby/commit/200103fddf8b1d524caa1cb3a126d72b476315f4))
11
+ * support webmock for testing ([ca1c497](https://github.com/orbcorp/orb-ruby/commit/ca1c497d57309c0bd2518070a0f8af3e0c639be4))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * ensure gem release is unaffected by renaming ([3e0fd9e](https://github.com/orbcorp/orb-ruby/commit/3e0fd9e21bb02529c0513b7a1e2fbdfa7d80b049))
17
+ * make a typo for `FilePart.content` ([f62d185](https://github.com/orbcorp/orb-ruby/commit/f62d18544ccd90a55bdfc520cbea03c1ea7583d1))
18
+
19
+
20
+ ### Chores
21
+
22
+ * broadly detect json family of content-type headers ([d4e5904](https://github.com/orbcorp/orb-ruby/commit/d4e5904287b32db4efe997b617310670961be6b1))
23
+ * **ci:** add timeout thresholds for CI jobs ([450f552](https://github.com/orbcorp/orb-ruby/commit/450f552e892e75242d3ec3e3e0c98605e1ac0b61))
24
+ * **ci:** only use depot for staging repos ([fd387ce](https://github.com/orbcorp/orb-ruby/commit/fd387ce6f9dff526039887480712e8b0c35595b5))
25
+ * **ci:** run on more branches and use depot runners ([7f5a6c3](https://github.com/orbcorp/orb-ruby/commit/7f5a6c320853a23d5ac339ea368d7cad7bbc35c5))
26
+ * documentation improvements ([6e04e50](https://github.com/orbcorp/orb-ruby/commit/6e04e5062b468fdf1f40fe3cd491b9fbb610bc5c))
27
+ * explicitly mark apis public under `Internal` module ([d19524a](https://github.com/orbcorp/orb-ruby/commit/d19524a2a412b98ac4529b46c02e249e8a587c34))
28
+ * **internal:** improve response envelope unwrap functionality ([b3f0632](https://github.com/orbcorp/orb-ruby/commit/b3f0632eae23d838395933fe4a334fd23dff46fd))
29
+ * **internal:** minor type annotation improvements ([cf871bc](https://github.com/orbcorp/orb-ruby/commit/cf871bca5feacf6e95351418a3553c774889ccee))
30
+ * **internal:** version bump ([6b83db6](https://github.com/orbcorp/orb-ruby/commit/6b83db65c3d405b7f7c5e20a93be6428dcf7fc08))
31
+ * make sorbet enums easier to read ([3793346](https://github.com/orbcorp/orb-ruby/commit/3793346c4a6cd6ff18aad64e4c48933a5159ebe1))
32
+ * show truncated parameter docs in yard ([0fb86bd](https://github.com/orbcorp/orb-ruby/commit/0fb86bd1313bb300e565f873e5a181f652ce88fa))
33
+ * simplify yard annotations by removing most `@!parse` directives ([a94843b](https://github.com/orbcorp/orb-ruby/commit/a94843be3f13ed22ae07ded47bff22e044525f0b))
34
+ * update README with recommended editor plugins ([50771fd](https://github.com/orbcorp/orb-ruby/commit/50771fdf28dcee2856522c5c29a491873ec14a4a))
35
+ * use `@!method` instead of `@!parse` for virtual method type definitions ([21cfdfc](https://github.com/orbcorp/orb-ruby/commit/21cfdfcc91f9dbd04831e502b990f9118f4b5eb0))
36
+
3
37
  ## 0.2.0 (2025-04-17)
4
38
 
5
39
  Full Changelog: [v0.1.3...v0.2.0](https://github.com/orbcorp/orb-ruby/compare/v0.1.3...v0.2.0)
data/README.md CHANGED
@@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
15
15
  <!-- x-release-please-start-version -->
16
16
 
17
17
  ```ruby
18
- gem "orb-billing", "~> 0.2.0"
18
+ gem "orb-billing", "~> 0.3.0"
19
19
  ```
20
20
 
21
21
  <!-- x-release-please-end -->
@@ -35,6 +35,16 @@ customer = orb.customers.create(email: "example-customer@withorb.com", name: "My
35
35
  puts(customer.id)
36
36
  ```
37
37
 
38
+ ## Sorbet
39
+
40
+ This library is written with [Sorbet type definitions](https://sorbet.org/docs/rbi). However, there is no runtime dependency on the `sorbet-runtime`.
41
+
42
+ When using sorbet, it is recommended to use model classes as below. This provides stronger type checking and tooling integration.
43
+
44
+ ```ruby
45
+ orb.customers.create(email: "example-customer@withorb.com", name: "My Customer")
46
+ ```
47
+
38
48
  ### Pagination
39
49
 
40
50
  List methods in the Orb API are paginated.
@@ -126,61 +136,33 @@ orb.customers.create(
126
136
  )
127
137
  ```
128
138
 
129
- ## LSP Support
130
-
131
- ### Solargraph
132
-
133
- This library includes [Solargraph](https://solargraph.org) support for both auto completion and go to definition.
134
-
135
- ```ruby
136
- gem "solargraph", group: :development
137
- ```
138
-
139
- After Solargraph is installed, **you must populate its index** either via the provided editor command, or by running the following in your terminal:
140
-
141
- ```sh
142
- bundle exec solargraph gems
143
- ```
144
-
145
- Note: if you had installed the gem either using a `git:` or `github:` URL, or had vendored the gem using bundler, you will need to set up your [`.solargraph.yml`](https://solargraph.org/guides/configuration) to include the path to the gem's `lib` directory.
146
-
147
- ```yaml
148
- include:
149
- - 'vendor/bundle/ruby/*/gems/orb-billing-*/lib/**/*.rb'
150
- ```
151
-
152
- Otherwise Solargraph will not be able to provide type information or auto-completion for any non-indexed libraries.
153
-
154
- ### Sorbet
155
-
156
- This library is written with [Sorbet type definitions](https://sorbet.org/docs/rbi). However, there is no runtime dependency on the `sorbet-runtime`.
139
+ ## Model DSL
157
140
 
158
- What this means is that while you can use Sorbet to type check your code statically, and benefit from the [Sorbet Language Server](https://sorbet.org/docs/lsp) in your editor, there is no runtime type checking and execution overhead from Sorbet itself.
141
+ This library uses a simple DSL to represent request parameters and response shapes in `lib/orb/models`.
159
142
 
160
- Due to limitations with the Sorbet type system, where a method otherwise can take an instance of `Orb::BaseModel` class, you will need to use the `**` splat operator to pass the arguments:
143
+ With the right [editor plugins](https://shopify.github.io/ruby-lsp), you can ctrl-click on elements of the DSL to navigate around and explore the library.
161
144
 
162
- Please follow Sorbet's [setup guides](https://sorbet.org/docs/adopting) for best experience.
145
+ In all places where a `BaseModel` type is specified, vanilla Ruby `Hash` can also be used. For example, the following are interchangeable as arguments:
163
146
 
164
147
  ```ruby
148
+ # This has tooling readability, for auto-completion, static analysis, and goto definition with supported language services
165
149
  params = Orb::Models::CustomerCreateParams.new(email: "example-customer@withorb.com", name: "My Customer")
166
150
 
167
- orb.customers.create(**params)
151
+ # This also works
152
+ params = {
153
+ email: "example-customer@withorb.com",
154
+ name: "My Customer"
155
+ }
168
156
  ```
169
157
 
170
- Note: **This library emits an intentional warning under the [`tapioca` toolchain](https://github.com/Shopify/tapioca)**. This is normal, and does not impact functionality.
171
-
172
- ### Ruby LSP
158
+ ## Editor support
173
159
 
174
- The Ruby LSP has [best effort support](https://shopify.github.io/ruby-lsp/#guessed-types) for inferring type information from Ruby code, and as such it may not always be able to provide accurate type information.
160
+ A combination of [Shopify LSP](https://shopify.github.io/ruby-lsp) and [Solargraph](https://solargraph.org/) is recommended for non-[Sorbet](https://sorbet.org) users. The former is especially good at go to definition, while the latter has much better auto-completion support.
175
161
 
176
- ## Advanced
162
+ ## Advanced concepts
177
163
 
178
164
  ### Making custom/undocumented requests
179
165
 
180
- This library is typed for convenient access to the documented API.
181
-
182
- If you need to access undocumented endpoints, params, or response properties, the library can still be used.
183
-
184
166
  #### Undocumented request params
185
167
 
186
168
  If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a requests as seen in examples above.
@@ -191,15 +173,15 @@ To make requests to undocumented endpoints, you can make requests using `client.
191
173
 
192
174
  ```ruby
193
175
  response = client.request(
194
- method: :post,
195
- path: '/undocumented/endpoint',
196
- query: {"dog": "woof"},
197
- headers: {"useful-header": "interesting-value"},
198
- body: {"he": "llo"},
199
- )
176
+ method: :post,
177
+ path: '/undocumented/endpoint',
178
+ query: {"dog": "woof"},
179
+ headers: {"useful-header": "interesting-value"},
180
+ body: {"he": "llo"},
181
+ )
200
182
  ```
201
183
 
202
- ### Concurrency & Connection Pooling
184
+ ### Concurrency & connection pooling
203
185
 
204
186
  The `Orb::Client` instances are thread-safe, and should be re-used across multiple threads. By default, each `Client` have their own HTTP connection pool, with a maximum number of connections equal to thread count.
205
187
 
@@ -209,6 +191,30 @@ Unless otherwise specified, other classes in the SDK do not have locks protectin
209
191
 
210
192
  Currently, `Orb::Client` instances are only fork-safe if there are no in-flight HTTP requests.
211
193
 
194
+ ### Sorbet
195
+
196
+ #### Enums
197
+
198
+ Sorbet's typed enums require sub-classing of the [`T::Enum` class](https://sorbet.org/docs/tenum) from the `sorbet-runtime` gem.
199
+
200
+ Since this library does not depend on `sorbet-runtime`, it uses a [`T.all` intersection type](https://sorbet.org/docs/intersection-types) with a ruby primitive type to construct a "tagged alias" instead.
201
+
202
+ ```ruby
203
+ module Orb::Models::BillingCycleRelativeDate
204
+ # This alias aids language service driven navigation.
205
+ TaggedSymbol = T.type_alias { T.all(Symbol, Orb::Models::BillingCycleRelativeDate) }
206
+ end
207
+ ```
208
+
209
+ #### Argument passing trick
210
+
211
+ It is possible to pass a compatible model / parameter class to a method that expects keyword arguments by using the `**` splat operator.
212
+
213
+ ```ruby
214
+ params = Orb::Models::CustomerCreateParams.new(email: "example-customer@withorb.com", name: "My Customer")
215
+ orb.customers.create(**params)
216
+ ```
217
+
212
218
  ## Versioning
213
219
 
214
220
  This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.
@@ -218,3 +224,7 @@ This package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` typ
218
224
  ## Requirements
219
225
 
220
226
  Ruby 3.1.0 or higher.
227
+
228
+ ## Contributing
229
+
230
+ See [the contributing documentation](https://github.com/orbcorp/orb-ruby/tree/main/CONTRIBUTING.md).
data/lib/orb/client.rb CHANGED
@@ -91,10 +91,10 @@ module Orb
91
91
  def initialize(
92
92
  api_key: ENV["ORB_API_KEY"],
93
93
  base_url: ENV["ORB_BASE_URL"],
94
- max_retries: DEFAULT_MAX_RETRIES,
95
- timeout: DEFAULT_TIMEOUT_IN_SECONDS,
96
- initial_retry_delay: DEFAULT_INITIAL_RETRY_DELAY,
97
- max_retry_delay: DEFAULT_MAX_RETRY_DELAY,
94
+ max_retries: Orb::Client::DEFAULT_MAX_RETRIES,
95
+ timeout: Orb::Client::DEFAULT_TIMEOUT_IN_SECONDS,
96
+ initial_retry_delay: Orb::Client::DEFAULT_INITIAL_RETRY_DELAY,
97
+ max_retry_delay: Orb::Client::DEFAULT_MAX_RETRY_DELAY,
98
98
  idempotency_header: "Idempotency-Key"
99
99
  )
100
100
  base_url ||= "https://api.withorb.com/v1"
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Orb
4
+ class FilePart
5
+ # @return [Pathname, StringIO, IO, String]
6
+ attr_reader :content
7
+
8
+ # @return [String, nil]
9
+ attr_reader :content_type
10
+
11
+ # @return [String, nil]
12
+ attr_reader :filename
13
+
14
+ # @api private
15
+ #
16
+ # @return [String]
17
+ private def read
18
+ case content
19
+ in Pathname
20
+ content.read(binmode: true)
21
+ in StringIO
22
+ content.string
23
+ in IO
24
+ content.read
25
+ in String
26
+ content
27
+ end
28
+ end
29
+
30
+ # @param a [Object]
31
+ #
32
+ # @return [String]
33
+ def to_json(*a) = read.to_json(*a)
34
+
35
+ # @param a [Object]
36
+ #
37
+ # @return [String]
38
+ def to_yaml(*a) = read.to_yaml(*a)
39
+
40
+ # @param content [Pathname, StringIO, IO, String]
41
+ # @param filename [String, nil]
42
+ # @param content_type [String, nil]
43
+ def initialize(content, filename: nil, content_type: nil)
44
+ @content = content
45
+ @filename =
46
+ case content
47
+ in Pathname
48
+ filename.nil? ? content.basename.to_path : File.basename(filename)
49
+ else
50
+ filename.nil? ? nil : File.basename(filename)
51
+ end
52
+ @content_type = content_type
53
+ end
54
+ end
55
+ end
@@ -28,7 +28,7 @@ module Orb
28
28
  end
29
29
 
30
30
  # @raise [Orb::HTTP::Error]
31
- # @return [Orb::Internal::Page]
31
+ # @return [self]
32
32
  def next_page
33
33
  unless next_page?
34
34
  message = "No more pages available. Please check #next_page? before calling ##{__method__}"
@@ -101,13 +101,9 @@ module Orb
101
101
  # @return [String, nil]
102
102
  required :next_cursor, String, nil?: true
103
103
 
104
- # @!parse
105
- # # @param has_more [Boolean]
106
- # # @param next_cursor [String, nil]
107
- # #
108
- # def initialize(has_more:, next_cursor:, **) = super
109
-
110
- # def initialize: (Hash | Orb::Internal::Type::BaseModel) -> void
104
+ # @!method initialize(has_more:, next_cursor:)
105
+ # @param has_more [Boolean]
106
+ # @param next_cursor [String, nil]
111
107
  end
112
108
  end
113
109
  end
@@ -153,7 +153,7 @@ module Orb
153
153
 
154
154
  # @api private
155
155
  # @return [Orb::Internal::Transport::PooledNetRequester]
156
- attr_accessor :requester
156
+ attr_reader :requester
157
157
 
158
158
  # @api private
159
159
  #
@@ -214,11 +214,11 @@ module Orb
214
214
  #
215
215
  # @option req [Object, nil] :body
216
216
  #
217
- # @option req [Symbol, nil] :unwrap
217
+ # @option req [Symbol, Integer, Array<Symbol, Integer>, Proc, nil] :unwrap
218
218
  #
219
- # @option req [Class, nil] :page
219
+ # @option req [Class<Orb::Internal::Type::BasePage>, nil] :page
220
220
  #
221
- # @option req [Class, nil] :stream
221
+ # @option req [Class<Orb::Internal::Type::BaseStream>, nil] :stream
222
222
  #
223
223
  # @option req [Orb::Internal::Type::Converter, Class, nil] :model
224
224
  #
@@ -415,11 +415,11 @@ module Orb
415
415
  #
416
416
  # @param body [Object, nil]
417
417
  #
418
- # @param unwrap [Symbol, nil]
418
+ # @param unwrap [Symbol, Integer, Array<Symbol, Integer>, Proc, nil]
419
419
  #
420
- # @param page [Class, nil]
420
+ # @param page [Class<Orb::Internal::Type::BasePage>, nil]
421
421
  #
422
- # @param stream [Class, nil]
422
+ # @param stream [Class<Orb::Internal::Type::BaseStream>, nil]
423
423
  #
424
424
  # @param model [Orb::Internal::Type::Converter, Class, nil]
425
425
  #
@@ -61,7 +61,7 @@ module Orb
61
61
  method.to_s.upcase,
62
62
  !body.nil?,
63
63
  method != :head,
64
- url.to_s
64
+ URI(url.to_s) # ensure we construct a URI class of the right scheme
65
65
  )
66
66
 
67
67
  headers.each { req[_1] = _2 }
@@ -176,7 +176,7 @@ module Orb
176
176
  conn.finish if !eof && conn&.started?
177
177
  closing&.call
178
178
  end
179
- [Integer(response.code), response, (response.body = body)]
179
+ [Integer(response.code), response, body]
180
180
  end
181
181
 
182
182
  # @api private
@@ -28,13 +28,19 @@ module Orb
28
28
  # @option spec [Proc] :union
29
29
  #
30
30
  # @option spec [Boolean] :"nil?"
31
+ #
32
+ # @return [Orb::Internal::Type::ArrayOf]
31
33
  def self.[](...) = new(...)
32
34
 
35
+ # @api public
36
+ #
33
37
  # @param other [Object]
34
38
  #
35
39
  # @return [Boolean]
36
40
  def ===(other) = other.is_a?(Array) && other.all?(item_type)
37
41
 
42
+ # @api public
43
+ #
38
44
  # @param other [Object]
39
45
  #
40
46
  # @return [Boolean]
@@ -44,6 +50,11 @@ module Orb
44
50
  # rubocop:enable Layout/LineLength
45
51
  end
46
52
 
53
+ # @api public
54
+ #
55
+ # @return [Integer]
56
+ def hash = [self.class, item_type].hash
57
+
47
58
  # @api private
48
59
  #
49
60
  # @param value [Array<Object>, Object]
@@ -4,14 +4,6 @@ module Orb
4
4
  module Internal
5
5
  module Type
6
6
  # @abstract
7
- #
8
- # @example
9
- # # `amount_discount` is a `Orb::Models::AmountDiscount`
10
- # amount_discount => {
11
- # amount_discount: amount_discount,
12
- # applies_to_price_ids: applies_to_price_ids,
13
- # discount_type: discount_type
14
- # }
15
7
  class BaseModel
16
8
  extend Orb::Internal::Type::Converter
17
9
 
@@ -93,11 +85,13 @@ module Orb
93
85
  state: state
94
86
  )
95
87
  end
96
- rescue StandardError
88
+ rescue StandardError => e
97
89
  cls = self.class.name.split("::").last
98
- # rubocop:disable Layout/LineLength
99
- message = "Failed to parse #{cls}.#{__method__} from #{value.class} to #{target.inspect}. To get the unparsed API response, use #{cls}[:#{__method__}]."
100
- # rubocop:enable Layout/LineLength
90
+ message = [
91
+ "Failed to parse #{cls}.#{__method__} from #{value.class} to #{target.inspect}.",
92
+ "To get the unparsed API response, use #{cls}[#{__method__.inspect}].",
93
+ "Cause: #{e.message}"
94
+ ].join(" ")
101
95
  raise Orb::Errors::ConversionError.new(message)
102
96
  end
103
97
  end
@@ -165,19 +159,33 @@ module Orb
165
159
  @mode = nil
166
160
  end
167
161
 
162
+ # @api public
163
+ #
168
164
  # @param other [Object]
169
165
  #
170
166
  # @return [Boolean]
171
167
  def ==(other)
172
168
  other.is_a?(Class) && other <= Orb::Internal::Type::BaseModel && other.fields == fields
173
169
  end
170
+
171
+ # @api public
172
+ #
173
+ # @return [Integer]
174
+ def hash = fields.hash
174
175
  end
175
176
 
177
+ # @api public
178
+ #
176
179
  # @param other [Object]
177
180
  #
178
181
  # @return [Boolean]
179
182
  def ==(other) = self.class == other.class && @data == other.to_h
180
183
 
184
+ # @api public
185
+ #
186
+ # @return [Integer]
187
+ def hash = [self.class, @data].hash
188
+
181
189
  class << self
182
190
  # @api private
183
191
  #
@@ -291,6 +299,8 @@ module Orb
291
299
  end
292
300
  end
293
301
 
302
+ # @api public
303
+ #
294
304
  # Returns the raw value associated with the given key, if found. Otherwise, nil is
295
305
  # returned.
296
306
  #
@@ -309,6 +319,8 @@ module Orb
309
319
  @data[key]
310
320
  end
311
321
 
322
+ # @api public
323
+ #
312
324
  # Returns a Hash of the data underlying this object. O(1)
313
325
  #
314
326
  # Keys are Symbols and values are the raw values from the response. The return
@@ -339,6 +351,8 @@ module Orb
339
351
  end
340
352
 
341
353
  class << self
354
+ # @api private
355
+ #
342
356
  # @param model [Orb::Internal::Type::BaseModel]
343
357
  #
344
358
  # @return [Hash{Symbol=>Object}]
@@ -359,11 +373,15 @@ module Orb
359
373
  end
360
374
  end
361
375
 
376
+ # @api public
377
+ #
362
378
  # @param a [Object]
363
379
  #
364
380
  # @return [String]
365
381
  def to_json(*a) = Orb::Internal::Type::Converter.dump(self.class, self).to_json(*a)
366
382
 
383
+ # @api public
384
+ #
367
385
  # @param a [Object]
368
386
  #
369
387
  # @return [String]
@@ -371,7 +389,7 @@ module Orb
371
389
 
372
390
  # Create a new instance of a model.
373
391
  #
374
- # @param data [Hash{Symbol=>Object}, Orb::Internal::Type::BaseModel]
392
+ # @param data [Hash{Symbol=>Object}, self]
375
393
  def initialize(data = {})
376
394
  case Orb::Internal::Util.coerce_hash(data)
377
395
  in Hash => coerced
@@ -405,7 +423,7 @@ module Orb
405
423
  end
406
424
  end
407
425
 
408
- # @api private
426
+ # @api public
409
427
  #
410
428
  # @return [String]
411
429
  def to_s = self.class.walk(@data).to_s
@@ -3,19 +3,27 @@
3
3
  module Orb
4
4
  module Internal
5
5
  module Type
6
+ # @api private
7
+ #
6
8
  # @generic Elem
7
9
  #
8
10
  # This module provides a base implementation for paginated responses in the SDK.
9
11
  module BasePage
10
12
  # rubocop:disable Lint/UnusedMethodArgument
11
13
 
14
+ # @api public
15
+ #
12
16
  # @return [Boolean]
13
17
  def next_page? = (raise NotImplementedError)
14
18
 
19
+ # @api public
20
+ #
15
21
  # @raise [Orb::Errors::APIError]
16
- # @return [Orb::Internal::Type::BasePage]
22
+ # @return [self]
17
23
  def next_page = (raise NotImplementedError)
18
24
 
25
+ # @api public
26
+ #
19
27
  # @param blk [Proc]
20
28
  #
21
29
  # @yieldparam [generic<Elem>]
@@ -13,11 +13,15 @@ module Orb
13
13
 
14
14
  private_class_method :new
15
15
 
16
+ # @api public
17
+ #
16
18
  # @param other [Object]
17
19
  #
18
20
  # @return [Boolean]
19
21
  def self.===(other) = other == true || other == false
20
22
 
23
+ # @api public
24
+ #
21
25
  # @param other [Object]
22
26
  #
23
27
  # @return [Boolean]
@@ -43,7 +43,10 @@ module Orb
43
43
  value.string
44
44
  in Pathname | IO
45
45
  state[:can_retry] = false if value.is_a?(IO)
46
- Orb::Internal::Util::SerializationAdapter.new(value)
46
+ Orb::FilePart.new(value)
47
+ in Orb::FilePart
48
+ state[:can_retry] = false if value.content.is_a?(IO)
49
+ value
47
50
  else
48
51
  value
49
52
  end
@@ -42,18 +42,17 @@ module Orb
42
42
  # All of the valid Symbol values for this enum.
43
43
  #
44
44
  # @return [Array<NilClass, Boolean, Integer, Float, Symbol>]
45
- def values = (@values ||= constants.map { const_get(_1) })
45
+ def values = constants.map { const_get(_1) }
46
46
 
47
- # @api private
47
+ # @api public
48
48
  #
49
- # Guard against thread safety issues by instantiating `@values`.
50
- private def finalize! = values
51
-
52
49
  # @param other [Object]
53
50
  #
54
51
  # @return [Boolean]
55
52
  def ===(other) = values.include?(other)
56
53
 
54
+ # @api public
55
+ #
57
56
  # @param other [Object]
58
57
  #
59
58
  # @return [Boolean]
@@ -63,6 +62,11 @@ module Orb
63
62
  # rubocop:enable Style/CaseEquality
64
63
  end
65
64
 
65
+ # @api public
66
+ #
67
+ # @return [Integer]
68
+ def hash = values.to_set.hash
69
+
66
70
  # @api private
67
71
  #
68
72
  # Unlike with primitives, `Enum` additionally validates that the value is a member