dodopayments 1.51.1 → 1.52.5

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 (101) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/README.md +1 -1
  4. data/lib/dodopayments/client.rb +8 -0
  5. data/lib/dodopayments/models/add_meter_to_price.rb +58 -0
  6. data/lib/dodopayments/models/event.rb +71 -0
  7. data/lib/dodopayments/models/event_input.rb +70 -0
  8. data/lib/dodopayments/models/invoices/payment_retrieve_refund_params.rb +16 -0
  9. data/lib/dodopayments/models/meter.rb +88 -0
  10. data/lib/dodopayments/models/meter_aggregation.rb +39 -0
  11. data/lib/dodopayments/models/meter_archive_params.rb +14 -0
  12. data/lib/dodopayments/models/meter_create_params.rb +62 -0
  13. data/lib/dodopayments/models/meter_filter.rb +482 -0
  14. data/lib/dodopayments/models/meter_list_params.rb +38 -0
  15. data/lib/dodopayments/models/{product_delete_params.rb → meter_retrieve_params.rb} +2 -2
  16. data/lib/dodopayments/models/meter_unarchive_params.rb +14 -0
  17. data/lib/dodopayments/models/payment.rb +10 -1
  18. data/lib/dodopayments/models/price.rb +122 -7
  19. data/lib/dodopayments/models/product.rb +2 -2
  20. data/lib/dodopayments/models/product_archive_params.rb +14 -0
  21. data/lib/dodopayments/models/product_create_params.rb +2 -2
  22. data/lib/dodopayments/models/product_list_response.rb +2 -2
  23. data/lib/dodopayments/models/product_update_params.rb +2 -2
  24. data/lib/dodopayments/models/subscription.rb +57 -1
  25. data/lib/dodopayments/models/subscription_retrieve_usage_history_params.rb +54 -0
  26. data/lib/dodopayments/models/subscription_retrieve_usage_history_response.rb +101 -0
  27. data/lib/dodopayments/models/usage_event_ingest_params.rb +22 -0
  28. data/lib/dodopayments/models/usage_event_ingest_response.rb +16 -0
  29. data/lib/dodopayments/models/usage_event_list_params.rb +75 -0
  30. data/lib/dodopayments/models/usage_event_retrieve_params.rb +14 -0
  31. data/lib/dodopayments/models.rb +32 -2
  32. data/lib/dodopayments/resources/invoices/payments.rb +18 -0
  33. data/lib/dodopayments/resources/meters.rb +123 -0
  34. data/lib/dodopayments/resources/products.rb +5 -5
  35. data/lib/dodopayments/resources/subscriptions.rb +74 -0
  36. data/lib/dodopayments/resources/usage_events.rb +193 -0
  37. data/lib/dodopayments/version.rb +1 -1
  38. data/lib/dodopayments.rb +21 -1
  39. data/rbi/dodopayments/client.rbi +6 -0
  40. data/rbi/dodopayments/models/add_meter_to_price.rbi +75 -0
  41. data/rbi/dodopayments/models/event.rbi +88 -0
  42. data/rbi/dodopayments/models/event_input.rbi +102 -0
  43. data/rbi/dodopayments/models/invoices/payment_retrieve_refund_params.rbi +34 -0
  44. data/rbi/dodopayments/models/meter.rbi +107 -0
  45. data/rbi/dodopayments/models/meter_aggregation.rbi +68 -0
  46. data/rbi/dodopayments/models/meter_archive_params.rbi +32 -0
  47. data/rbi/dodopayments/models/meter_create_params.rbi +92 -0
  48. data/rbi/dodopayments/models/meter_filter.rbi +1042 -0
  49. data/rbi/dodopayments/models/meter_list_params.rbi +68 -0
  50. data/rbi/dodopayments/models/{product_delete_params.rbi → meter_retrieve_params.rbi} +2 -2
  51. data/rbi/dodopayments/models/meter_unarchive_params.rbi +32 -0
  52. data/rbi/dodopayments/models/payment.rbi +10 -0
  53. data/rbi/dodopayments/models/price.rbi +153 -7
  54. data/rbi/dodopayments/models/product.rbi +2 -1
  55. data/rbi/dodopayments/models/product_archive_params.rbi +32 -0
  56. data/rbi/dodopayments/models/product_create_params.rbi +6 -3
  57. data/rbi/dodopayments/models/product_list_response.rbi +2 -1
  58. data/rbi/dodopayments/models/product_update_params.rbi +6 -3
  59. data/rbi/dodopayments/models/subscription.rbi +78 -0
  60. data/rbi/dodopayments/models/subscription_retrieve_usage_history_params.rbi +78 -0
  61. data/rbi/dodopayments/models/subscription_retrieve_usage_history_response.rbi +159 -0
  62. data/rbi/dodopayments/models/usage_event_ingest_params.rbi +46 -0
  63. data/rbi/dodopayments/models/usage_event_ingest_response.rbi +26 -0
  64. data/rbi/dodopayments/models/usage_event_list_params.rbi +119 -0
  65. data/rbi/dodopayments/models/usage_event_retrieve_params.rbi +32 -0
  66. data/rbi/dodopayments/models.rbi +33 -2
  67. data/rbi/dodopayments/resources/invoices/payments.rbi +9 -0
  68. data/rbi/dodopayments/resources/meters.rbi +102 -0
  69. data/rbi/dodopayments/resources/products.rbi +5 -3
  70. data/rbi/dodopayments/resources/subscriptions.rbi +74 -0
  71. data/rbi/dodopayments/resources/usage_events.rbi +175 -0
  72. data/sig/dodopayments/client.rbs +4 -0
  73. data/sig/dodopayments/models/add_meter_to_price.rbs +45 -0
  74. data/sig/dodopayments/models/event.rbs +53 -0
  75. data/sig/dodopayments/models/event_input.rbs +48 -0
  76. data/sig/dodopayments/models/invoices/payment_retrieve_refund_params.rbs +17 -0
  77. data/sig/dodopayments/models/meter.rbs +65 -0
  78. data/sig/dodopayments/models/meter_aggregation.rbs +35 -0
  79. data/sig/dodopayments/models/meter_archive_params.rbs +15 -0
  80. data/sig/dodopayments/models/meter_create_params.rbs +51 -0
  81. data/sig/dodopayments/models/meter_filter.rbs +417 -0
  82. data/sig/dodopayments/models/meter_list_params.rbs +38 -0
  83. data/sig/dodopayments/models/{product_delete_params.rbs → meter_retrieve_params.rbs} +2 -2
  84. data/sig/dodopayments/models/meter_unarchive_params.rbs +15 -0
  85. data/sig/dodopayments/models/payment.rbs +5 -0
  86. data/sig/dodopayments/models/price.rbs +88 -9
  87. data/sig/dodopayments/models/product_archive_params.rbs +15 -0
  88. data/sig/dodopayments/models/subscription.rbs +52 -0
  89. data/sig/dodopayments/models/subscription_retrieve_usage_history_params.rbs +46 -0
  90. data/sig/dodopayments/models/subscription_retrieve_usage_history_response.rbs +82 -0
  91. data/sig/dodopayments/models/usage_event_ingest_params.rbs +24 -0
  92. data/sig/dodopayments/models/usage_event_ingest_response.rbs +13 -0
  93. data/sig/dodopayments/models/usage_event_list_params.rbs +70 -0
  94. data/sig/dodopayments/models/usage_event_retrieve_params.rbs +15 -0
  95. data/sig/dodopayments/models.rbs +32 -2
  96. data/sig/dodopayments/resources/invoices/payments.rbs +5 -0
  97. data/sig/dodopayments/resources/meters.rbs +39 -0
  98. data/sig/dodopayments/resources/products.rbs +1 -1
  99. data/sig/dodopayments/resources/subscriptions.rbs +10 -0
  100. data/sig/dodopayments/resources/usage_events.rbs +28 -0
  101. metadata +65 -5
