orb-billing 0.10.0 → 0.12.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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +32 -0
  3. data/README.md +1 -1
  4. data/lib/orb/internal/type/union.rb +3 -8
  5. data/lib/orb/internal/util.rb +8 -9
  6. data/lib/orb/models/amount_discount.rb +65 -1
  7. data/lib/orb/models/beta/external_plan_id_create_plan_version_params.rb +1437 -15
  8. data/lib/orb/models/beta_create_plan_version_params.rb +1435 -15
  9. data/lib/orb/models/percentage_discount.rb +65 -1
  10. data/lib/orb/models/subscription_create_params.rb +1435 -15
  11. data/lib/orb/models/subscription_price_intervals_params.rb +715 -5
  12. data/lib/orb/models/subscription_redeem_coupon_params.rb +17 -9
  13. data/lib/orb/models/subscription_schedule_plan_change_params.rb +1435 -15
  14. data/lib/orb/models/trial_discount.rb +65 -1
  15. data/lib/orb/models/usage_discount.rb +65 -1
  16. data/lib/orb/resources/subscriptions.rb +6 -4
  17. data/lib/orb/version.rb +1 -1
  18. data/rbi/orb/internal/util.rbi +2 -0
  19. data/rbi/orb/models/amount_discount.rbi +117 -0
  20. data/rbi/orb/models/beta/external_plan_id_create_plan_version_params.rbi +6145 -3045
  21. data/rbi/orb/models/beta_create_plan_version_params.rbi +6096 -2996
  22. data/rbi/orb/models/percentage_discount.rbi +131 -0
  23. data/rbi/orb/models/subscription_create_params.rbi +6037 -2937
  24. data/rbi/orb/models/subscription_price_intervals_params.rbi +1633 -83
  25. data/rbi/orb/models/subscription_redeem_coupon_params.rbi +16 -8
  26. data/rbi/orb/models/subscription_schedule_plan_change_params.rbi +6948 -3848
  27. data/rbi/orb/models/trial_discount.rbi +109 -0
  28. data/rbi/orb/models/usage_discount.rbi +109 -0
  29. data/rbi/orb/resources/subscriptions.rbi +7 -4
  30. data/sig/orb/models/amount_discount.rbs +58 -0
  31. data/sig/orb/models/beta/external_plan_id_create_plan_version_params.rbs +1130 -20
  32. data/sig/orb/models/beta_create_plan_version_params.rbs +1130 -20
  33. data/sig/orb/models/percentage_discount.rbs +58 -0
  34. data/sig/orb/models/subscription_create_params.rbs +1130 -20
  35. data/sig/orb/models/subscription_price_intervals_params.rbs +565 -10
  36. data/sig/orb/models/subscription_redeem_coupon_params.rbs +11 -6
  37. data/sig/orb/models/subscription_schedule_plan_change_params.rbs +1130 -20
  38. data/sig/orb/models/trial_discount.rbs +58 -0
  39. data/sig/orb/models/usage_discount.rbs +58 -0
  40. data/sig/orb/resources/subscriptions.rbs +2 -1
  41. metadata +2 -2
@@ -14,6 +14,10 @@ module Orb
14
14
  sig { returns(T.nilable(T::Array[String])) }
15
15
  attr_accessor :applies_to_price_ids
16
16
 
17
+ # The filters that determine which prices to apply this discount to.
18
+ sig { returns(T.nilable(T::Array[Orb::TrialDiscount::Filter])) }
19
+ attr_accessor :filters
20
+
17
21
  sig { returns(T.nilable(String)) }
18
22
  attr_accessor :reason
19
23
 
