orb-billing 0.9.0 → 0.10.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.
data/lib/orb/models.rb CHANGED
@@ -11,16 +11,16 @@ module Orb
11
11
  mod.constants.each do |name|
12
12
  case mod.const_get(name)
13
13
  in true | false
14
- mod.define_sorbet_constant!(:TaggedBoolean) { T.type_alias { T.all(T::Boolean, mod) } }
14
+ mod.define_sorbet_constant!(:TaggedBoolean) { T.type_alias { T::Boolean } }
15
15
  mod.define_sorbet_constant!(:OrBoolean) { T.type_alias { T::Boolean } }
16
16
  in Integer
17
- mod.define_sorbet_constant!(:TaggedInteger) { T.type_alias { T.all(Integer, mod) } }
17
+ mod.define_sorbet_constant!(:TaggedInteger) { T.type_alias { Integer } }
18
18
  mod.define_sorbet_constant!(:OrInteger) { T.type_alias { Integer } }
19
19
  in Float
20
- mod.define_sorbet_constant!(:TaggedFloat) { T.type_alias { T.all(Float, mod) } }
20
+ mod.define_sorbet_constant!(:TaggedFloat) { T.type_alias { Float } }
21
21
  mod.define_sorbet_constant!(:OrFloat) { T.type_alias { Float } }
22
22
  in Symbol
23
- mod.define_sorbet_constant!(:TaggedSymbol) { T.type_alias { T.all(Symbol, mod) } }
23
+ mod.define_sorbet_constant!(:TaggedSymbol) { T.type_alias { Symbol } }
24
24
  mod.define_sorbet_constant!(:OrSymbol) { T.type_alias { T.any(Symbol, String) } }
25
25
  else
26
26
  end
@@ -244,6 +244,8 @@ module Orb
244
244
 
245
245
  SubscriptionPriceIntervalsParams = Orb::Models::SubscriptionPriceIntervalsParams
246
246
 
247
+ SubscriptionRedeemCouponParams = Orb::Models::SubscriptionRedeemCouponParams
248
+
247
249
  SubscriptionsAPI = Orb::Models::SubscriptionsAPI
248
250
 
249
251
  SubscriptionSchedulePlanChangeParams = Orb::Models::SubscriptionSchedulePlanChangeParams
@@ -982,6 +982,39 @@ module Orb
982
982
  )
983
983
  end
984
984
 
985
+ # Some parameter documentations has been truncated, see
986
+ # {Orb::Models::SubscriptionRedeemCouponParams} for more details.
987
+ #
988
+ # Redeem a coupon effective at a given time.
989
+ #
990
+ # @overload redeem_coupon(subscription_id, change_option:, coupon_id:, allow_invoice_credit_or_void: nil, change_date: nil, request_options: {})
991
+ #
992
+ # @param subscription_id [String]
993
+ #
994
+ # @param change_option [Symbol, Orb::Models::SubscriptionRedeemCouponParams::ChangeOption]
995
+ #
996
+ # @param coupon_id [String] Coupon ID to be redeemed for this subscription.
997
+ #
998
+ # @param allow_invoice_credit_or_void [Boolean, nil] If false, this request will fail if it would void an issued invoice or create a
999
+ #
1000
+ # @param change_date [Time, nil] The date that the coupon discount should take effect. This parameter can only be
1001
+ #
1002
+ # @param request_options [Orb::RequestOptions, Hash{Symbol=>Object}, nil]
1003
+ #
1004
+ # @return [Orb::Models::SubscriptionRedeemCouponResponse]
1005
+ #
1006
+ # @see Orb::Models::SubscriptionRedeemCouponParams
1007
+ def redeem_coupon(subscription_id, params)
1008
+ parsed, options = Orb::SubscriptionRedeemCouponParams.dump_request(params)
1009
+ @client.request(
1010
+ method: :post,
1011
+ path: ["subscriptions/%1$s/redeem_coupon", subscription_id],
1012
+ body: parsed,
1013
+ model: Orb::Models::SubscriptionRedeemCouponResponse,
1014
+ options: options
1015
+ )
1016
+ end
1017
+
985
1018
  # Some parameter documentations has been truncated, see