@@ -0,0 +1,68 @@
1
+ # typed: strong
2
+
3
+ module Dodopayments
4
+ module Models
5
+ class MeterListParams < Dodopayments::Internal::Type::BaseModel
6
+ extend Dodopayments::Internal::Type::RequestParameters::Converter
7
+ include Dodopayments::Internal::Type::RequestParameters
8
+
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(Dodopayments::MeterListParams, Dodopayments::Internal::AnyHash)
12
+ end
13
+
14
+ # List archived meters
15
+ sig { returns(T.nilable(T::Boolean)) }
16
+ attr_reader :archived
17
+
18
+ sig { params(archived: T::Boolean).void }
19
+ attr_writer :archived
20
+
21
+ # Page number default is 0
22
+ sig { returns(T.nilable(Integer)) }
23
+ attr_reader :page_number
24
+
25
+ sig { params(page_number: Integer).void }
26
+ attr_writer :page_number
27
+
28
+ # Page size default is 10 max is 100
29
+ sig { returns(T.nilable(Integer)) }
30
+ attr_reader :page_size
31
+
32
+ sig { params(page_size: Integer).void }
33
+ attr_writer :page_size
34
+
35
+ sig do
36
+ params(
37
+ archived: T::Boolean,
38
+ page_number: Integer,
39
+ page_size: Integer,
40
+ request_options: Dodopayments::RequestOptions::OrHash
41
+ ).returns(T.attached_class)
42
+ end
43
+ def self.new(
44
+ # List archived meters
45
+ archived: nil,
46
+ # Page number default is 0
47
+ page_number: nil,
48
+ # Page size default is 10 max is 100
49
+ page_size: nil,
50
+ request_options: {}
51
+ )
52
+ end
53
+
54
+ sig do
55
+ override.returns(
56
+ {
57
+ archived: T::Boolean,
58
+ page_number: Integer,
59
+ page_size: Integer,
60
+ request_options: Dodopayments::RequestOptions
61
+ }
62
+ )
63
+ end
64
+ def to_hash
65
+ end
66
+ end
67
+ end
68
+ end
@@ -2,14 +2,14 @@
2
2
 
