Skip to content

Commit 85ddf12

Browse files
chore(internal): annotate request options with type aliases in sorbet
1 parent 5528e59 commit 85ddf12

29 files changed

+111
-295
lines changed

rbi/orb/internal/transport/base_client.rbi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module Orb
3535
page: T.nilable(T::Class[Orb::Internal::Type::BasePage[Orb::Internal::Type::BaseModel]]),
3636
stream: T.nilable(T::Class[T.anything]),
3737
model: T.nilable(Orb::Internal::Type::Converter::Input),
38-
options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
38+
options: T.nilable(Orb::RequestOpts)
3939
}
4040
end
4141

@@ -185,7 +185,7 @@ module Orb
185185
page: T.nilable(T::Class[Orb::Internal::Type::BasePage[Orb::Internal::Type::BaseModel]]),
186186
stream: T.nilable(T::Class[T.anything]),
187187
model: T.nilable(Orb::Internal::Type::Converter::Input),
188-
options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
188+
options: T.nilable(Orb::RequestOpts)
189189
)
190190
.returns(T.anything)
191191
end

rbi/orb/internal/type/request_parameters.rbi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Orb
66
# @api private
77
module RequestParameters
88
# Options to specify HTTP behaviour for this request.
9-
sig { returns(T.any(Orb::RequestOptions, Orb::Internal::AnyHash)) }
9+
sig { returns(Orb::RequestOpts) }
1010
attr_accessor :request_options
1111

1212
# @api private

rbi/orb/request_options.rbi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# typed: strong
22

33
module Orb
4+
RequestOpts = T.type_alias { T.any(Orb::RequestOptions, Orb::Internal::AnyHash) }
5+
46
# Specify HTTP behaviour to use for a specific request. These options supplement
57
# or override those provided at the client level.
68
#

rbi/orb/resources/alerts.rbi

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,15 @@ module Orb
44
module Resources
55
class Alerts
66
# This endpoint retrieves an alert by its ID.
7-
sig do
8-
params(
9-
alert_id: String,
10-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
11-
)
12-
.returns(Orb::Models::Alert)
13-
end
7+
sig { params(alert_id: String, request_options: Orb::RequestOpts).returns(Orb::Models::Alert) }
148
def retrieve(alert_id, request_options: {}); end
159

1610
# This endpoint updates the thresholds of an alert.
1711
sig do
1812
params(
1913
alert_configuration_id: String,
2014
thresholds: T::Array[T.any(Orb::Models::AlertUpdateParams::Threshold, Orb::Internal::AnyHash)],
21-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
15+
request_options: Orb::RequestOpts
2216
)
2317
.returns(Orb::Models::Alert)
2418
end
@@ -50,7 +44,7 @@ module Orb
5044
external_customer_id: T.nilable(String),
5145
limit: Integer,
5246
subscription_id: T.nilable(String),
53-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
47+
request_options: Orb::RequestOpts
5448
)
5549
.returns(Orb::Internal::Page[Orb::Models::Alert])
5650
end
@@ -86,7 +80,7 @@ module Orb
8680
currency: String,
8781
type: Orb::Models::AlertCreateForCustomerParams::Type::OrSymbol,
8882
thresholds: T.nilable(T::Array[T.any(Orb::Models::AlertCreateForCustomerParams::Threshold, Orb::Internal::AnyHash)]),
89-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
83+
request_options: Orb::RequestOpts
9084
)
9185
.returns(Orb::Models::Alert)
9286
end
@@ -116,7 +110,7 @@ module Orb
116110
thresholds: T.nilable(
117111
T::Array[T.any(Orb::Models::AlertCreateForExternalCustomerParams::Threshold, Orb::Internal::AnyHash)]
118112
),
119-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
113+
request_options: Orb::RequestOpts
120114
)
121115
.returns(Orb::Models::Alert)
122116
end
@@ -147,7 +141,7 @@ module Orb
147141
thresholds: T::Array[T.any(Orb::Models::AlertCreateForSubscriptionParams::Threshold, Orb::Internal::AnyHash)],
148142
type: Orb::Models::AlertCreateForSubscriptionParams::Type::OrSymbol,
149143
metric_id: T.nilable(String),
150-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
144+
request_options: Orb::RequestOpts
151145
)
152146
.returns(Orb::Models::Alert)
153147
end
@@ -168,7 +162,7 @@ module Orb
168162
params(
169163
alert_configuration_id: String,
170164
subscription_id: T.nilable(String),
171-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
165+
request_options: Orb::RequestOpts
172166
)
173167
.returns(Orb::Models::Alert)
174168
end
@@ -185,7 +179,7 @@ module Orb
185179
params(
186180
alert_configuration_id: String,
187181
subscription_id: T.nilable(String),
188-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
182+
request_options: Orb::RequestOpts
189183
)
190184
.returns(Orb::Models::Alert)
191185
end