986
1019
  # {Orb::Models::SubscriptionSchedulePlanChangeParams} for more details.
987
1020
  #
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.9.0"
4
+ VERSION = "0.10.0"
5
5
  end
data/lib/orb.rb CHANGED
@@ -213,6 +213,8 @@ require_relative "orb/models/subscription_fetch_usage_params"
213
213
  require_relative "orb/models/subscription_list_params"
214
214
  require_relative "orb/models/subscription_price_intervals_params"
215
215
  require_relative "orb/models/subscription_price_intervals_response"
216
+ require_relative "orb/models/subscription_redeem_coupon_params"
217
+ require_relative "orb/models/subscription_redeem_coupon_response"
216
218
  require_relative "orb/models/subscriptions"
217
219
  require_relative "orb/models/subscription_schedule_plan_change_params"
218
220
  require_relative "orb/models/subscription_schedule_plan_change_response"
@@ -1646,7 +1646,7 @@ module Orb
1646
1646
  #
1647
1647
  # For more on the types of prices, see
1648
1648
  # [the core concepts documentation](/core-concepts#plan-and-price)
1649
- sig { returns(T.nilable(Orb::Price::Variants)) }
1649
+ sig { returns(Orb::Price::Variants) }
1650
1650
  attr_accessor :price
1651
1651
 
1652
1652
  # Either the fixed fee quantity or the usage during the service period.
@@ -1710,37 +1710,35 @@ module Orb
1710
1710
  name: String,
1711
1711
  partially_invoiced_amount: String,
1712
1712
  price:
1713
- T.nilable(
1714
- T.any(
1715
- Orb::Price::Unit::OrHash,
1716
- Orb::Price::Package::OrHash,
1717
- Orb::Price::Matrix::OrHash,
1718
- Orb::Price::Tiered::OrHash,
1719
- Orb::Price::TieredBps::OrHash,
1720
- Orb::Price::Bps::OrHash,
1721
- Orb::Price::BulkBps::OrHash,
1722
- Orb::Price::Bulk::OrHash,
1723
- Orb::Price::ThresholdTotalAmount::OrHash,
1724
- Orb::Price::TieredPackage::OrHash,
1725
- Orb::Price::GroupedTiered::OrHash,
1726
- Orb::Price::TieredWithMinimum::OrHash,
1727
- Orb::Price::TieredPackageWithMinimum::OrHash,
1728
- Orb::Price::PackageWithAllocation::OrHash,
1729
- Orb::Price::UnitWithPercent::OrHash,
1730
- Orb::Price::MatrixWithAllocation::OrHash,
1731
- Orb::Price::TieredWithProration::OrHash,
1732
- Orb::Price::UnitWithProration::OrHash,
1733
- Orb::Price::GroupedAllocation::OrHash,
1734
- Orb::Price::GroupedWithProratedMinimum::OrHash,
1735
- Orb::Price::GroupedWithMeteredMinimum::OrHash,
1736
- Orb::Price::MatrixWithDisplayName::OrHash,
1737
- Orb::Price::BulkWithProration::OrHash,
1738
- Orb::Price::GroupedTieredPackage::OrHash,
1739
- Orb::Price::MaxGroupTieredPackage::OrHash,
1740
- Orb::Price::ScalableMatrixWithUnitPricing::OrHash,
1741
- Orb::Price::ScalableMatrixWithTieredPricing::OrHash,
1742
- Orb::Price::CumulativeGroupedBulk::OrHash
1743
- )
1713
+ T.any(
1714
+ Orb::Price::Unit::OrHash,
1715
+ Orb::Price::Package::OrHash,
1716
+ Orb::Price::Matrix::OrHash,
1717
+ Orb::Price::Tiered::OrHash,
1718
+ Orb::Price::TieredBps::OrHash,
1719
+ Orb::Price::Bps::OrHash,
1720
+ Orb::Price::BulkBps::OrHash,
1721
+ Orb::Price::Bulk::OrHash,
1722
+ Orb::Price::ThresholdTotalAmount::OrHash,
1723
+ Orb::Price::TieredPackage::OrHash,
1724
+ Orb::Price::GroupedTiered::OrHash,
1725
+ Orb::Price::TieredWithMinimum::OrHash,
1726
+ Orb::Price::TieredPackageWithMinimum::OrHash,
1727
+ Orb::Price::PackageWithAllocation::OrHash,
1728
+ Orb::Price::UnitWithPercent::OrHash,
1729
+ Orb::Price::MatrixWithAllocation::OrHash,
1730
+ Orb::Price::TieredWithProration::OrHash,
1731
+ Orb::Price::UnitWithProration::OrHash,
1732
+ Orb::Price::GroupedAllocation::OrHash,
1733
+ Orb::Price::GroupedWithProratedMinimum::OrHash,
1734
+ Orb::Price::GroupedWithMeteredMinimum::OrHash,
1735
+ Orb::Price::MatrixWithDisplayName::OrHash,
1736
+ Orb::Price::BulkWithProration::OrHash,
1737
+ Orb::Price::GroupedTieredPackage::OrHash,
1738
+ Orb::Price::MaxGroupTieredPackage::OrHash,
1739
+ Orb::Price::ScalableMatrixWithUnitPricing::OrHash,
1740
+ Orb::Price::ScalableMatrixWithTieredPricing::OrHash,
1741
+ Orb::Price::CumulativeGroupedBulk::OrHash
1744
1742
  ),
1745
1743
  quantity: Float,
1746
1744
  start_date: Time,
@@ -1840,7 +1838,7 @@ module Orb
1840
1838
  minimum_amount: T.nilable(String),
1841
1839
  name: String,
1842
1840
  partially_invoiced_amount: String,
1843
- price: T.nilable(Orb::Price::Variants),
1841
+ price: Orb::Price::Variants,
1844
1842
  quantity: Float,
1845
1843
  start_date: Time,
1846
1844
  sub_line_items:
@@ -2421,7 +2421,7 @@ module Orb
2421
2421
  #
2422
2422
  # For more on the types of prices, see
2423
2423
  # [the core concepts documentation](/core-concepts#plan-and-price)
2424
- sig { returns(T.nilable(Orb::Price::Variants)) }
2424
+ sig { returns(Orb::Price::Variants) }
2425
2425
  attr_accessor :price
2426
2426
 
2427
2427
  # Either the fixed fee quantity or the usage during the service period.
@@ -2503,37 +2503,35 @@ module Orb
2503
2503
  name: String,
2504
2504
  partially_invoiced_amount: String,
2505
2505
  price:
2506
- T.nilable(
2507
- T.any(
2508
- Orb::Price::Unit::OrHash,
2509
- Orb::Price::Package::OrHash,
2510
- Orb::Price::Matrix::OrHash,
2511
- Orb::Price::Tiered::OrHash,
2512
- Orb::Price::TieredBps::OrHash,
2513
- Orb::Price::Bps::OrHash,
2514
- Orb::Price::BulkBps::OrHash,
2515
- Orb::Price::Bulk::OrHash,
2516
- Orb::Price::ThresholdTotalAmount::OrHash,
2517
- Orb::Price::TieredPackage::OrHash,
2518
- Orb::Price::GroupedTiered::OrHash,
2519
- Orb::Price::TieredWithMinimum::OrHash,
2520
- Orb::Price::TieredPackageWithMinimum::OrHash,
2521
- Orb::Price::PackageWithAllocation::OrHash,
2522
- Orb::Price::UnitWithPercent::OrHash,
2523
- Orb::Price::MatrixWithAllocation::OrHash,
2524
- Orb::Price::TieredWithProration::OrHash,
2525
- Orb::Price::UnitWithProration::OrHash,
2526
- Orb::Price::GroupedAllocation::OrHash,
2527
- Orb::Price::GroupedWithProratedMinimum::OrHash,
2528
- Orb::Price::GroupedWithMeteredMinimum::OrHash,
2529
- Orb::Price::MatrixWithDisplayName::OrHash,
2530
- Orb::Price::BulkWithProration::OrHash,
2531
- Orb::Price::GroupedTieredPackage::OrHash,
2532
- Orb::Price::MaxGroupTieredPackage::OrHash,
2533
- Orb::Price::ScalableMatrixWithUnitPricing::OrHash,
2534
- Orb::Price::ScalableMatrixWithTieredPricing::OrHash,
2535
- Orb::Price::CumulativeGroupedBulk::OrHash
2536
- )
2506
+ T.any(
2507
+ Orb::Price::Unit::OrHash,
2508
+ Orb::Price::Package::OrHash,
2509
+ Orb::Price::Matrix::OrHash,
2510
+ Orb::Price::Tiered::OrHash,
2511
+ Orb::Price::TieredBps::OrHash,
2512
+ Orb::Price::Bps::OrHash,
2513
+ Orb::Price::BulkBps::OrHash,
2514
+ Orb::Price::Bulk::OrHash,
2515
+ Orb::Price::ThresholdTotalAmount::OrHash,
2516
+ Orb::Price::TieredPackage::OrHash,
2517
+ Orb::Price::GroupedTiered::OrHash,
2518
+ Orb::Price::TieredWithMinimum::OrHash,
2519
+ Orb::Price::TieredPackageWithMinimum::OrHash,
2520
+ Orb::Price::PackageWithAllocation::OrHash,
2521
+ Orb::Price::UnitWithPercent::OrHash,
2522
+ Orb::Price::MatrixWithAllocation::OrHash,
2523
+ Orb::Price::TieredWithProration::OrHash,
2524
+ Orb::Price::UnitWithProration::OrHash,
2525
+ Orb::Price::GroupedAllocation::OrHash,
2526
+ Orb::Price::GroupedWithProratedMinimum::OrHash,
2527
+ Orb::Price::GroupedWithMeteredMinimum::OrHash,
2528
+ Orb::Price::MatrixWithDisplayName::OrHash,
2529
+ Orb::Price::BulkWithProration::OrHash,
2530
+ Orb::Price::GroupedTieredPackage::OrHash,
2531
+ Orb::Price::MaxGroupTieredPackage::OrHash,
2532
+ Orb::Price::ScalableMatrixWithUnitPricing::OrHash,
2533
+ Orb::Price::ScalableMatrixWithTieredPricing::OrHash,
2534
+ Orb::Price::CumulativeGroupedBulk::OrHash
2537
2535
  ),
2538
2536
  quantity: Float,
2539
2537
  start_date: Time,
@@ -2644,7 +2642,7 @@ module Orb
2644
2642
  minimum_amount: T.nilable(String),
2645
2643
  name: String,
2646
2644
  partially_invoiced_amount: String,
2647
- price: T.nilable(Orb::Price::Variants),
2645
+ price: Orb::Price::Variants,
2648
2646
  quantity: Float,
2649
2647
  start_date: Time,
2650
2648
  sub_line_items:
@@ -116,7 +116,7 @@ module Orb
116
116
  #
117
117
  # For more on the types of prices, see
118
118
  # [the core concepts documentation](/core-concepts#plan-and-price)
119
- sig { returns(T.nilable(Orb::Price::Variants)) }
119
+ sig { returns(Orb::Price::Variants) }
120
120
  attr_accessor :price
121
121
 
122
122
  # Either the fixed fee quantity or the usage during the service period.
@@ -194,37 +194,35 @@ module Orb
194
194
  name: String,
195
195
  partially_invoiced_amount: String,
196
196
  price:
197
- T.nilable(
198
- T.any(
199
- Orb::Price::Unit::OrHash,
200
- Orb::Price::Package::OrHash,
201
- Orb::Price::Matrix::OrHash,
202
- Orb::Price::Tiered::OrHash,
203
- Orb::Price::TieredBps::OrHash,
204
- Orb::Price::Bps::OrHash,
205
- Orb::Price::BulkBps::OrHash,
206
- Orb::Price::Bulk::OrHash,
207
- Orb::Price::ThresholdTotalAmount::OrHash,
208
- Orb::Price::TieredPackage::OrHash,
209
- Orb::Price::GroupedTiered::OrHash,
210
- Orb::Price::TieredWithMinimum::OrHash,
211
- Orb::Price::TieredPackageWithMinimum::OrHash,
212
- Orb::Price::PackageWithAllocation::OrHash,
213
- Orb::Price::UnitWithPercent::OrHash,
214
- Orb::Price::MatrixWithAllocation::OrHash,
215
- Orb::Price::TieredWithProration::OrHash,
216
- Orb::Price::UnitWithProration::OrHash,
217
- Orb::Price::GroupedAllocation::OrHash,
218
- Orb::Price::GroupedWithProratedMinimum::OrHash,
219
- Orb::Price::GroupedWithMeteredMinimum::OrHash,
220
- Orb::Price::MatrixWithDisplayName::OrHash,
221
- Orb::Price::BulkWithProration::OrHash,
222
- Orb::Price::GroupedTieredPackage::OrHash,
223
- Orb::Price::MaxGroupTieredPackage::OrHash,
224
- Orb::Price::ScalableMatrixWithUnitPricing::OrHash,
225
- Orb::Price::ScalableMatrixWithTieredPricing::OrHash,
226
- Orb::Price::CumulativeGroupedBulk::OrHash
227
- )
197
+ T.any(
198
+ Orb::Price::Unit::OrHash,
199
+ Orb::Price::Package::OrHash,
200
+ Orb::Price::Matrix::OrHash,
201
+ Orb::Price::Tiered::OrHash,
202
+ Orb::Price::TieredBps::OrHash,
203
+ Orb::Price::Bps::OrHash,
204
+ Orb::Price::BulkBps::OrHash,
205
+ Orb::Price::Bulk::OrHash,
206
+ Orb::Price::ThresholdTotalAmount::OrHash,
207
+ Orb::Price::TieredPackage::OrHash,
208
+ Orb::Price::GroupedTiered::OrHash,
209
+ Orb::Price::TieredWithMinimum::OrHash,
210
+ Orb::Price::TieredPackageWithMinimum::OrHash,
211
+ Orb::Price::PackageWithAllocation::OrHash,
212
+ Orb::Price::UnitWithPercent::OrHash,
213
+ Orb::Price::MatrixWithAllocation::OrHash,
214
+ Orb::Price::TieredWithProration::OrHash,
215
+ Orb::Price::UnitWithProration::OrHash,
216
+ Orb::Price::GroupedAllocation::OrHash,
217
+ Orb::Price::GroupedWithProratedMinimum::OrHash,
218
+ Orb::Price::GroupedWithMeteredMinimum::OrHash,
219
+ Orb::Price::MatrixWithDisplayName::OrHash,
220
+ Orb::Price::BulkWithProration::OrHash,
221
+ Orb::Price::GroupedTieredPackage::OrHash,
222
+ Orb::Price::MaxGroupTieredPackage::OrHash,
223
+ Orb::Price::ScalableMatrixWithUnitPricing::OrHash,
224
+ Orb::Price::ScalableMatrixWithTieredPricing::OrHash,
225
+ Orb::Price::CumulativeGroupedBulk::OrHash
228
226
  ),
229
227
  quantity: Float,
230
228
  start_date: Time,
@@ -331,7 +329,7 @@ module Orb
331
329
  minimum_amount: T.nilable(String),
332
330
  name: String,
333
331
  partially_invoiced_amount: String,
334
- price: T.nilable(Orb::Price::Variants),
332
+ price: Orb::Price::Variants,
335
333
  quantity: Float,
336
334
  start_date: Time,
337
335
  sub_line_items:
@@ -0,0 +1,111 @@
1
+ # typed: strong
2
+
3
+ module Orb
4
+ module Models
5
+ class SubscriptionRedeemCouponParams < Orb::Internal::Type::BaseModel
6
+ extend Orb::Internal::Type::RequestParameters::Converter
7
+ include Orb::Internal::Type::RequestParameters
8
+
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(Orb::SubscriptionRedeemCouponParams, Orb::Internal::AnyHash)
12
+ end
13
+
14
+ sig do
15
+ returns(Orb::SubscriptionRedeemCouponParams::ChangeOption::OrSymbol)
16
+ end
17
+ attr_accessor :change_option
18
+
19
+ # Coupon ID to be redeemed for this subscription.
20
+ sig { returns(String) }
21
+ attr_accessor :coupon_id
22
+
23
+ # If false, this request will fail if it would void an issued invoice or create a
24
+ # credit note. Consider using this as a safety mechanism if you do not expect
25
+ # existing invoices to be changed.
26
+ sig { returns(T.nilable(T::Boolean)) }
27
+ attr_accessor :allow_invoice_credit_or_void
28
+
29
+ # The date that the coupon discount should take effect. This parameter can only be
30
+ # passed if the `change_option` is `requested_date`.
31
+ sig { returns(T.nilable(Time)) }
32
+ attr_accessor :change_date
33
+
34
+ sig do
35
+ params(
36
+ change_option:
37
+ Orb::SubscriptionRedeemCouponParams::ChangeOption::OrSymbol,
38
+ coupon_id: String,
39
+ allow_invoice_credit_or_void: T.nilable(T::Boolean),
40
+ change_date: T.nilable(Time),
41
+ request_options: Orb::RequestOptions::OrHash
42
+ ).returns(T.attached_class)
43
+ end
44
+ def self.new(
45
+ change_option:,
46
+ # Coupon ID to be redeemed for this subscription.
47
+ coupon_id:,
48
+ # If false, this request will fail if it would void an issued invoice or create a
49
+ # credit note. Consider using this as a safety mechanism if you do not expect
50
+ # existing invoices to be changed.
51
+ allow_invoice_credit_or_void: nil,
52
+ # The date that the coupon discount should take effect. This parameter can only be
53
+ # passed if the `change_option` is `requested_date`.
54
+ change_date: nil,
55
+ request_options: {}
56
+ )
57
+ end
58
+
59
+ sig do
60
+ override.returns(
61
+ {
62
+ change_option:
63
+ Orb::SubscriptionRedeemCouponParams::ChangeOption::OrSymbol,
64
+ coupon_id: String,
65
+ allow_invoice_credit_or_void: T.nilable(T::Boolean),
66
+ change_date: T.nilable(Time),
67
+ request_options: Orb::RequestOptions
68
+ }
69
+ )
70
+ end
71
+ def to_hash
72
+ end
73
+
74
+ module ChangeOption
75
+ extend Orb::Internal::Type::Enum
76
+
77
+ TaggedSymbol =
78
+ T.type_alias do
79
+ T.all(Symbol, Orb::SubscriptionRedeemCouponParams::ChangeOption)
80
+ end
81
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
82
+
83
+ REQUESTED_DATE =
84
+ T.let(
85
+ :requested_date,
86
+ Orb::SubscriptionRedeemCouponParams::ChangeOption::TaggedSymbol
87
+ )
88
+ END_OF_SUBSCRIPTION_TERM =
89
+ T.let(
90
+ :end_of_subscription_term,
91
+ Orb::SubscriptionRedeemCouponParams::ChangeOption::TaggedSymbol
92
+ )
93
+ IMMEDIATE =
94
+ T.let(
95
+ :immediate,
96
+ Orb::SubscriptionRedeemCouponParams::ChangeOption::TaggedSymbol
97
+ )
98
+
99
+ sig do
100
+ override.returns(
101
+ T::Array[
102
+ Orb::SubscriptionRedeemCouponParams::ChangeOption::TaggedSymbol
103
+ ]
104
+ )
105
+ end
106
+ def self.values
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end