orb-billing 0.3.2 → 0.4.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 (245) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/README.md +1 -1
  4. data/lib/orb/errors.rb +1 -1
  5. data/lib/orb/internal/transport/base_client.rb +74 -5
  6. data/lib/orb/internal/transport/pooled_net_requester.rb +14 -0
  7. data/lib/orb/internal/type/array_of.rb +1 -1
  8. data/lib/orb/internal/type/base_model.rb +62 -30
  9. data/lib/orb/internal/type/converter.rb +18 -0
  10. data/lib/orb/internal/type/enum.rb +1 -0
  11. data/lib/orb/internal/type/hash_of.rb +1 -1
  12. data/lib/orb/internal/type/union.rb +1 -0
  13. data/lib/orb/internal/util.rb +56 -0
  14. data/lib/orb/internal.rb +6 -0
  15. data/lib/orb/models/coupon.rb +4 -0
  16. data/lib/orb/models/coupon_create_params.rb +6 -0
  17. data/lib/orb/models/customer_create_params.rb +9 -0
  18. data/lib/orb/models/customer_update_by_external_id_params.rb +9 -0
  19. data/lib/orb/models/customer_update_params.rb +9 -0
  20. data/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_response.rb +14 -0
  21. data/lib/orb/models/customers/credits/ledger_create_entry_response.rb +14 -0
  22. data/lib/orb/models/customers/credits/ledger_list_by_external_id_response.rb +14 -0
  23. data/lib/orb/models/customers/credits/ledger_list_response.rb +14 -0
  24. data/lib/orb/models/discount.rb +6 -0
  25. data/lib/orb/models/evaluate_price_group.rb +4 -0
  26. data/lib/orb/models/invoice.rb +22 -0
  27. data/lib/orb/models/invoice_fetch_upcoming_response.rb +22 -0
  28. data/lib/orb/models/invoice_level_discount.rb +4 -0
  29. data/lib/orb/models/invoice_line_item_create_response.rb +22 -0
  30. data/lib/orb/models/plan.rb +12 -0
  31. data/lib/orb/models/plan_create_params.rb +32 -0
  32. data/lib/orb/models/price.rb +35 -0
  33. data/lib/orb/models/subscription.rb +22 -0
  34. data/lib/orb/models/subscription_cancel_response.rb +22 -0
  35. data/lib/orb/models/subscription_change_apply_response.rb +22 -0
  36. data/lib/orb/models/subscription_change_cancel_response.rb +22 -0
  37. data/lib/orb/models/subscription_change_retrieve_response.rb +22 -0
  38. data/lib/orb/models/subscription_create_params.rb +88 -0
  39. data/lib/orb/models/subscription_create_response.rb +22 -0
  40. data/lib/orb/models/subscription_price_intervals_params.rb +89 -0
  41. data/lib/orb/models/subscription_price_intervals_response.rb +22 -0
  42. data/lib/orb/models/subscription_schedule_plan_change_params.rb +88 -0
  43. data/lib/orb/models/subscription_schedule_plan_change_response.rb +22 -0
  44. data/lib/orb/models/subscription_trigger_phase_response.rb +22 -0
  45. data/lib/orb/models/subscription_unschedule_cancellation_response.rb +22 -0
  46. data/lib/orb/models/subscription_unschedule_fixed_fee_quantity_updates_response.rb +22 -0
  47. data/lib/orb/models/subscription_unschedule_pending_plan_changes_response.rb +22 -0
  48. data/lib/orb/models/subscription_update_fixed_fee_quantity_response.rb +22 -0
  49. data/lib/orb/models/subscription_update_trial_params.rb +4 -0
  50. data/lib/orb/models/subscription_update_trial_response.rb +22 -0
  51. data/lib/orb/models/subscription_usage.rb +9 -0
  52. data/lib/orb/models.rb +24 -0
  53. data/lib/orb/request_options.rb +4 -0
  54. data/lib/orb/version.rb +1 -1
  55. data/lib/orb.rb +2 -0
  56. data/rbi/orb/internal/page.rbi +2 -1
  57. data/rbi/orb/internal/transport/base_client.rbi +31 -8
  58. data/rbi/orb/internal/transport/pooled_net_requester.rbi +5 -4
  59. data/rbi/orb/internal/type/base_model.rbi +31 -15
  60. data/rbi/orb/internal/type/base_page.rbi +1 -1
  61. data/rbi/orb/internal/type/converter.rbi +2 -0
  62. data/rbi/orb/internal/type/enum.rbi +1 -0
  63. data/rbi/orb/internal/type/union.rbi +1 -0
  64. data/rbi/orb/internal/util.rbi +28 -7
  65. data/rbi/orb/internal.rbi +2 -0
  66. data/rbi/orb/models/alert.rbi +13 -6
  67. data/rbi/orb/models/alert_create_for_customer_params.rbi +11 -2
  68. data/rbi/orb/models/alert_create_for_external_customer_params.rbi +14 -2
  69. data/rbi/orb/models/alert_create_for_subscription_params.rbi +11 -2
  70. data/rbi/orb/models/alert_disable_params.rbi +2 -1
  71. data/rbi/orb/models/alert_enable_params.rbi +2 -1
  72. data/rbi/orb/models/alert_list_params.rbi +2 -1
  73. data/rbi/orb/models/alert_retrieve_params.rbi +2 -1
  74. data/rbi/orb/models/alert_update_params.rbi +6 -2
  75. data/rbi/orb/models/amount_discount.rbi +2 -1
  76. data/rbi/orb/models/billable_metric.rbi +2 -1
  77. data/rbi/orb/models/coupon.rbi +1 -1
  78. data/rbi/orb/models/coupon_archive_params.rbi +2 -1
  79. data/rbi/orb/models/coupon_create_params.rbi +16 -3
  80. data/rbi/orb/models/coupon_fetch_params.rbi +2 -1
  81. data/rbi/orb/models/coupon_list_params.rbi +2 -1
  82. data/rbi/orb/models/coupons/subscription_list_params.rbi +4 -1
  83. data/rbi/orb/models/credit_note.rbi +45 -9
  84. data/rbi/orb/models/credit_note_create_params.rbi +8 -2
  85. data/rbi/orb/models/credit_note_fetch_params.rbi +4 -1
  86. data/rbi/orb/models/credit_note_list_params.rbi +4 -1
  87. data/rbi/orb/models/customer.rbi +41 -10
  88. data/rbi/orb/models/customer_create_params.rbi +61 -10
  89. data/rbi/orb/models/customer_delete_params.rbi +4 -1
  90. data/rbi/orb/models/customer_fetch_by_external_id_params.rbi +4 -1
  91. data/rbi/orb/models/customer_fetch_params.rbi +2 -1
  92. data/rbi/orb/models/customer_list_params.rbi +2 -1
  93. data/rbi/orb/models/customer_sync_payment_methods_from_gateway_by_external_customer_id_params.rbi +7 -1
  94. data/rbi/orb/models/customer_sync_payment_methods_from_gateway_params.rbi +7 -1
  95. data/rbi/orb/models/customer_update_by_external_id_params.rbi +67 -10
  96. data/rbi/orb/models/customer_update_params.rbi +61 -10
  97. data/rbi/orb/models/customers/balance_transaction_create_params.rbi +7 -1
  98. data/rbi/orb/models/customers/balance_transaction_create_response.rbi +21 -3
  99. data/rbi/orb/models/customers/balance_transaction_list_params.rbi +7 -1
  100. data/rbi/orb/models/customers/balance_transaction_list_response.rbi +21 -3
  101. data/rbi/orb/models/customers/cost_list_by_external_id_params.rbi +7 -1
  102. data/rbi/orb/models/customers/cost_list_by_external_id_response.rbi +21 -3
  103. data/rbi/orb/models/customers/cost_list_params.rbi +4 -1
  104. data/rbi/orb/models/customers/cost_list_response.rbi +21 -3
  105. data/rbi/orb/models/customers/credit_list_by_external_id_params.rbi +7 -1
  106. data/rbi/orb/models/customers/credit_list_by_external_id_response.rbi +7 -1
  107. data/rbi/orb/models/customers/credit_list_params.rbi +4 -1
  108. data/rbi/orb/models/customers/credit_list_response.rbi +7 -1
  109. data/rbi/orb/models/customers/credits/ledger_create_entry_by_external_id_params.rbi +14 -2
  110. data/rbi/orb/models/customers/credits/ledger_create_entry_by_external_id_response.rbi +133 -21
  111. data/rbi/orb/models/customers/credits/ledger_create_entry_params.rbi +14 -2
  112. data/rbi/orb/models/customers/credits/ledger_create_entry_response.rbi +133 -21
  113. data/rbi/orb/models/customers/credits/ledger_list_by_external_id_params.rbi +7 -1
  114. data/rbi/orb/models/customers/credits/ledger_list_by_external_id_response.rbi +133 -21
  115. data/rbi/orb/models/customers/credits/ledger_list_params.rbi +7 -1
  116. data/rbi/orb/models/customers/credits/ledger_list_response.rbi +133 -21
  117. data/rbi/orb/models/customers/credits/top_up_create_by_external_id_params.rbi +14 -2
  118. data/rbi/orb/models/customers/credits/top_up_create_by_external_id_response.rbi +14 -2
  119. data/rbi/orb/models/customers/credits/top_up_create_params.rbi +14 -2
  120. data/rbi/orb/models/customers/credits/top_up_create_response.rbi +14 -2
  121. data/rbi/orb/models/customers/credits/top_up_delete_by_external_id_params.rbi +7 -1
  122. data/rbi/orb/models/customers/credits/top_up_delete_params.rbi +7 -1
  123. data/rbi/orb/models/customers/credits/top_up_list_by_external_id_params.rbi +7 -1
  124. data/rbi/orb/models/customers/credits/top_up_list_by_external_id_response.rbi +14 -2
  125. data/rbi/orb/models/customers/credits/top_up_list_params.rbi +7 -1
  126. data/rbi/orb/models/customers/credits/top_up_list_response.rbi +14 -2
  127. data/rbi/orb/models/dimensional_price_group.rbi +4 -1
  128. data/rbi/orb/models/dimensional_price_group_create_params.rbi +4 -1
  129. data/rbi/orb/models/dimensional_price_group_list_params.rbi +4 -1
  130. data/rbi/orb/models/dimensional_price_group_retrieve_params.rbi +7 -1
  131. data/rbi/orb/models/dimensional_price_groups/external_dimensional_price_group_id_retrieve_params.rbi +7 -1
  132. data/rbi/orb/models/dimensional_price_groups.rbi +4 -1
  133. data/rbi/orb/models/evaluate_price_group.rbi +2 -1
  134. data/rbi/orb/models/event_deprecate_params.rbi +4 -1
  135. data/rbi/orb/models/event_deprecate_response.rbi +4 -1
  136. data/rbi/orb/models/event_ingest_params.rbi +6 -2
  137. data/rbi/orb/models/event_ingest_response.rbi +18 -3
  138. data/rbi/orb/models/event_search_params.rbi +2 -1
  139. data/rbi/orb/models/event_search_response.rbi +11 -2
  140. data/rbi/orb/models/event_update_params.rbi +2 -1
  141. data/rbi/orb/models/event_update_response.rbi +4 -1
  142. data/rbi/orb/models/events/backfill_close_params.rbi +4 -1
  143. data/rbi/orb/models/events/backfill_close_response.rbi +7 -1
  144. data/rbi/orb/models/events/backfill_create_params.rbi +4 -1
  145. data/rbi/orb/models/events/backfill_create_response.rbi +7 -1
  146. data/rbi/orb/models/events/backfill_fetch_params.rbi +4 -1
  147. data/rbi/orb/models/events/backfill_fetch_response.rbi +7 -1
  148. data/rbi/orb/models/events/backfill_list_params.rbi +4 -1
  149. data/rbi/orb/models/events/backfill_list_response.rbi +7 -1
  150. data/rbi/orb/models/events/backfill_revert_params.rbi +4 -1
  151. data/rbi/orb/models/events/backfill_revert_response.rbi +7 -1
  152. data/rbi/orb/models/events/event_volumes.rbi +8 -2
  153. data/rbi/orb/models/events/volume_list_params.rbi +4 -1
  154. data/rbi/orb/models/invoice.rbi +156 -31
  155. data/rbi/orb/models/invoice_create_params.rbi +13 -3
  156. data/rbi/orb/models/invoice_fetch_params.rbi +2 -1
  157. data/rbi/orb/models/invoice_fetch_upcoming_params.rbi +4 -1
  158. data/rbi/orb/models/invoice_fetch_upcoming_response.rbi +212 -31
  159. data/rbi/orb/models/invoice_issue_params.rbi +2 -1
  160. data/rbi/orb/models/invoice_line_item_create_params.rbi +4 -1
  161. data/rbi/orb/models/invoice_line_item_create_response.rbi +119 -17
  162. data/rbi/orb/models/invoice_list_params.rbi +2 -1
  163. data/rbi/orb/models/invoice_mark_paid_params.rbi +4 -1
  164. data/rbi/orb/models/invoice_pay_params.rbi +2 -1
  165. data/rbi/orb/models/invoice_update_params.rbi +2 -1
  166. data/rbi/orb/models/invoice_void_params.rbi +2 -1
  167. data/rbi/orb/models/item.rbi +5 -2
  168. data/rbi/orb/models/item_create_params.rbi +2 -1
  169. data/rbi/orb/models/item_fetch_params.rbi +2 -1
  170. data/rbi/orb/models/item_list_params.rbi +2 -1
  171. data/rbi/orb/models/item_update_params.rbi +9 -2
  172. data/rbi/orb/models/metric_create_params.rbi +2 -1
  173. data/rbi/orb/models/metric_fetch_params.rbi +2 -1
  174. data/rbi/orb/models/metric_list_params.rbi +2 -1
  175. data/rbi/orb/models/metric_update_params.rbi +2 -1
  176. data/rbi/orb/models/pagination_metadata.rbi +2 -1
  177. data/rbi/orb/models/percentage_discount.rbi +2 -1
  178. data/rbi/orb/models/plan.rbi +50 -14
  179. data/rbi/orb/models/plan_create_params.rbi +604 -89
  180. data/rbi/orb/models/plan_fetch_params.rbi +2 -1
  181. data/rbi/orb/models/plan_list_params.rbi +2 -1
  182. data/rbi/orb/models/plan_update_params.rbi +2 -1
  183. data/rbi/orb/models/plans/external_plan_id_fetch_params.rbi +4 -1
  184. data/rbi/orb/models/plans/external_plan_id_update_params.rbi +7 -1
  185. data/rbi/orb/models/price.rbi +1624 -270
  186. data/rbi/orb/models/price_create_params.rbi +100 -18
  187. data/rbi/orb/models/price_evaluate_params.rbi +2 -1
  188. data/rbi/orb/models/price_evaluate_response.rbi +4 -1
  189. data/rbi/orb/models/price_fetch_params.rbi +2 -1
  190. data/rbi/orb/models/price_list_params.rbi +2 -1
  191. data/rbi/orb/models/price_update_params.rbi +2 -1
  192. data/rbi/orb/models/prices/external_price_id_fetch_params.rbi +7 -1
  193. data/rbi/orb/models/prices/external_price_id_update_params.rbi +7 -1
  194. data/rbi/orb/models/subscription.rbi +109 -19
  195. data/rbi/orb/models/subscription_cancel_params.rbi +4 -1
  196. data/rbi/orb/models/subscription_cancel_response.rbi +137 -20
  197. data/rbi/orb/models/subscription_change_apply_params.rbi +4 -1
  198. data/rbi/orb/models/subscription_change_apply_response.rbi +142 -21
  199. data/rbi/orb/models/subscription_change_cancel_params.rbi +4 -1
  200. data/rbi/orb/models/subscription_change_cancel_response.rbi +142 -21
  201. data/rbi/orb/models/subscription_change_retrieve_params.rbi +4 -1
  202. data/rbi/orb/models/subscription_change_retrieve_response.rbi +142 -21
  203. data/rbi/orb/models/subscription_create_params.rbi +1257 -198
  204. data/rbi/orb/models/subscription_create_response.rbi +137 -20
  205. data/rbi/orb/models/subscription_fetch_costs_params.rbi +4 -1
  206. data/rbi/orb/models/subscription_fetch_costs_response.rbi +21 -3
  207. data/rbi/orb/models/subscription_fetch_params.rbi +4 -1
  208. data/rbi/orb/models/subscription_fetch_schedule_params.rbi +4 -1
  209. data/rbi/orb/models/subscription_fetch_schedule_response.rbi +14 -2
  210. data/rbi/orb/models/subscription_fetch_usage_params.rbi +4 -1
  211. data/rbi/orb/models/subscription_list_params.rbi +4 -1
  212. data/rbi/orb/models/subscription_price_intervals_params.rbi +731 -115
  213. data/rbi/orb/models/subscription_price_intervals_response.rbi +140 -20
  214. data/rbi/orb/models/subscription_schedule_plan_change_params.rbi +1260 -198
  215. data/rbi/orb/models/subscription_schedule_plan_change_response.rbi +140 -20
  216. data/rbi/orb/models/subscription_trigger_phase_params.rbi +4 -1
  217. data/rbi/orb/models/subscription_trigger_phase_response.rbi +140 -20
  218. data/rbi/orb/models/subscription_unschedule_cancellation_params.rbi +7 -1
  219. data/rbi/orb/models/subscription_unschedule_cancellation_response.rbi +140 -20
  220. data/rbi/orb/models/subscription_unschedule_fixed_fee_quantity_updates_params.rbi +7 -1
  221. data/rbi/orb/models/subscription_unschedule_fixed_fee_quantity_updates_response.rbi +140 -20
  222. data/rbi/orb/models/subscription_unschedule_pending_plan_changes_params.rbi +7 -1
  223. data/rbi/orb/models/subscription_unschedule_pending_plan_changes_response.rbi +140 -20
  224. data/rbi/orb/models/subscription_update_fixed_fee_quantity_params.rbi +7 -1
  225. data/rbi/orb/models/subscription_update_fixed_fee_quantity_response.rbi +140 -20
  226. data/rbi/orb/models/subscription_update_params.rbi +4 -1
  227. data/rbi/orb/models/subscription_update_trial_params.rbi +4 -1
  228. data/rbi/orb/models/subscription_update_trial_response.rbi +140 -20
  229. data/rbi/orb/models/subscription_usage.rbi +63 -9
  230. data/rbi/orb/models/subscriptions.rbi +2 -1
  231. data/rbi/orb/models/top_level_ping_params.rbi +2 -1
  232. data/rbi/orb/models/top_level_ping_response.rbi +4 -1
  233. data/rbi/orb/models/trial_discount.rbi +2 -1
  234. data/rbi/orb/models/usage_discount.rbi +2 -1
  235. data/rbi/orb/request_options.rbi +1 -1
  236. data/sig/orb/internal/transport/base_client.rbs +16 -1
  237. data/sig/orb/internal/transport/pooled_net_requester.rbs +2 -0
  238. data/sig/orb/internal/type/base_model.rbs +11 -5
  239. data/sig/orb/internal/type/base_page.rbs +1 -1
  240. data/sig/orb/internal/type/converter.rbs +2 -0
  241. data/sig/orb/internal/type/enum.rbs +1 -0
  242. data/sig/orb/internal/type/union.rbs +1 -0
  243. data/sig/orb/internal/util.rbs +13 -0
  244. data/sig/orb/internal.rbs +2 -0
  245. metadata +2 -2