rbi/orb/resources/coupons.rbi

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module Orb
1818
redemption_code: String,
1919
duration_in_months: T.nilable(Integer),
2020
max_redemptions: T.nilable(Integer),
21-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
21+
request_options: Orb::RequestOpts
2222
)
2323
.returns(Orb::Models::Coupon)
2424
end
@@ -46,7 +46,7 @@ module Orb
4646
limit: Integer,
4747
redemption_code: T.nilable(String),
4848
show_archived: T.nilable(T::Boolean),
49-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
49+
request_options: Orb::RequestOpts
5050
)
5151
.returns(Orb::Internal::Page[Orb::Models::Coupon])
5252
end
@@ -66,25 +66,13 @@ module Orb
6666
# This endpoint allows a coupon to be archived. Archived coupons can no longer be
6767
# redeemed, and will be hidden from lists of active coupons. Additionally, once a
6868
# coupon is archived, its redemption code can be reused for a different coupon.
69-
sig do
70-
params(
71-
coupon_id: String,
72-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
73-
)
74-
.returns(Orb::Models::Coupon)
75-
end
69+
sig { params(coupon_id: String, request_options: Orb::RequestOpts).returns(Orb::Models::Coupon) }
7670
def archive(coupon_id, request_options: {}); end
7771

7872
# This endpoint retrieves a coupon by its ID. To fetch coupons by their redemption
7973
# code, use the [List coupons](list-coupons) endpoint with the redemption_code
8074
# parameter.
81-
sig do
82-
params(
83-
coupon_id: String,
84-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
85-
)
86-
.returns(Orb::Models::Coupon)
87-
end
75+
sig { params(coupon_id: String, request_options: Orb::RequestOpts).returns(Orb::Models::Coupon) }
8876
def fetch(coupon_id, request_options: {}); end
8977

9078
# @api private

rbi/orb/resources/coupons/subscriptions.rbi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module Orb
1313
coupon_id: String,
1414
cursor: T.nilable(String),
1515
limit: Integer,
16-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
16+
request_options: Orb::RequestOpts
1717
)
1818
.returns(Orb::Internal::Page[Orb::Models::Subscription])
1919
end

rbi/orb/resources/credit_notes.rbi

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Orb
1010
line_items: T::Array[T.any(Orb::Models::CreditNoteCreateParams::LineItem, Orb::Internal::AnyHash)],
1111
memo: T.nilable(String),
1212
reason: T.nilable(Orb::Models::CreditNoteCreateParams::Reason::OrSymbol),
13-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
13+
request_options: Orb::RequestOpts
1414
)
1515
.returns(Orb::Models::CreditNote)
1616
end
@@ -33,7 +33,7 @@ module Orb
3333
created_at_lte: T.nilable(Time),
3434
cursor: T.nilable(String),
3535
limit: Integer,
36-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
36+
request_options: Orb::RequestOpts
3737
)
3838
.returns(Orb::Internal::Page[Orb::Models::CreditNote])
3939
end
@@ -51,13 +51,7 @@ module Orb
5151
); end
5252
# This endpoint is used to fetch a single [`Credit Note`](/invoicing/credit-notes)
5353
# given an identifier.
54-
sig do
55-
params(
56-
credit_note_id: String,
57-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
58-
)
59-
.returns(Orb::Models::CreditNote)
60-
end
54+
sig { params(credit_note_id: String, request_options: Orb::RequestOpts).returns(Orb::Models::CreditNote) }
6155
def fetch(credit_note_id, request_options: {}); end
6256

6357
# @api private

rbi/orb/resources/customers.rbi

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module Orb
5050
),
5151
tax_id: T.nilable(T.any(Orb::Models::CustomerCreateParams::TaxID, Orb::Internal::AnyHash)),
5252
timezone: T.nilable(String),
53-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
53+
request_options: Orb::RequestOpts
5454
)
5555
.returns(Orb::Models::Customer)
5656
end
@@ -237,7 +237,7 @@ module Orb
237237
)
238238
),
239239
tax_id: T.nilable(T.any(Orb::Models::CustomerUpdateParams::TaxID, Orb::Internal::AnyHash)),
240-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
240+
request_options: Orb::RequestOpts
241241
)
242242
.returns(Orb::Models::Customer)
243243
end
@@ -405,7 +405,7 @@ module Orb
405405
created_at_lte: T.nilable(Time),
406406
cursor: T.nilable(String),
407407
limit: Integer,
408-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
408+
request_options: Orb::RequestOpts
409409
)
410410
.returns(Orb::Internal::Page[Orb::Models::Customer])
411411
end
@@ -436,13 +436,7 @@ module Orb
436436
# been fully processed, the customer will not be returned in the API.
437437
#
438438
# On successful processing, this returns an empty dictionary (`{}`) in the API.
439-
sig do
440-
params(
441-
customer_id: String,
442-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
443-
)
444-
.void
445-
end
439+
sig { params(customer_id: String, request_options: Orb::RequestOpts).void }
446440
def delete(customer_id, request_options: {}); end
447441