@@ -29,6 +33,7 @@ module Orb
29
33
  params(
30
34
  discount_type: Orb::TrialDiscount::DiscountType::OrSymbol,
31
35
  applies_to_price_ids: T.nilable(T::Array[String]),
36
+ filters: T.nilable(T::Array[Orb::TrialDiscount::Filter::OrHash]),
32
37
  reason: T.nilable(String),
33
38
  trial_amount_discount: T.nilable(String),
34
39
  trial_percentage_discount: T.nilable(Float)
@@ -39,6 +44,8 @@ module Orb
39
44
  # List of price_ids that this discount applies to. For plan/plan phase discounts,
40
45
  # this can be a subset of prices.
41
46
  applies_to_price_ids: nil,
47
+ # The filters that determine which prices to apply this discount to.
48
+ filters: nil,
42
49
  reason: nil,
43
50
  # Only available if discount_type is `trial`
44
51
  trial_amount_discount: nil,
@@ -52,6 +59,7 @@ module Orb
52
59
  {
53
60
  discount_type: Orb::TrialDiscount::DiscountType::OrSymbol,
54
61
  applies_to_price_ids: T.nilable(T::Array[String]),
62
+ filters: T.nilable(T::Array[Orb::TrialDiscount::Filter]),
55
63
  reason: T.nilable(String),
56
64
  trial_amount_discount: T.nilable(String),
57
65
  trial_percentage_discount: T.nilable(Float)
@@ -78,6 +86,107 @@ module Orb
78
86
  def self.values
79
87
  end
80
88
  end
89
+
90
+ class Filter < Orb::Internal::Type::BaseModel
91
+ OrHash =
92
+ T.type_alias do
93
+ T.any(Orb::TrialDiscount::Filter, Orb::Internal::AnyHash)
94
+ end
95
+
96
+ # The property of the price to filter on.
97
+ sig { returns(Orb::TrialDiscount::Filter::Field::OrSymbol) }
98
+ attr_accessor :field
99
+
100
+ # Should prices that match the filter be included or excluded.
101
+ sig { returns(Orb::TrialDiscount::Filter::Operator::OrSymbol) }
102
+ attr_accessor :operator
103
+
104
+ # The IDs or values that match this filter.
105
+ sig { returns(T::Array[String]) }
106
+ attr_accessor :values
107
+
108
+ sig do
109
+ params(
110
+ field: Orb::TrialDiscount::Filter::Field::OrSymbol,
111
+ operator: Orb::TrialDiscount::Filter::Operator::OrSymbol,
112
+ values: T::Array[String]
113
+ ).returns(T.attached_class)
114
+ end
115
+ def self.new(
116
+ # The property of the price to filter on.
117
+ field:,
118
+ # Should prices that match the filter be included or excluded.
119
+ operator:,
120
+ # The IDs or values that match this filter.
121
+ values:
122
+ )
123
+ end
124
+
125
+ sig do
126
+ override.returns(
127
+ {
128
+ field: Orb::TrialDiscount::Filter::Field::OrSymbol,
129
+ operator: Orb::TrialDiscount::Filter::Operator::OrSymbol,
130
+ values: T::Array[String]
131
+ }
132
+ )
133
+ end
134
+ def to_hash
135
+ end
136
+
137
+ # The property of the price to filter on.
138
+ module Field
139
+ extend Orb::Internal::Type::Enum
140
+
141
+ TaggedSymbol =
142
+ T.type_alias { T.all(Symbol, Orb::TrialDiscount::Filter::Field) }
143
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
144
+
145
+ PRICE_ID =
146
+ T.let(:price_id, Orb::TrialDiscount::Filter::Field::TaggedSymbol)
147
+ ITEM_ID =
148
+ T.let(:item_id, Orb::TrialDiscount::Filter::Field::TaggedSymbol)
149
+ PRICE_TYPE =
150
+ T.let(:price_type, Orb::TrialDiscount::Filter::Field::TaggedSymbol)
151
+ CURRENCY =
152
+ T.let(:currency, Orb::TrialDiscount::Filter::Field::TaggedSymbol)
153
+ PRICING_UNIT_ID =
154
+ T.let(
155
+ :pricing_unit_id,
156
+ Orb::TrialDiscount::Filter::Field::TaggedSymbol
157
+ )
158
+
159
+ sig do
160
+ override.returns(
161
+ T::Array[Orb::TrialDiscount::Filter::Field::TaggedSymbol]
162
+ )
163
+ end
164
+ def self.values
165
+ end
166
+ end
167
+
168
+ # Should prices that match the filter be included or excluded.
169
+ module Operator
170
+ extend Orb::Internal::Type::Enum
171
+
172
+ TaggedSymbol =
173
+ T.type_alias { T.all(Symbol, Orb::TrialDiscount::Filter::Operator) }
174
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
175
+
176
+ INCLUDES =
177
+ T.let(:includes, Orb::TrialDiscount::Filter::Operator::TaggedSymbol)
178
+ EXCLUDES =
179
+ T.let(:excludes, Orb::TrialDiscount::Filter::Operator::TaggedSymbol)
180
+
181
+ sig do
182
+ override.returns(
183
+ T::Array[Orb::TrialDiscount::Filter::Operator::TaggedSymbol]
184
+ )
185
+ end
186
+ def self.values
187
+ end
188
+ end
189
+ end
81
190
  end
82
191
  end
83
192
  end
@@ -19,6 +19,10 @@ module Orb
19
19
  sig { returns(T.nilable(T::Array[String])) }
20
20
  attr_accessor :applies_to_price_ids
21
21
 
22
+ # The filters that determine which prices to apply this discount to.
23
+ sig { returns(T.nilable(T::Array[Orb::UsageDiscount::Filter])) }
24
+ attr_accessor :filters
25
+
22
26
  sig { returns(T.nilable(String)) }
23
27
  attr_accessor :reason
24
28
 
@@ -27,6 +31,7 @@ module Orb
27
31
  discount_type: Orb::UsageDiscount::DiscountType::OrSymbol,
28
32
  usage_discount: Float,
29
33
  applies_to_price_ids: T.nilable(T::Array[String]),
34
+ filters: T.nilable(T::Array[Orb::UsageDiscount::Filter::OrHash]),
30
35
  reason: T.nilable(String)
31
36
  ).returns(T.attached_class)
32
37
  end
@@ -38,6 +43,8 @@ module Orb
38
43
  # List of price_ids that this discount applies to. For plan/plan phase discounts,
39
44
  # this can be a subset of prices.
40
45
  applies_to_price_ids: nil,
46
+ # The filters that determine which prices to apply this discount to.
47
+ filters: nil,
41
48
  reason: nil
42
49
  )