data/lib/orb/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orb
4
- VERSION = "0.3.2"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/orb.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Standard libraries.
4
+ # rubocop:disable Lint/RedundantRequireStatement
4
5
  require "English"
5
6
  require "cgi"
6
7
  require "date"
@@ -15,6 +16,7 @@ require "set"
15
16
  require "stringio"
16
17
  require "time"
17
18
  require "uri"
19
+ # rubocop:enable Lint/RedundantRequireStatement
18
20
 
19
21
  # We already ship the preferred sorbet manifests in the package itself.
20
22
  # `tapioca` currently does not offer us a way to opt out of unnecessary compilation.
@@ -19,7 +19,8 @@ module Orb
19
19
  end
20
20
 
21
21
  class PaginationMetadata < Orb::Internal::Type::BaseModel
22
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
22
+ OrHash =
23
+ T.type_alias { T.any(PaginationMetadata, Orb::Internal::AnyHash) }
23
24
 
24
25
  sig { returns(T::Boolean) }
25
26
  attr_accessor :has_more
@@ -5,9 +5,11 @@ module Orb
5
5
  module Transport
6
6
  # @api private
7
7
  class BaseClient
8
+ extend Orb::Internal::Util::SorbetRuntimeSupport
9
+
8
10
  abstract!
9
11
 