3
3
  module Dodopayments
4
4
  module Models
5
- class ProductDeleteParams < Dodopayments::Internal::Type::BaseModel
5
+ class MeterRetrieveParams < Dodopayments::Internal::Type::BaseModel
6
6
  extend Dodopayments::Internal::Type::RequestParameters::Converter
7
7
  include Dodopayments::Internal::Type::RequestParameters
8
8
 
9
9
  OrHash =
10
10
  T.type_alias do
11
11
  T.any(
12
- Dodopayments::ProductDeleteParams,
12
+ Dodopayments::MeterRetrieveParams,
13
13
  Dodopayments::Internal::AnyHash
14
14
  )
15
15
  end
@@ -0,0 +1,32 @@
1
+ # typed: strong
2
+
3
+ module Dodopayments
4
+ module Models
5
+ class MeterUnarchiveParams < Dodopayments::Internal::Type::BaseModel
6
+ extend Dodopayments::Internal::Type::RequestParameters::Converter
7
+ include Dodopayments::Internal::Type::RequestParameters
8
+
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Dodopayments::MeterUnarchiveParams,
13
+ Dodopayments::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ sig do
18
+ params(request_options: Dodopayments::RequestOptions::OrHash).returns(
19
+ T.attached_class
20
+ )
21
+ end
22
+ def self.new(request_options: {})
23
+ end
24
+
25
+ sig do
26
+ override.returns({ request_options: Dodopayments::RequestOptions })
27
+ end
28
+ def to_hash
29
+ end
30
+ end
31
+ end
32
+ end
@@ -93,6 +93,11 @@ module Dodopayments
93
93
  sig { returns(T.nilable(String)) }
94
94
  attr_accessor :card_type
95
95
 
96
+ # If payment is made using a checkout session, this field is set to the id of the
97
+ # session.
98
+ sig { returns(T.nilable(String)) }
99
+ attr_accessor :checkout_session_id
100
+
96
101
  # The discount id if discount is applied
97
102
  sig { returns(T.nilable(String)) }
98
103
  attr_accessor :discount_id
@@ -163,6 +168,7 @@ module Dodopayments
163
168
  card_last_four: T.nilable(String),
164
169
  card_network: T.nilable(String),
165
170
  card_type: T.nilable(String),
171
+ checkout_session_id: T.nilable(String),
166
172
  discount_id: T.nilable(String),
167
173
  error_code: T.nilable(String),
168
174
  error_message: T.nilable(String),
@@ -220,6 +226,9 @@ module Dodopayments
220
226
  card_network: nil,
221
227
  # The type of card DEBIT or CREDIT
222
228
  card_type: nil,