43
50
  end
@@ -48,6 +55,7 @@ module Orb
48
55
  discount_type: Orb::UsageDiscount::DiscountType::OrSymbol,
49
56
  usage_discount: Float,
50
57
  applies_to_price_ids: T.nilable(T::Array[String]),
58
+ filters: T.nilable(T::Array[Orb::UsageDiscount::Filter]),
51
59
  reason: T.nilable(String)
52
60
  }
53
61
  )
@@ -72,6 +80,107 @@ module Orb
72
80
  def self.values
73
81
  end
74
82
  end
83
+
84
+ class Filter < Orb::Internal::Type::BaseModel
85
+ OrHash =
86
+ T.type_alias do
87
+ T.any(Orb::UsageDiscount::Filter, Orb::Internal::AnyHash)
88
+ end
89
+
90
+ # The property of the price to filter on.
91
+ sig { returns(Orb::UsageDiscount::Filter::Field::OrSymbol) }
92
+ attr_accessor :field
93
+
94
+ # Should prices that match the filter be included or excluded.
95
+ sig { returns(Orb::UsageDiscount::Filter::Operator::OrSymbol) }
96
+ attr_accessor :operator
97
+
98
+ # The IDs or values that match this filter.
99
+ sig { returns(T::Array[String]) }
100
+ attr_accessor :values
101
+
102
+ sig do
103
+ params(
104
+ field: Orb::UsageDiscount::Filter::Field::OrSymbol,
105
+ operator: Orb::UsageDiscount::Filter::Operator::OrSymbol,
106
+ values: T::Array[String]
107
+ ).returns(T.attached_class)
108
+ end
109
+ def self.new(
110
+ # The property of the price to filter on.
111
+ field:,
112
+ # Should prices that match the filter be included or excluded.
113
+ operator:,
114
+ # The IDs or values that match this filter.
115
+ values:
116
+ )
117
+ end
118
+
119
+ sig do
120
+ override.returns(
121
+ {
122
+ field: Orb::UsageDiscount::Filter::Field::OrSymbol,
123
+ operator: Orb::UsageDiscount::Filter::Operator::OrSymbol,
124
+ values: T::Array[String]
125
+ }
126
+ )
127
+ end
128
+ def to_hash
129
+ end
130
+
131
+ # The property of the price to filter on.
132
+ module Field
133
+ extend Orb::Internal::Type::Enum
134
+
135
+ TaggedSymbol =
136
+ T.type_alias { T.all(Symbol, Orb::UsageDiscount::Filter::Field) }
137
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
138
+
139
+ PRICE_ID =
140
+ T.let(:price_id, Orb::UsageDiscount::Filter::Field::TaggedSymbol)
141
+ ITEM_ID =
142
+ T.let(:item_id, Orb::UsageDiscount::Filter::Field::TaggedSymbol)
143
+ PRICE_TYPE =
144
+ T.let(:price_type, Orb::UsageDiscount::Filter::Field::TaggedSymbol)
145
+ CURRENCY =
146
+ T.let(:currency, Orb::UsageDiscount::Filter::Field::TaggedSymbol)
147
+ PRICING_UNIT_ID =
148
+ T.let(
149
+ :pricing_unit_id,
150
+ Orb::UsageDiscount::Filter::Field::TaggedSymbol
151
+ )
152
+
153
+ sig do
154
+ override.returns(
155
+ T::Array[Orb::UsageDiscount::Filter::Field::TaggedSymbol]
156
+ )
157
+ end
158
+ def self.values
159
+ end
160
+ end
161
+
162
+ # Should prices that match the filter be included or excluded.
163
+ module Operator
164
+ extend Orb::Internal::Type::Enum
165
+
166
+ TaggedSymbol =
167
+ T.type_alias { T.all(Symbol, Orb::UsageDiscount::Filter::Operator) }
168
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
169
+
170
+ INCLUDES =
171
+ T.let(:includes, Orb::UsageDiscount::Filter::Operator::TaggedSymbol)
172
+ EXCLUDES =
173
+ T.let(:excludes, Orb::UsageDiscount::Filter::Operator::TaggedSymbol)
174
+
175
+ sig do
176
+ override.returns(
177
+ T::Array[Orb::UsageDiscount::Filter::Operator::TaggedSymbol]
178
+ )
179
+ end
180
+ def self.values
181
+ end
182
+ end
183
+ end
75
184
  end