10
- RequestComponentsShape =
12
+ RequestComponents =
11
13
  T.type_alias do
12
14
  {
13
15
  method: Symbol,
@@ -53,7 +55,7 @@ module Orb
53
55
  }
54
56
  end
55
57
 
56
- RequestInputShape =
58
+ RequestInput =
57
59
  T.type_alias do
58
60
  {
59
61
  method: Symbol,
@@ -74,7 +76,7 @@ module Orb
74
76
  # @api private
75
77
  sig do
76
78
  params(
77
- req: Orb::Internal::Transport::BaseClient::RequestComponentsShape
79
+ req: Orb::Internal::Transport::BaseClient::RequestComponents
78
80
  ).void
79
81
  end
80
82
  def validate!(req)
@@ -93,10 +95,10 @@ module Orb
93
95
  # @api private
94
96
  sig do
95
97
  params(
96
- request: Orb::Internal::Transport::BaseClient::RequestInputShape,
98
+ request: Orb::Internal::Transport::BaseClient::RequestInput,
97
99
  status: Integer,
98
100
  response_headers: T.any(T::Hash[String, String], Net::HTTPHeader)
99
- ).returns(Orb::Internal::Transport::BaseClient::RequestInputShape)
101
+ ).returns(Orb::Internal::Transport::BaseClient::RequestInput)
100
102
  end