448442
# This endpoint is used to fetch customer details given an identifier. If the
@@ -451,27 +445,15 @@ module Orb
451445
#
452446
# See the [Customer resource](/core-concepts#customer) for a full discussion of
453447
# the Customer model.
454-
sig do
455-
params(
456-
customer_id: String,
457-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
458-
)
459-
.returns(Orb::Models::Customer)
460-
end
448+
sig { params(customer_id: String, request_options: Orb::RequestOpts).returns(Orb::Models::Customer) }
461449
def fetch(customer_id, request_options: {}); end
462450

463451
# This endpoint is used to fetch customer details given an `external_customer_id`
464452
# (see [Customer ID Aliases](/events-and-metrics/customer-aliases)).
465453
#
466454
# Note that the resource and semantics of this endpoint exactly mirror
467455
# [Get Customer](fetch-customer).
468-
sig do
469-
params(
470-
external_customer_id: String,
471-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
472-
)
473-
.returns(Orb::Models::Customer)
474-
end
456+
sig { params(external_customer_id: String, request_options: Orb::RequestOpts).returns(Orb::Models::Customer) }
475457
def fetch_by_external_id(external_customer_id, request_options: {}); end
476458

477459
# Sync Orb's payment methods for the customer with their gateway.
@@ -480,13 +462,7 @@ module Orb
480462
# be charged, ensuring that the most up-to-date payment method is charged.
481463
#
482464
# **Note**: This functionality is currently only available for Stripe.
483-
sig do
484-
params(
485-
customer_id: String,
486-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
487-
)
488-
.void
489-
end
465+
sig { params(customer_id: String, request_options: Orb::RequestOpts).void }
490466
def sync_payment_methods_from_gateway(customer_id, request_options: {}); end
491467

492468
# Sync Orb's payment methods for the customer with their gateway.
@@ -495,13 +471,7 @@ module Orb
495471
# be charged, ensuring that the most up-to-date payment method is charged.
496472
#
497473
# **Note**: This functionality is currently only available for Stripe.
498-
sig do
499-
params(
500-
external_customer_id: String,
501-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
502-
)
503-
.void
504-
end
474+
sig { params(external_customer_id: String, request_options: Orb::RequestOpts).void }
505475
def sync_payment_methods_from_gateway_by_external_customer_id(
506476
external_customer_id,
507477
request_options: {}
@@ -542,7 +512,7 @@ module Orb
542512
)
543513
),
544514
tax_id: T.nilable(T.any(Orb::Models::CustomerUpdateByExternalIDParams::TaxID, Orb::Internal::AnyHash)),
545-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
515+
request_options: Orb::RequestOpts
546516
)
547517
.returns(Orb::Models::Customer)
548518
end

rbi/orb/resources/customers/balance_transactions.rbi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module Orb
1212
amount: String,
1313
type: Orb::Models::Customers::BalanceTransactionCreateParams::Type::OrSymbol,
1414
description: T.nilable(String),
15-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
15+
request_options: Orb::RequestOpts
1616
)
1717
.returns(Orb::Models::Customers::BalanceTransactionCreateResponse)
1818
end
@@ -61,7 +61,7 @@ module Orb
6161
operation_time_gte: T.nilable(Time),
6262
operation_time_lt: T.nilable(Time),
6363
operation_time_lte: T.nilable(Time),
64-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
64+
request_options: Orb::RequestOpts
6565
)
6666
.returns(Orb::Internal::Page[Orb::Models::Customers::BalanceTransactionListResponse])
6767
end

rbi/orb/resources/customers/costs.rbi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ module Orb
128128
timeframe_end: T.nilable(Time),
129129
timeframe_start: T.nilable(Time),
130130
view_mode: T.nilable(Orb::Models::Customers::CostListParams::ViewMode::OrSymbol),
131-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
131+
request_options: Orb::RequestOpts
132132
)
133133
.returns(Orb::Models::Customers::CostListResponse)
134134
end
@@ -271,7 +271,7 @@ module Orb
271271
timeframe_end: T.nilable(Time),
272272
timeframe_start: T.nilable(Time),
273273
view_mode: T.nilable(Orb::Models::Customers::CostListByExternalIDParams::ViewMode::OrSymbol),
274-
request_options: T.nilable(T.any(Orb::RequestOptions, Orb::Internal::AnyHash))
274+
request_options: Orb::RequestOpts
275275
)
276276
.returns(Orb::Models::Customers::CostListByExternalIDResponse)
277277
end

0 commit comments

Comments
 (0)