76
185
  end
77
186
  end
@@ -1013,17 +1013,16 @@ module Orb
1013
1013
  subscription_id: String,
1014
1014
  change_option:
1015
1015
  Orb::SubscriptionRedeemCouponParams::ChangeOption::OrSymbol,
1016
- coupon_id: String,
1017
1016
  allow_invoice_credit_or_void: T.nilable(T::Boolean),
1018
1017
  change_date: T.nilable(Time),
1018
+ coupon_id: T.nilable(String),
1019
+ coupon_redemption_code: T.nilable(String),
1019
1020
  request_options: Orb::RequestOptions::OrHash
1020
1021
  ).returns(Orb::Models::SubscriptionRedeemCouponResponse)
1021
1022
  end
1022
1023
  def redeem_coupon(
1023
1024
  subscription_id,
1024
1025
  change_option:,
1025
- # Coupon ID to be redeemed for this subscription.
1026
- coupon_id:,
1027
1026
  # If false, this request will fail if it would void an issued invoice or create a
1028
1027
  # credit note. Consider using this as a safety mechanism if you do not expect
1029
1028
  # existing invoices to be changed.
@@ -1031,6 +1030,10 @@ module Orb
1031
1030
  # The date that the coupon discount should take effect. This parameter can only be
1032
1031
  # passed if the `change_option` is `requested_date`.
1033
1032
  change_date: nil,
1033
+ # Coupon ID to be redeemed for this subscription.
1034
+ coupon_id: nil,
1035
+ # Redemption code of the coupon to be redeemed for this subscription.
1036
+ coupon_redemption_code: nil,
1034
1037
  request_options: {}
1035
1038
  )