101
103
  def follow_redirect(request, status:, response_headers:)
102
104
  end
@@ -112,6 +114,27 @@ module Orb
112
114
  end
113
115
  end
114
116
 
117
+ sig { returns(URI::Generic) }
118
+ attr_reader :base_url
119
+
120
+ sig { returns(Float) }
121
+ attr_reader :timeout
122
+
123
+ sig { returns(Integer) }
124
+ attr_reader :max_retries
125
+
126
+ sig { returns(Float) }
127
+ attr_reader :initial_retry_delay
128
+
129
+ sig { returns(Float) }
130
+ attr_reader :max_retry_delay
131
+
132
+ sig { returns(T::Hash[String, String]) }
133
+ attr_reader :headers
134
+
135
+ sig { returns(T.nilable(String)) }
136
+ attr_reader :idempotency_header
137
+
115
138
  # @api private
116
139
  sig { returns(Orb::Internal::Transport::PooledNetRequester) }
117
140
  attr_reader :requester
@@ -163,10 +186,10 @@ module Orb
163
186
  sig do
164
187
  overridable
165
188
  .params(
166
- req: Orb::Internal::Transport::BaseClient::RequestComponentsShape,
189
+ req: Orb::Internal::Transport::BaseClient::RequestComponents,
167
190
  opts: Orb::Internal::AnyHash
168
191
  )