229
+ # If payment is made using a checkout session, this field is set to the id of the
230
+ # session.
231
+ checkout_session_id: nil,
223
232
  # The discount id if discount is applied
224
233
  discount_id: nil,
225
234
  # An error code if the payment failed
@@ -271,6 +280,7 @@ module Dodopayments
271
280
  card_last_four: T.nilable(String),
272
281
  card_network: T.nilable(String),
273
282
  card_type: T.nilable(String),
283
+ checkout_session_id: T.nilable(String),
274
284
  discount_id: T.nilable(String),
275
285
  error_code: T.nilable(String),
276
286
  error_message: T.nilable(String),
@@ -10,7 +10,8 @@ module Dodopayments
10
10
  T.type_alias do
11
11
  T.any(
12
12
  Dodopayments::Price::OneTimePrice,
13
- Dodopayments::Price::RecurringPrice
13
+ Dodopayments::Price::RecurringPrice,
14
+ Dodopayments::Price::UsageBasedPrice
14
15
  )
15
16
  end
16
17
 
@@ -28,7 +29,7 @@ module Dodopayments
28
29
  attr_accessor :currency
29
30
 
30
31
  # Discount applied to the price, represented as a percentage (0 to 100).
31
- sig { returns(Float) }
32
+ sig { returns(Integer) }
32
33
  attr_accessor :discount
33
34
 
34
35
  # The payment amount, in the smallest denomination of the currency (e.g., cents
@@ -69,7 +70,7 @@ module Dodopayments
69
70
  sig do
