Skip to content

Commit ad10a69

Browse files
chore(internal): more concise handling of parameter naming conflicts (#235)
1 parent 6211751 commit ad10a69

21 files changed

+99
-102
lines changed

lib/orb/internal/type/base_model.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ def dump(value)
258258
return super
259259
end
260260

261-
is_param = singleton_class <= Orb::Internal::Type::RequestParameters::Converter
262261
acc = {}
263262

264263
coerced.each do |key, val|
@@ -267,21 +266,19 @@ def dump(value)
267266
in nil
268267
acc.store(name, super(val))
269268
else
270-
mode, type_fn = field.fetch_values(:mode, :type_fn)
269+
api_name, mode, type_fn = field.fetch_values(:api_name, :mode, :type_fn)
271270
case mode
272271
in :coerce
273272
next
274273
else
275274
target = type_fn.call
276-
api_name = is_param ? name : field.fetch(:api_name)
277275
acc.store(api_name, Orb::Internal::Type::Converter.dump(target, val))
278276
end
279277
end
280278
end
281279

282-
known_fields.each do |name, field|
283-
mode, const = field.fetch_values(:mode, :const)
284-
api_name = is_param ? name : field.fetch(:api_name)
280+
known_fields.each_value do |field|
281+
api_name, mode, const = field.fetch_values(:api_name, :mode, :const)
285282
next if mode == :coerce || acc.key?(api_name) || const == Orb::Internal::OMIT
286283
acc.store(api_name, const)
287284
end

lib/orb/models/alert_list_params.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ class AlertListParams < Orb::Internal::Type::BaseModel
1111
# @!attribute created_at_gt
1212
#
1313
# @return [Time, nil]
14-
optional :created_at_gt, Time, api_name: :"created_at[gt]", nil?: true
14+
optional :created_at_gt, Time, nil?: true
1515

1616
# @!attribute created_at_gte
1717
#
1818
# @return [Time, nil]
19-
optional :created_at_gte, Time, api_name: :"created_at[gte]", nil?: true
19+
optional :created_at_gte, Time, nil?: true
2020

2121
# @!attribute created_at_lt
2222
#
2323
# @return [Time, nil]
24-
optional :created_at_lt, Time, api_name: :"created_at[lt]", nil?: true
24+
optional :created_at_lt, Time, nil?: true
2525

2626
# @!attribute created_at_lte
2727
#
2828
# @return [Time, nil]
29-
optional :created_at_lte, Time, api_name: :"created_at[lte]", nil?: true
29+
optional :created_at_lte, Time, nil?: true
3030

3131
# @!attribute cursor
3232
# Cursor for pagination. This can be populated by the `next_cursor` value returned

lib/orb/models/credit_note_list_params.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ class CreditNoteListParams < Orb::Internal::Type::BaseModel
1111
# @!attribute created_at_gt
1212
#
1313
# @return [Time, nil]
14-
optional :created_at_gt, Time, api_name: :"created_at[gt]", nil?: true
14+
optional :created_at_gt, Time, nil?: true
1515

1616
# @!attribute created_at_gte
1717
#
1818
# @return [Time, nil]
19-
optional :created_at_gte, Time, api_name: :"created_at[gte]", nil?: true
19+
optional :created_at_gte, Time, nil?: true
2020

2121
# @!attribute created_at_lt
2222
#
2323
# @return [Time, nil]
24-
optional :created_at_lt, Time, api_name: :"created_at[lt]", nil?: true
24+
optional :created_at_lt, Time, nil?: true
2525

2626
# @!attribute created_at_lte
2727
#
2828
# @return [Time, nil]
29-
optional :created_at_lte, Time, api_name: :"created_at[lte]", nil?: true
29+
optional :created_at_lte, Time, nil?: true
3030

3131
# @!attribute cursor
3232
# Cursor for pagination. This can be populated by the `next_cursor` value returned

lib/orb/models/customer_list_params.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ class CustomerListParams < Orb::Internal::Type::BaseModel
1111
# @!attribute created_at_gt
1212
#
1313
# @return [Time, nil]
14-
optional :created_at_gt, Time, api_name: :"created_at[gt]", nil?: true
14+
optional :created_at_gt, Time, nil?: true
1515

1616
# @!attribute created_at_gte
1717
#
1818
# @return [Time, nil]
19-
optional :created_at_gte, Time, api_name: :"created_at[gte]", nil?: true
19+
optional :created_at_gte, Time, nil?: true
2020

2121
# @!attribute created_at_lt
2222
#
2323
# @return [Time, nil]
24-
optional :created_at_lt, Time, api_name: :"created_at[lt]", nil?: true
24+
optional :created_at_lt, Time, nil?: true
2525

2626
# @!attribute created_at_lte
2727
#
2828
# @return [Time, nil]
29-
optional :created_at_lte, Time, api_name: :"created_at[lte]", nil?: true
29+
optional :created_at_lte, Time, nil?: true
3030

3131
# @!attribute cursor
3232
# Cursor for pagination. This can be populated by the `next_cursor` value returned

lib/orb/models/customers/balance_transaction_list_params.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@ class BalanceTransactionListParams < Orb::Internal::Type::BaseModel
2929
# @!attribute operation_time_gt
3030
#
3131
# @return [Time, nil]
32-
optional :operation_time_gt, Time, api_name: :"operation_time[gt]", nil?: true
32+
optional :operation_time_gt, Time, nil?: true
3333

3434
# @!attribute operation_time_gte
3535
#
3636
# @return [Time, nil]
37-
optional :operation_time_gte, Time, api_name: :"operation_time[gte]", nil?: true
37+
optional :operation_time_gte, Time, nil?: true
3838

3939
# @!attribute operation_time_lt
4040
#
4141
# @return [Time, nil]
42-
optional :operation_time_lt, Time, api_name: :"operation_time[lt]", nil?: true
42+
optional :operation_time_lt, Time, nil?: true
4343

4444
# @!attribute operation_time_lte
4545
#
4646
# @return [Time, nil]
47-
optional :operation_time_lte, Time, api_name: :"operation_time[lte]", nil?: true
47+
optional :operation_time_lte, Time, nil?: true
4848

4949
# @!parse
5050
# # @param cursor [String, nil]

lib/orb/models/customers/credits/ledger_list_by_external_id_params.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ class LedgerListByExternalIDParams < Orb::Internal::Type::BaseModel
1313
# @!attribute created_at_gt
1414
#
1515
# @return [Time, nil]
16-
optional :created_at_gt, Time, api_name: :"created_at[gt]", nil?: true
16+
optional :created_at_gt, Time, nil?: true
1717

1818
# @!attribute created_at_gte
1919
#
2020
# @return [Time, nil]
21-
optional :created_at_gte, Time, api_name: :"created_at[gte]", nil?: true
21+
optional :created_at_gte, Time, nil?: true
2222

2323
# @!attribute created_at_lt
2424
#
2525
# @return [Time, nil]
26-
optional :created_at_lt, Time, api_name: :"created_at[lt]", nil?: true
26+
optional :created_at_lt, Time, nil?: true
2727

2828
# @!attribute created_at_lte
2929
#
3030
# @return [Time, nil]
31-
optional :created_at_lte, Time, api_name: :"created_at[lte]", nil?: true
31+
optional :created_at_lte, Time, nil?: true
3232

3333
# @!attribute currency
3434
# The ledger currency or custom pricing unit to use.

lib/orb/models/customers/credits/ledger_list_params.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ class LedgerListParams < Orb::Internal::Type::BaseModel
1313
# @!attribute created_at_gt
1414
#
1515
# @return [Time, nil]
16-
optional :created_at_gt, Time, api_name: :"created_at[gt]", nil?: true
16+
optional :created_at_gt, Time, nil?: true
1717

1818
# @!attribute created_at_gte
1919
#
2020
# @return [Time, nil]
21-
optional :created_at_gte, Time, api_name: :"created_at[gte]", nil?: true
21+
optional :created_at_gte, Time, nil?: true
2222

2323
# @!attribute created_at_lt
2424
#
2525
# @return [Time, nil]
26-
optional :created_at_lt, Time, api_name: :"created_at[lt]", nil?: true
26+
optional :created_at_lt, Time, nil?: true
2727

2828
# @!attribute created_at_lte
2929
#
3030
# @return [Time, nil]
31-
optional :created_at_lte, Time, api_name: :"created_at[lte]", nil?: true
31+
optional :created_at_lte, Time, nil?: true
3232

3333
# @!attribute currency
3434
# The ledger currency or custom pricing unit to use.

lib/orb/models/invoice_list_params.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ class InvoiceListParams < Orb::Internal::Type::BaseModel
1616
# @!attribute amount_gt
1717
#
1818
# @return [String, nil]
19-
optional :amount_gt, String, api_name: :"amount[gt]", nil?: true
19+
optional :amount_gt, String, nil?: true
2020

2121
# @!attribute amount_lt
2222
#
2323
# @return [String, nil]
24-
optional :amount_lt, String, api_name: :"amount[lt]", nil?: true
24+
optional :amount_lt, String, nil?: true
2525

2626
# @!attribute cursor
2727
# Cursor for pagination. This can be populated by the `next_cursor` value returned
@@ -57,12 +57,12 @@ class InvoiceListParams < Orb::Internal::Type::BaseModel
5757
# @!attribute due_date_gt
5858
#
5959
# @return [Date, nil]
60-
optional :due_date_gt, Date, api_name: :"due_date[gt]", nil?: true
60+
optional :due_date_gt, Date, nil?: true
6161

6262
# @!attribute due_date_lt
6363
#
6464
# @return [Date, nil]
65-
optional :due_date_lt, Date, api_name: :"due_date[lt]", nil?: true
65+
optional :due_date_lt, Date, nil?: true
6666

6767
# @!attribute external_customer_id
6868
#
@@ -72,22 +72,22 @@ class InvoiceListParams < Orb::Internal::Type::BaseModel
7272
# @!attribute invoice_date_gt
7373
#
7474
# @return [Time, nil]
75-
optional :invoice_date_gt, Time, api_name: :"invoice_date[gt]", nil?: true
75+
optional :invoice_date_gt, Time, nil?: true
7676

7777
# @!attribute invoice_date_gte
7878
#
7979
# @return [Time, nil]
80-
optional :invoice_date_gte, Time, api_name: :"invoice_date[gte]", nil?: true
80+
optional :invoice_date_gte, Time, nil?: true
8181

8282
# @!attribute invoice_date_lt
8383
#
8484
# @return [Time, nil]
85-
optional :invoice_date_lt, Time, api_name: :"invoice_date[lt]", nil?: true
85+
optional :invoice_date_lt, Time, nil?: true
8686

8787
# @!attribute invoice_date_lte
8888
#
8989
# @return [Time, nil]
90-
optional :invoice_date_lte, Time, api_name: :"invoice_date[lte]", nil?: true
90+
optional :invoice_date_lte, Time, nil?: true
9191

9292
# @!attribute is_recurring
9393
#

lib/orb/models/metric_list_params.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ class MetricListParams < Orb::Internal::Type::BaseModel
1111
# @!attribute created_at_gt
1212
#
1313
# @return [Time, nil]
14-
optional :created_at_gt, Time, api_name: :"created_at[gt]", nil?: true
14+
optional :created_at_gt, Time, nil?: true
1515

1616
# @!attribute created_at_gte
1717
#
1818
# @return [Time, nil]
19-
optional :created_at_gte, Time, api_name: :"created_at[gte]", nil?: true
19+
optional :created_at_gte, Time, nil?: true
2020

2121
# @!attribute created_at_lt
2222
#
2323
# @return [Time, nil]
24-
optional :created_at_lt, Time, api_name: :"created_at[lt]", nil?: true
24+
optional :created_at_lt, Time, nil?: true
2525

2626
# @!attribute created_at_lte
2727
#
2828
# @return [Time, nil]
29-
optional :created_at_lte, Time, api_name: :"created_at[lte]", nil?: true
29+
optional :created_at_lte, Time, nil?: true
3030

3131
# @!attribute cursor
3232
# Cursor for pagination. This can be populated by the `next_cursor` value returned

lib/orb/models/plan_list_params.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ class PlanListParams < Orb::Internal::Type::BaseModel
1111
# @!attribute created_at_gt
1212
#
1313
# @return [Time, nil]
14-
optional :created_at_gt, Time, api_name: :"created_at[gt]", nil?: true
14+
optional :created_at_gt, Time, nil?: true
1515

1616
# @!attribute created_at_gte
1717
#
1818
# @return [Time, nil]
19-
optional :created_at_gte, Time, api_name: :"created_at[gte]", nil?: true
19+
optional :created_at_gte, Time, nil?: true
2020

2121
# @!attribute created_at_lt
2222
#
2323
# @return [Time, nil]
24-
optional :created_at_lt, Time, api_name: :"created_at[lt]", nil?: true
24+
optional :created_at_lt, Time, nil?: true
2525

2626
# @!attribute created_at_lte
2727
#
2828
# @return [Time, nil]
29-
optional :created_at_lte, Time, api_name: :"created_at[lte]", nil?: true
29+
optional :created_at_lte, Time, nil?: true
3030

3131
# @!attribute cursor
3232
# Cursor for pagination. This can be populated by the `next_cursor` value returned

0 commit comments

Comments
 (0)