169
- .returns(Orb::Internal::Transport::BaseClient::RequestInputShape)
192
+ .returns(Orb::Internal::Transport::BaseClient::RequestInput)
170
193
  end
171
194
  private def build_request(req, opts)
172
195
  end
@@ -184,7 +207,7 @@ module Orb
184
207
  # @api private
185
208
  sig do
186
209
  params(
187
- request: Orb::Internal::Transport::BaseClient::RequestInputShape,
210
+ request: Orb::Internal::Transport::BaseClient::RequestInput,
188
211
  redirect_count: Integer,
189
212
  retry_count: Integer,
190
213
  send_retry_header: T::Boolean
@@ -5,7 +5,9 @@ module Orb
5
5
  module Transport
6
6
  # @api private
7
7
  class PooledNetRequester
8
- RequestShape =
8
+ extend Orb::Internal::Util::SorbetRuntimeSupport
9
+
10
+ Request =
9
11
  T.type_alias do
10
12
  {
11
13
  method: Symbol,
@@ -34,8 +36,7 @@ module Orb
34
36
  # @api private
35
37
  sig do
36
38
  params(
37
- request:
38
- Orb::Internal::Transport::PooledNetRequester::RequestShape,
39
+ request: Orb::Internal::Transport::PooledNetRequester::Request,
39
40
  blk: T.proc.params(arg0: String).void
40
41
  ).returns([Net::HTTPGenericRequest, T.proc.void])
41
42
  end
@@ -57,7 +58,7 @@ module Orb
57
58
  # @api private
58
59
  sig do
59
60
  params(
60
- request: Orb::Internal::Transport::PooledNetRequester::RequestShape
61
+ request: Orb::Internal::Transport::PooledNetRequester::Request
61
62
  ).returns([Integer, Net::HTTPResponse, T::Enumerable[String]])
62
63
  end
63
64
  def execute(request)
@@ -5,10 +5,11 @@ module Orb
5
5
  module Type
6
6
  class BaseModel
7
7
  extend Orb::Internal::Type::Converter
8
+ extend Orb::Internal::Util::SorbetRuntimeSupport
8
9
 
9
10
  abstract!
10
11
 
11
- KnownFieldShape =
12
+ KnownField =
12
13
  T.type_alias do
13
14
  {
14
15
  mode: T.nilable(Symbol),
@@ -17,19 +18,27 @@ module Orb
17
18
  }
18
19
  end
19
20
 
20
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
21
+ OrHash =
22
+ T.type_alias do
23
+ T.any(Orb::Internal::Type::BaseModel, Orb::Internal::AnyHash)
24
+ end
21
25
 
22
26
  class << self
23
27
  # @api private
24
28
  #
25
29
  # Assumes superclass fields are totally defined before fields are accessed /
26
30
  # defined on subclasses.
31
+ sig { params(child: T.self_type).void }
32
+ def inherited(child)
33
+ end
34
+
35
+ # @api private
27
36
  sig do
28
37
  returns(
29
38
  T::Hash[
30
39
  Symbol,
31
40
  T.all(
32
- Orb::Internal::Type::BaseModel::KnownFieldShape,
41
+ Orb::Internal::Type::BaseModel::KnownField,
33
42
  {
34
43
  type_fn:
35
44
  T.proc.returns(Orb::Internal::Type::Converter::Input)
@@ -47,7 +56,7 @@ module Orb
47
56
  T::Hash[
48
57
  Symbol,
49
58
  T.all(
50
- Orb::Internal::Type::BaseModel::KnownFieldShape,
59
+ Orb::Internal::Type::BaseModel::KnownField,
51
60
  { type: Orb::Internal::Type::Converter::Input }
52
61
  )
53
62
  ]
@@ -183,6 +192,18 @@ module Orb
183
192
  end
184
193
  end
185
194
 
195
+ class << self
196
+ # @api private
197
+ sig do
198
+ params(
199
+ model: Orb::Internal::Type::BaseModel,
200
+ convert: T::Boolean
201
+ ).returns(Orb::Internal::AnyHash)
202
+ end
203
+ def recursively_to_h(model, convert:)
204
+ end
205
+ end
206
+
186
207
  # Returns the raw value associated with the given key, if found. Otherwise, nil is
187
208
  # returned.
188
209
  #
@@ -217,6 +238,12 @@ module Orb
217
238
  def to_hash
218
239
  end
219
240
 
241
+ # In addition to the behaviour of `#to_h`, this method will recursively call
242
+ # `#to_h` on nested models.
243
+ sig { overridable.returns(Orb::Internal::AnyHash) }
244
+ def deep_to_h
245
+ end
246
+
220
247
  sig do
221
248
  params(keys: T.nilable(T::Array[Symbol])).returns(
222
249
  Orb::Internal::AnyHash
@@ -225,17 +252,6 @@ module Orb
225
252
  def deconstruct_keys(keys)
226
253
  end
227
254
 
228
- class << self
229
- # @api private
230
- sig do
231
- params(model: Orb::Internal::Type::BaseModel).returns(
232
- Orb::Internal::AnyHash
233
- )
234
- end
235
- def walk(model)
236
- end
237
- end
238
-
239
255
  sig { params(a: T.anything).returns(String) }
240
256
  def to_json(*a)
241
257
  end
@@ -29,7 +29,7 @@ module Orb
29
29
  sig do
30
30
  params(
31
31
  client: Orb::Internal::Transport::BaseClient,
32
- req: Orb::Internal::Transport::BaseClient::RequestComponentsShape,
32
+ req: Orb::Internal::Transport::BaseClient::RequestComponents,
33
33
  headers: T.any(T::Hash[String, String], Net::HTTPHeader),
34
34
  page_data: T.anything
35
35
  ).void
@@ -5,6 +5,8 @@ module Orb
5
5
  module Type
6
6
  # @api private
7
7
  module Converter
8
+ extend Orb::Internal::Util::SorbetRuntimeSupport
9
+
8
10
  Input =
9
11
  T.type_alias do
10
12
  T.any(Orb::Internal::Type::Converter, T::Class[T.anything])
@@ -17,6 +17,7 @@ module Orb
17
17
  # values safely.
18
18
  module Enum
19
19
  include Orb::Internal::Type::Converter
20
+ include Orb::Internal::Util::SorbetRuntimeSupport
20
21
 
21
22
  # All of the valid Symbol values for this enum.
22
23
  sig do
@@ -6,6 +6,7 @@ module Orb
6
6
  # @api private
7
7
  module Union
8
8
  include Orb::Internal::Type::Converter
9
+ include Orb::Internal::Util::SorbetRuntimeSupport
9
10
 
10
11
  # @api private
11
12
  #
@@ -4,6 +4,8 @@ module Orb
4
4
  module Internal
5
5
  # @api private
6
6
  module Util
7
+ extend Orb::Internal::Util::SorbetRuntimeSupport
8
+
7
9
  # @api private
8
10
  sig { returns(Float) }
9
11
  def self.monotonic_secs
@@ -168,7 +170,7 @@ module Orb
168
170
  end
169
171
  end
170
172
 
171
- ParsedUriShape =
173
+ ParsedUri =
172
174
  T.type_alias do
173
175
  {
174
176
  scheme: T.nilable(String),
@@ -183,7 +185,7 @@ module Orb
183
185
  # @api private
184
186
  sig do
185
187
  params(url: T.any(URI::Generic, String)).returns(
186
- Orb::Internal::Util::ParsedUriShape
188
+ Orb::Internal::Util::ParsedUri
187
189
  )
188
190
  end
189
191
  def parse_uri(url)
@@ -191,9 +193,7 @@ module Orb
191
193
 
192
194
  # @api private
193
195
  sig do
194
- params(parsed: Orb::Internal::Util::ParsedUriShape).returns(
195
- URI::Generic
196
- )
196
+ params(parsed: Orb::Internal::Util::ParsedUri).returns(URI::Generic)
197
197
  end
198
198
  def unparse_uri(parsed)
199
199
  end
@@ -201,8 +201,8 @@ module Orb
201
201
  # @api private
202
202
  sig do
203
203
  params(
204
- lhs: Orb::Internal::Util::ParsedUriShape,
205
- rhs: Orb::Internal::Util::ParsedUriShape
204
+ lhs: Orb::Internal::Util::ParsedUri,
205
+ rhs: Orb::Internal::Util::ParsedUri
206
206
  ).returns(URI::Generic)
207
207
  end
208
208
  def join_parsed_uri(lhs, rhs)
@@ -419,6 +419,27 @@ module Orb
419
419
  def decode_sse(lines)
420
420
  end
421
421
  end
422
+
423
+ # @api private
424
+ module SorbetRuntimeSupport
425
+ class MissingSorbetRuntimeError < ::RuntimeError
426
+ end
427
+
428
+ # @api private
429
+ sig { returns(T::Hash[Symbol, T.anything]) }
430
+ private def sorbet_runtime_constants
431
+ end
432
+
433
+ # @api private
434
+ sig { params(name: Symbol).void }
435
+ def const_missing(name)
436
+ end
437
+
438
+ # @api private
439
+ sig { params(name: Symbol, blk: T.proc.returns(T.anything)).void }
440
+ def define_sorbet_constant!(name, &blk)
441
+ end
442
+ end
422
443
  end
423
444
  end
424
445
  end
data/rbi/orb/internal.rbi CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Orb
4
4
  module Internal
5
+ extend Orb::Internal::Util::SorbetRuntimeSupport
6
+
5
7
  # Due to the current WIP status of Shapes support in Sorbet, types referencing
6
8
  # this alias might be refined in the future.
7
9
  AnyHash = T.type_alias { T::Hash[Symbol, T.anything] }
@@ -3,7 +3,7 @@
3
3
  module Orb
4
4
  module Models
5
5
  class Alert < Orb::Internal::Type::BaseModel
6
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
6
+ OrHash = T.type_alias { T.any(Orb::Alert, Orb::Internal::AnyHash) }
7
7
 
8
8
  # Also referred to as alert_id in this documentation.
9
9
  sig { returns(String) }
@@ -124,7 +124,8 @@ module Orb
124
124
  end
125
125
 
126
126
  class Customer < Orb::Internal::Type::BaseModel
127
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
127
+ OrHash =
128
+ T.type_alias { T.any(Orb::Alert::Customer, Orb::Internal::AnyHash) }
128
129
 
129
130
  sig { returns(String) }
130
131
  attr_accessor :id
@@ -151,7 +152,8 @@ module Orb
151
152
  end
152
153
 
153
154
  class Metric < Orb::Internal::Type::BaseModel
154
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
155
+ OrHash =
156
+ T.type_alias { T.any(Orb::Alert::Metric, Orb::Internal::AnyHash) }
155
157
 
156
158
  sig { returns(String) }
157
159
  attr_accessor :id
@@ -167,7 +169,8 @@ module Orb
167
169
  end
168
170
 
169
171
  class Plan < Orb::Internal::Type::BaseModel
170
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
172
+ OrHash =
173
+ T.type_alias { T.any(Orb::Alert::Plan, Orb::Internal::AnyHash) }
171
174
 
172
175
  sig { returns(T.nilable(String)) }
173
176
  attr_accessor :id
@@ -219,7 +222,10 @@ module Orb
219
222
  end
220
223
 
221
224
  class Subscription < Orb::Internal::Type::BaseModel
222
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
225
+ OrHash =
226
+ T.type_alias do
227
+ T.any(Orb::Alert::Subscription, Orb::Internal::AnyHash)
228
+ end
223
229
 
224
230
  sig { returns(String) }
225
231
  attr_accessor :id
@@ -235,7 +241,8 @@ module Orb
235
241
  end
236
242
 
237
243
  class Threshold < Orb::Internal::Type::BaseModel
238
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
244
+ OrHash =
245
+ T.type_alias { T.any(Orb::Alert::Threshold, Orb::Internal::AnyHash) }
239
246
 
240
247
  # The value at which an alert will fire. For credit balance alerts, the alert will
241
248
  # fire at or below this value. For usage and cost alerts, the alert will fire at
@@ -6,7 +6,10 @@ module Orb
6
6
  extend Orb::Internal::Type::RequestParameters::Converter
7
7
  include Orb::Internal::Type::RequestParameters
8
8
 
9
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(Orb::AlertCreateForCustomerParams, Orb::Internal::AnyHash)
12
+ end
10
13
 
11
14
  # The case sensitive currency or custom pricing unit to use for this alert.
12
15
  sig { returns(String) }
@@ -96,7 +99,13 @@ module Orb
96
99
  end
97
100
 
98
101
  class Threshold < Orb::Internal::Type::BaseModel
99
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
102
+ OrHash =
103
+ T.type_alias do
104
+ T.any(
105
+ Orb::AlertCreateForCustomerParams::Threshold,
106
+ Orb::Internal::AnyHash
107
+ )
108
+ end
100
109
 
101
110
  # The value at which an alert will fire. For credit balance alerts, the alert will
102
111
  # fire at or below this value. For usage and cost alerts, the alert will fire at
@@ -6,7 +6,13 @@ module Orb
6
6
  extend Orb::Internal::Type::RequestParameters::Converter
7
7
  include Orb::Internal::Type::RequestParameters
8
8
 
9
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Orb::AlertCreateForExternalCustomerParams,
13
+ Orb::Internal::AnyHash
14
+ )
15
+ end
10
16
 
11
17
  # The case sensitive currency or custom pricing unit to use for this alert.
12
18
  sig { returns(String) }
@@ -104,7 +110,13 @@ module Orb
104
110
  end
105
111
 
106
112
  class Threshold < Orb::Internal::Type::BaseModel
107
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
113
+ OrHash =
114
+ T.type_alias do
115
+ T.any(
116
+ Orb::AlertCreateForExternalCustomerParams::Threshold,
117
+ Orb::Internal::AnyHash
118
+ )
119
+ end
108
120
 
109
121
  # The value at which an alert will fire. For credit balance alerts, the alert will
110
122
  # fire at or below this value. For usage and cost alerts, the alert will fire at
@@ -6,7 +6,10 @@ module Orb
6
6
  extend Orb::Internal::Type::RequestParameters::Converter
7
7
  include Orb::Internal::Type::RequestParameters
8
8
 
9
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(Orb::AlertCreateForSubscriptionParams, Orb::Internal::AnyHash)
12
+ end
10
13
 
11
14
  # The thresholds that define the values at which the alert will be triggered.
12
15
  sig do
@@ -57,7 +60,13 @@ module Orb
57
60
  end
58
61
 
59
62
  class Threshold < Orb::Internal::Type::BaseModel
60
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
63
+ OrHash =
64
+ T.type_alias do
65
+ T.any(
66
+ Orb::AlertCreateForSubscriptionParams::Threshold,
67
+ Orb::Internal::AnyHash
68
+ )
69
+ end
61
70
 
62
71
  # The value at which an alert will fire. For credit balance alerts, the alert will
63
72
  # fire at or below this value. For usage and cost alerts, the alert will fire at
@@ -6,7 +6,8 @@ module Orb
6
6
  extend Orb::Internal::Type::RequestParameters::Converter
7
7
  include Orb::Internal::Type::RequestParameters
8
8
 
9
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
9
+ OrHash =
10
+ T.type_alias { T.any(Orb::AlertDisableParams, Orb::Internal::AnyHash) }
10
11
 
11
12
  # Used to update the status of a plan alert scoped to this subscription_id
12
13
  sig { returns(T.nilable(String)) }
@@ -6,7 +6,8 @@ module Orb
6
6
  extend Orb::Internal::Type::RequestParameters::Converter
7
7
  include Orb::Internal::Type::RequestParameters
8
8
 
9
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
9
+ OrHash =
10
+ T.type_alias { T.any(Orb::AlertEnableParams, Orb::Internal::AnyHash) }
10
11
 
11
12
  # Used to update the status of a plan alert scoped to this subscription_id
12
13
  sig { returns(T.nilable(String)) }
@@ -6,7 +6,8 @@ module Orb
6
6
  extend Orb::Internal::Type::RequestParameters::Converter
7
7
  include Orb::Internal::Type::RequestParameters
8
8
 
9
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
9
+ OrHash =
10
+ T.type_alias { T.any(Orb::AlertListParams, Orb::Internal::AnyHash) }
10
11
 
11
12
  sig { returns(T.nilable(Time)) }
12
13
  attr_accessor :created_at_gt
@@ -6,7 +6,8 @@ module Orb
6
6
  extend Orb::Internal::Type::RequestParameters::Converter
7
7
  include Orb::Internal::Type::RequestParameters
8
8
 
9
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
9
+ OrHash =
10
+ T.type_alias { T.any(Orb::AlertRetrieveParams, Orb::Internal::AnyHash) }
10
11
 
11
12
  sig do
12
13
  params(request_options: Orb::RequestOptions::OrHash).returns(
@@ -6,7 +6,8 @@ module Orb
6
6
  extend Orb::Internal::Type::RequestParameters::Converter
7
7
  include Orb::Internal::Type::RequestParameters
8
8
 
9
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
9
+ OrHash =
10
+ T.type_alias { T.any(Orb::AlertUpdateParams, Orb::Internal::AnyHash) }
10
11
 
11
12
  # The thresholds that define the values at which the alert will be triggered.
12
13
  sig { returns(T::Array[Orb::AlertUpdateParams::Threshold]) }
@@ -37,7 +38,10 @@ module Orb
37
38
  end
38
39
 
39
40
  class Threshold < Orb::Internal::Type::BaseModel
40
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
41
+ OrHash =
42
+ T.type_alias do
43
+ T.any(Orb::AlertUpdateParams::Threshold, Orb::Internal::AnyHash)
44
+ end
41
45
 
42
46
  # The value at which an alert will fire. For credit balance alerts, the alert will
43
47
  # fire at or below this value. For usage and cost alerts, the alert will fire at
@@ -3,7 +3,8 @@
3
3
  module Orb
4
4
  module Models
5
5
  class AmountDiscount < Orb::Internal::Type::BaseModel
6
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
6
+ OrHash =
7
+ T.type_alias { T.any(Orb::AmountDiscount, Orb::Internal::AnyHash) }
7
8
 
8
9
  # Only available if discount_type is `amount`.
9
10
  sig { returns(String) }
@@ -3,7 +3,8 @@
3
3
  module Orb
4
4
  module Models
5
5
  class BillableMetric < Orb::Internal::Type::BaseModel
6
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
6
+ OrHash =
7
+ T.type_alias { T.any(Orb::BillableMetric, Orb::Internal::AnyHash) }
7
8
 
8
9
  sig { returns(String) }
9
10
  attr_accessor :id
@@ -3,7 +3,7 @@
3
3
  module Orb
4
4
  module Models
5
5
  class Coupon < Orb::Internal::Type::BaseModel
6
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
6
+ OrHash = T.type_alias { T.any(Orb::Coupon, Orb::Internal::AnyHash) }
7
7
 
8
8
  # Also referred to as coupon_id in this documentation.
9
9
  sig { returns(String) }
@@ -6,7 +6,8 @@ module Orb
6
6
  extend Orb::Internal::Type::RequestParameters::Converter
7
7
  include Orb::Internal::Type::RequestParameters
8
8
 
9
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
9
+ OrHash =
10
+ T.type_alias { T.any(Orb::CouponArchiveParams, Orb::Internal::AnyHash) }
10
11
 
11
12
  sig do
12
13
  params(request_options: Orb::RequestOptions::OrHash).returns(
@@ -6,7 +6,8 @@ module Orb
6
6
  extend Orb::Internal::Type::RequestParameters::Converter
7
7
  include Orb::Internal::Type::RequestParameters
8
8
 
9
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
9
+ OrHash =
10
+ T.type_alias { T.any(Orb::CouponCreateParams, Orb::Internal::AnyHash) }
10
11
 
11
12
  sig do
12
13
  returns(
@@ -89,7 +90,13 @@ module Orb
89
90
  end
90
91
 
91
92
  class Percentage < Orb::Internal::Type::BaseModel
92
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
93
+ OrHash =
94
+ T.type_alias do
95
+ T.any(
96
+ Orb::CouponCreateParams::Discount::Percentage,
97
+ Orb::Internal::AnyHash
98
+ )
99
+ end
93
100
 
94
101
  sig { returns(Symbol) }
95
102
  attr_accessor :discount_type
@@ -115,7 +122,13 @@ module Orb
115
122
  end
116
123
 
117
124
  class Amount < Orb::Internal::Type::BaseModel
118
- OrHash = T.type_alias { T.any(T.self_type, Orb::Internal::AnyHash) }
125
+ OrHash =
126
+ T.type_alias do
127
+ T.any(
128
+ Orb::CouponCreateParams::Discount::Amount,
129
+ Orb::Internal::AnyHash
130
+ )
131
+ end
119
132
 
120
133
  sig { returns(String) }
121
134
  attr_accessor :amount_discount