70
71
  params(
71
72
  currency: Dodopayments::Currency::OrSymbol,
72
- discount: Float,
73
+ discount: Integer,
73
74
  price: Integer,
74
75
  purchasing_power_parity: T::Boolean,
75
76
  type: Dodopayments::Price::OneTimePrice::Type::OrSymbol,
@@ -109,7 +110,7 @@ module Dodopayments
109
110
  override.returns(
110
111
  {
111
112
  currency: Dodopayments::Currency::OrSymbol,
112
- discount: Float,
113
+ discount: Integer,
113
114
  price: Integer,
114
115
  purchasing_power_parity: T::Boolean,
115
116
  type: Dodopayments::Price::OneTimePrice::Type::OrSymbol,
@@ -161,7 +162,7 @@ module Dodopayments
161
162
  attr_accessor :currency
162
163
 
163
164
  # Discount applied to the price, represented as a percentage (0 to 100).
164
- sig { returns(Float) }
165
+ sig { returns(Integer) }
165
166
  attr_accessor :discount
166
167
 
167
168
  # Number of units for the payment frequency. For example, a value of `1` with a
@@ -210,7 +211,7 @@ module Dodopayments
210
211
  sig do
211
212
  params(
212
213
  currency: Dodopayments::Currency::OrSymbol,
213
- discount: Float,
214
+ discount: Integer,
214
215
  payment_frequency_count: Integer,
215
216
  payment_frequency_interval: Dodopayments::TimeInterval::OrSymbol,
216
217
  price: Integer,
@@ -255,7 +256,7 @@ module Dodopayments
255
256
  override.returns(
256
257
  {
257
258
  currency: Dodopayments::Currency::OrSymbol,
258
- discount: Float,
259
+ discount: Integer,
259
260
  payment_frequency_count: Integer,
260
261
  payment_frequency_interval: Dodopayments::TimeInterval::OrSymbol,
261
262
  price: Integer,
@@ -297,6 +298,151 @@ module Dodopayments
297
298
  end
298
299
  end
299
300
 
301
+ class UsageBasedPrice < Dodopayments::Internal::Type::BaseModel
302
+ OrHash =
303
+ T.type_alias do
304
+ T.any(
305
+ Dodopayments::Price::UsageBasedPrice,
306
+ Dodopayments::Internal::AnyHash
307
+ )
308
+ end
309
+
310
+ # The currency in which the payment is made.
311
+ sig { returns(Dodopayments::Currency::OrSymbol) }
312
+ attr_accessor :currency
313
+
314
+ # Discount applied to the price, represented as a percentage (0 to 100).
315
+ sig { returns(Integer) }
316
+ attr_accessor :discount
317
+
318
+ # The fixed payment amount. Represented in the lowest denomination of the currency
319
+ # (e.g., cents for USD). For example, to charge $1.00, pass `100`.
320
+ sig { returns(Integer) }
321
+ attr_accessor :fixed_price
322
+
323
+ # Number of units for the payment frequency. For example, a value of `1` with a
324
+ # `payment_frequency_interval` of `month` represents monthly payments.
325
+ sig { returns(Integer) }
326
+ attr_accessor :payment_frequency_count
327
+
328
+ # The time interval for the payment frequency (e.g., day, month, year).
329
+ sig { returns(Dodopayments::TimeInterval::OrSymbol) }
330
+ attr_accessor :payment_frequency_interval
331
+
332
+ # Indicates if purchasing power parity adjustments are applied to the price.
333
+ # Purchasing power parity feature is not available as of now
334
+ sig { returns(T::Boolean) }
335
+ attr_accessor :purchasing_power_parity
336
+
337
+ # Number of units for the subscription period. For example, a value of `12` with a
338
+ # `subscription_period_interval` of `month` represents a one-year subscription.
339
+ sig { returns(Integer) }
340
+ attr_accessor :subscription_period_count
341
+
342
+ # The time interval for the subscription period (e.g., day, month, year).
343
+ sig { returns(Dodopayments::TimeInterval::OrSymbol) }
344
+ attr_accessor :subscription_period_interval
345
+
346
+ sig { returns(Dodopayments::Price::UsageBasedPrice::Type::OrSymbol) }
347
+ attr_accessor :type
348
+
349
+ sig { returns(T.nilable(T::Array[Dodopayments::AddMeterToPrice])) }
350
+ attr_accessor :meters
351
+
352
+ # Indicates if the price is tax inclusive
353
+ sig { returns(T.nilable(T::Boolean)) }
354
+ attr_accessor :tax_inclusive
355
+
356
+ # Usage Based price details.
357
+ sig do
358
+ params(
359
+ currency: Dodopayments::Currency::OrSymbol,
360
+ discount: Integer,
361
+ fixed_price: Integer,
362
+ payment_frequency_count: Integer,
363
+ payment_frequency_interval: Dodopayments::TimeInterval::OrSymbol,
364
+ purchasing_power_parity: T::Boolean,
365
+ subscription_period_count: Integer,
366
+ subscription_period_interval: Dodopayments::TimeInterval::OrSymbol,
367
+ type: Dodopayments::Price::UsageBasedPrice::Type::OrSymbol,
368
+ meters: T.nilable(T::Array[Dodopayments::AddMeterToPrice::OrHash]),
369
+ tax_inclusive: T.nilable(T::Boolean)
370
+ ).returns(T.attached_class)
371
+ end
372
+ def self.new(
373
+ # The currency in which the payment is made.
374
+ currency:,
375
+ # Discount applied to the price, represented as a percentage (0 to 100).
376
+ discount:,
377
+ # The fixed payment amount. Represented in the lowest denomination of the currency
378
+ # (e.g., cents for USD). For example, to charge $1.00, pass `100`.
379
+ fixed_price:,
380
+ # Number of units for the payment frequency. For example, a value of `1` with a
381
+ # `payment_frequency_interval` of `month` represents monthly payments.
382
+ payment_frequency_count:,
383
+ # The time interval for the payment frequency (e.g., day, month, year).
384
+ payment_frequency_interval:,
385
+ # Indicates if purchasing power parity adjustments are applied to the price.
386
+ # Purchasing power parity feature is not available as of now
387
+ purchasing_power_parity:,
388
+ # Number of units for the subscription period. For example, a value of `12` with a
389
+ # `subscription_period_interval` of `month` represents a one-year subscription.
390
+ subscription_period_count:,
391
+ # The time interval for the subscription period (e.g., day, month, year).
392
+ subscription_period_interval:,
393
+ type:,
394
+ meters: nil,
395
+ # Indicates if the price is tax inclusive
396
+ tax_inclusive: nil
397
+ )
398
+ end
399
+
400
+ sig do
401
+ override.returns(
402
+ {
403
+ currency: Dodopayments::Currency::OrSymbol,
404
+ discount: Integer,
405
+ fixed_price: Integer,
406
+ payment_frequency_count: Integer,
407
+ payment_frequency_interval: Dodopayments::TimeInterval::OrSymbol,
408
+ purchasing_power_parity: T::Boolean,
409
+ subscription_period_count: Integer,
410
+ subscription_period_interval:
411
+ Dodopayments::TimeInterval::OrSymbol,
412
+ type: Dodopayments::Price::UsageBasedPrice::Type::OrSymbol,
413
+ meters: T.nilable(T::Array[Dodopayments::AddMeterToPrice]),
414
+ tax_inclusive: T.nilable(T::Boolean)
415
+ }
416
+ )
417
+ end
418
+ def to_hash
419
+ end
420
+
421
+ module Type
422
+ extend Dodopayments::Internal::Type::Enum
423
+
424
+ TaggedSymbol =
425
+ T.type_alias do
426
+ T.all(Symbol, Dodopayments::Price::UsageBasedPrice::Type)
427
+ end
428
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
429
+
430
+ USAGE_BASED_PRICE =
431
+ T.let(
432
+ :usage_based_price,
433
+ Dodopayments::Price::UsageBasedPrice::Type::TaggedSymbol
434
+ )
435
+
436
+ sig do
437
+ override.returns(
438
+ T::Array[Dodopayments::Price::UsageBasedPrice::Type::TaggedSymbol]
439
+ )
440
+ end
441
+ def self.values
442
+ end
443
+ end
444
+ end
445
+
300
446
  sig { override.returns(T::Array[Dodopayments::Price::Variants]) }
301
447
  def self.variants
302
448
  end
@@ -105,7 +105,8 @@ module Dodopayments
105
105
  price:
106
106
  T.any(
107
107
  Dodopayments::Price::OneTimePrice::OrHash,
108
- Dodopayments::Price::RecurringPrice::OrHash
108
+ Dodopayments::Price::RecurringPrice::OrHash,
109
+ Dodopayments::Price::UsageBasedPrice::OrHash
109
110
  ),
110
111
  product_id: String,
111
112
  tax_category: Dodopayments::TaxCategory::OrSymbol,
@@ -0,0 +1,32 @@
1
+ # typed: strong
2
+
3
+ module Dodopayments
4
+ module Models
5
+ class ProductArchiveParams < Dodopayments::Internal::Type::BaseModel
6
+ extend Dodopayments::Internal::Type::RequestParameters::Converter
7
+ include Dodopayments::Internal::Type::RequestParameters
8
+
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Dodopayments::ProductArchiveParams,
13
+ Dodopayments::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ sig do
18
+ params(request_options: Dodopayments::RequestOptions::OrHash).returns(
19
+ T.attached_class
20
+ )
21
+ end
22
+ def self.new(request_options: {})
23
+ end
24
+
25
+ sig do
26
+ override.returns({ request_options: Dodopayments::RequestOptions })
27
+ end
28
+ def to_hash
29
+ end
30
+ end
31
+ end
32
+ end
@@ -19,7 +19,8 @@ module Dodopayments
19
19
  returns(
20
20
  T.any(
21
21
  Dodopayments::Price::OneTimePrice,
22
- Dodopayments::Price::RecurringPrice
22
+ Dodopayments::Price::RecurringPrice,
23
+ Dodopayments::Price::UsageBasedPrice
23
24
  )
24
25
  )
25
26
  end
@@ -101,7 +102,8 @@ module Dodopayments
101
102
  price:
102
103
  T.any(
103
104
  Dodopayments::Price::OneTimePrice::OrHash,
104
- Dodopayments::Price::RecurringPrice::OrHash
105
+ Dodopayments::Price::RecurringPrice::OrHash,
106
+ Dodopayments::Price::UsageBasedPrice::OrHash
105
107
  ),
106
108
  tax_category: Dodopayments::TaxCategory::OrSymbol,
107
109
  addons: T.nilable(T::Array[String]),
@@ -158,7 +160,8 @@ module Dodopayments
158
160
  price:
159
161
  T.any(
160
162
  Dodopayments::Price::OneTimePrice,
161
- Dodopayments::Price::RecurringPrice
163
+ Dodopayments::Price::RecurringPrice,
164
+ Dodopayments::Price::UsageBasedPrice
162
165
  ),
163
166
  tax_category: Dodopayments::TaxCategory::OrSymbol,
164
167
  addons: T.nilable(T::Array[String]),
@@ -94,7 +94,8 @@ module Dodopayments
94
94
  T.nilable(
95
95
  T.any(
96
96
  Dodopayments::Price::OneTimePrice::OrHash,
97
- Dodopayments::Price::RecurringPrice::OrHash
97
+ Dodopayments::Price::RecurringPrice::OrHash,
98
+ Dodopayments::Price::UsageBasedPrice::OrHash
98
99
  )
99
100
  ),
100
101
  tax_inclusive: T.nilable(T::Boolean)
@@ -97,7 +97,8 @@ module Dodopayments
97
97
  T.nilable(
98
98
  T.any(
99
99
  Dodopayments::Price::OneTimePrice,
100
- Dodopayments::Price::RecurringPrice
100
+ Dodopayments::Price::RecurringPrice,
101
+ Dodopayments::Price::UsageBasedPrice
101
102
  )
102
103
  )
103
104
  )
@@ -129,7 +130,8 @@ module Dodopayments
129
130
  T.nilable(
130
131
  T.any(
131
132
  Dodopayments::Price::OneTimePrice::OrHash,
132
- Dodopayments::Price::RecurringPrice::OrHash
133
+ Dodopayments::Price::RecurringPrice::OrHash,
134
+ Dodopayments::Price::UsageBasedPrice::OrHash
133
135
  )
134
136
  ),
135
137
  tax_category: T.nilable(Dodopayments::TaxCategory::OrSymbol),
@@ -199,7 +201,8 @@ module Dodopayments
199
201
  T.nilable(
200
202
  T.any(
201
203
  Dodopayments::Price::OneTimePrice,
202
- Dodopayments::Price::RecurringPrice
204
+ Dodopayments::Price::RecurringPrice,
205
+ Dodopayments::Price::UsageBasedPrice
203
206
  )
204
207
  ),
205
208
  tax_category: T.nilable(Dodopayments::TaxCategory::OrSymbol),
@@ -44,6 +44,10 @@ module Dodopayments
44
44
  sig { returns(T::Hash[Symbol, String]) }
45
45
  attr_accessor :metadata
46
46
 
47
+ # Meters associated with this subscription (for usage-based billing)
48
+ sig { returns(T::Array[Dodopayments::Subscription::Meter]) }
49
+ attr_accessor :meters
50
+
47
51
  # Timestamp of the next scheduled billing. Indicates the end of current billing
48
52
  # period
49
53
  sig { returns(Time) }
@@ -128,6 +132,7 @@ module Dodopayments
128
132
  currency: Dodopayments::Currency::OrSymbol,
129
133
  customer: Dodopayments::CustomerLimitedDetails::OrHash,
130
134
  metadata: T::Hash[Symbol, String],
135
+ meters: T::Array[Dodopayments::Subscription::Meter::OrHash],
131
136
  next_billing_date: Time,
132
137
  on_demand: T::Boolean,
133
138
  payment_frequency_count: Integer,
@@ -163,6 +168,8 @@ module Dodopayments
163
168
  customer:,
164
169
  # Additional custom data associated with the subscription
165
170
  metadata:,
171
+ # Meters associated with this subscription (for usage-based billing)
172
+ meters:,
166
173
  # Timestamp of the next scheduled billing. Indicates the end of current billing
167
174
  # period
168
175
  next_billing_date:,
@@ -214,6 +221,7 @@ module Dodopayments
214
221
  currency: Dodopayments::Currency::TaggedSymbol,
215
222
  customer: Dodopayments::CustomerLimitedDetails,
216
223
  metadata: T::Hash[Symbol, String],
224
+ meters: T::Array[Dodopayments::Subscription::Meter],
217
225
  next_billing_date: Time,
218
226
  on_demand: T::Boolean,
219
227
  payment_frequency_count: Integer,
@@ -239,6 +247,76 @@ module Dodopayments
239
247
  end
240
248
  def to_hash
241
249
  end
250
+
251
+ class Meter < Dodopayments::Internal::Type::BaseModel
252
+ OrHash =
253
+ T.type_alias do
254
+ T.any(
255
+ Dodopayments::Subscription::Meter,
256
+ Dodopayments::Internal::AnyHash
257
+ )
258
+ end
259
+
260
+ sig { returns(Dodopayments::Currency::TaggedSymbol) }
261
+ attr_accessor :currency
262
+
263
+ sig { returns(Integer) }
264
+ attr_accessor :free_threshold
265
+
266
+ sig { returns(String) }
267
+ attr_accessor :measurement_unit
268
+
269
+ sig { returns(String) }
270
+ attr_accessor :meter_id
271
+
272
+ sig { returns(String) }
273
+ attr_accessor :name
274
+
275
+ sig { returns(String) }
276
+ attr_accessor :price_per_unit
277
+
278
+ sig { returns(T.nilable(String)) }
279
+ attr_accessor :description
280
+
281
+ # Response struct representing usage-based meter cart details for a subscription
282
+ sig do
283
+ params(
284
+ currency: Dodopayments::Currency::OrSymbol,
285
+ free_threshold: Integer,
286
+ measurement_unit: String,
287
+ meter_id: String,
288
+ name: String,
289
+ price_per_unit: String,
290
+ description: T.nilable(String)
291
+ ).returns(T.attached_class)
292
+ end
293
+ def self.new(
294
+ currency:,
295
+ free_threshold:,
296
+ measurement_unit:,
297
+ meter_id:,
298
+ name:,
299
+ price_per_unit:,
300
+ description: nil
301
+ )
302
+ end
303
+
304
+ sig do
305
+ override.returns(
306
+ {
307
+ currency: Dodopayments::Currency::TaggedSymbol,
308
+ free_threshold: Integer,
309
+ measurement_unit: String,
310
+ meter_id: String,
311
+ name: String,
312
+ price_per_unit: String,
313
+ description: T.nilable(String)
314
+ }
315
+ )
316
+ end
317
+ def to_hash
318
+ end
319
+ end
242
320
  end
243
321
  end
244
322
  end
@@ -0,0 +1,78 @@
1
+ # typed: strong
2
+
3
+ module Dodopayments
4
+ module Models
5
+ class SubscriptionRetrieveUsageHistoryParams < Dodopayments::Internal::Type::BaseModel
6
+ extend Dodopayments::Internal::Type::RequestParameters::Converter
7
+ include Dodopayments::Internal::Type::RequestParameters
8
+
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Dodopayments::SubscriptionRetrieveUsageHistoryParams,
13
+ Dodopayments::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ # Filter by end date (inclusive)
18
+ sig { returns(T.nilable(Time)) }
19
+ attr_accessor :end_date
20
+
21
+ # Filter by specific meter ID
22
+ sig { returns(T.nilable(String)) }
23
+ attr_accessor :meter_id
24
+
25
+ # Page number (default: 0)
26
+ sig { returns(T.nilable(Integer)) }
27
+ attr_accessor :page_number
28
+
29
+ # Page size (default: 10, max: 100)
30
+ sig { returns(T.nilable(Integer)) }
31
+ attr_accessor :page_size
32
+
33
+ # Filter by start date (inclusive)
34
+ sig { returns(T.nilable(Time)) }
35
+ attr_accessor :start_date
36
+
37
+ sig do
38
+ params(
39
+ end_date: T.nilable(Time),
40
+ meter_id: T.nilable(String),
41
+ page_number: T.nilable(Integer),
42
+ page_size: T.nilable(Integer),
43
+ start_date: T.nilable(Time),
44
+ request_options: Dodopayments::RequestOptions::OrHash
45
+ ).returns(T.attached_class)
46
+ end
47
+ def self.new(
48
+ # Filter by end date (inclusive)
49
+ end_date: nil,
50
+ # Filter by specific meter ID
51
+ meter_id: nil,
52
+ # Page number (default: 0)
53
+ page_number: nil,
54
+ # Page size (default: 10, max: 100)
55
+ page_size: nil,
56
+ # Filter by start date (inclusive)
57
+ start_date: nil,
58
+ request_options: {}
59
+ )
60
+ end
61
+
62
+ sig do
63
+ override.returns(
64
+ {
65
+ end_date: T.nilable(Time),
66
+ meter_id: T.nilable(String),
67
+ page_number: T.nilable(Integer),
68
+ page_size: T.nilable(Integer),
69
+ start_date: T.nilable(Time),
70
+ request_options: Dodopayments::RequestOptions
71
+ }
72
+ )
73
+ end
74
+ def to_hash
75
+ end
76
+ end
77
+ end
78
+ end