1036
1039
  end
@@ -1436,7 +1439,7 @@ module Orb
1436
1439
  end
1437
1440
 
1438
1441
  # This endpoint can be used to unschedule any pending plan changes on an existing
1439
- # subscription.
1442
+ # subscription. When called, all upcoming plan changes will be unscheduled.
1440
1443
  sig do
1441
1444
  params(
1442
1445
  subscription_id: String,
@@ -5,6 +5,7 @@ module Orb
5
5
  amount_discount: String,
6
6
  discount_type: Orb::Models::AmountDiscount::discount_type,
7
7
  applies_to_price_ids: ::Array[String]?,
8
+ filters: ::Array[Orb::AmountDiscount::Filter]?,
8
9
  reason: String?
9
10
  }
10
11
 
@@ -15,12 +16,15 @@ module Orb
15
16
 
16
17
  attr_accessor applies_to_price_ids: ::Array[String]?
17
18
 
19
+ attr_accessor filters: ::Array[Orb::AmountDiscount::Filter]?
20
+
18
21
  attr_accessor reason: String?
19
22
 
20
23
  def initialize: (
21
24
  amount_discount: String,
22
25
  discount_type: Orb::Models::AmountDiscount::discount_type,
23
26
  ?applies_to_price_ids: ::Array[String]?,
27
+ ?filters: ::Array[Orb::AmountDiscount::Filter]?,
24
28
  ?reason: String?
25
29
  ) -> void
26
30
 
@@ -28,6 +32,7 @@ module Orb
28
32
  amount_discount: String,
29
33
  discount_type: Orb::Models::AmountDiscount::discount_type,
30
34
  applies_to_price_ids: ::Array[String]?,
35
+ filters: ::Array[Orb::AmountDiscount::Filter]?,
31
36
  reason: String?
32
37
  }
33
38
 
@@ -40,6 +45,59 @@ module Orb
40
45
 
41
46
  def self?.values: -> ::Array[Orb::Models::AmountDiscount::discount_type]
42
47
  end
48
+
49
+ type filter =
50
+ {
51
+ field: Orb::Models::AmountDiscount::Filter::field,
52
+ operator: Orb::Models::AmountDiscount::Filter::operator,
53
+ values: ::Array[String]
54
+ }
55
+
56
+ class Filter < Orb::Internal::Type::BaseModel
57
+ attr_accessor field: Orb::Models::AmountDiscount::Filter::field
58
+
59
+ attr_accessor operator: Orb::Models::AmountDiscount::Filter::operator
60
+
61
+ attr_accessor values: ::Array[String]
62
+
63
+ def initialize: (
64
+ field: Orb::Models::AmountDiscount::Filter::field,
65
+ operator: Orb::Models::AmountDiscount::Filter::operator,
66
+ values: ::Array[String]
67
+ ) -> void
68
+
69
+ def to_hash: -> {
70
+ field: Orb::Models::AmountDiscount::Filter::field,
71
+ operator: Orb::Models::AmountDiscount::Filter::operator,
72
+ values: ::Array[String]
73
+ }
74
+
75
+ type field =
76
+ :price_id | :item_id | :price_type | :currency | :pricing_unit_id
77
+
78
+ module Field
79
+ extend Orb::Internal::Type::Enum
80
+
81
+ PRICE_ID: :price_id
82
+ ITEM_ID: :item_id
83
+ PRICE_TYPE: :price_type
84
+ CURRENCY: :currency
85
+ PRICING_UNIT_ID: :pricing_unit_id
86
+
87
+ def self?.values: -> ::Array[Orb::Models::AmountDiscount::Filter::field]
88
+ end
89
+
90
+ type operator = :includes | :excludes
91
+
92
+ module Operator
93
+ extend Orb::Internal::Type::Enum
94
+
95
+ INCLUDES: :includes
96
+ EXCLUDES: :excludes
97
+
98
+ def self?.values: -> ::Array[Orb::Models::AmountDiscount::Filter::operator]
99
+ end
100
+ end
43
101
  end
44
102
  end
45
103
  end