Class: ApiReference::PriceInterval
- Defined in:
- lib/api_reference/models/price_interval.rb
Overview
The Price Interval resource represents a period of time for which a price will bill on a subscription. A subscription’s price intervals define its billing behavior.
Instance Attribute Summary collapse
-
#billing_cycle_day ⇒ Integer
The day of the month that Orb bills for this price.
-
#can_defer_billing ⇒ TrueClass | FalseClass
For in-arrears prices.
-
#current_billing_period_end_date ⇒ DateTime
The end of the current billing period.
-
#current_billing_period_start_date ⇒ DateTime
The start date of the current billing period.
-
#end_date ⇒ DateTime
The end date of the price interval.
-
#filter ⇒ String
An additional filter to apply to usage queries.
-
#fixed_fee_quantity_transitions ⇒ Array[FixedFeeQuantityTransition]
The fixed fee quantity transitions for this price interval.
-
#id ⇒ String
TODO: Write general description for this method.
-
#metric_parameter_overrides ⇒ Object
Override values for parameterized billable metric variables.
-
#price ⇒ Object
The Price resource represents a price that can be billed on a subscription, resulting in a charge on an invoice in the form of an invoice line item.
-
#start_date ⇒ DateTime
The start date of the price interval.
-
#usage_customer_ids ⇒ Array[String]
A list of customer IDs whose usage events will be aggregated and billed under this price interval.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(id:, start_date:, end_date:, price:, billing_cycle_day:, can_defer_billing:, fixed_fee_quantity_transitions:, current_billing_period_start_date:, current_billing_period_end_date:, filter:, usage_customer_ids:, metric_parameter_overrides: SKIP, additional_properties: nil) ⇒ PriceInterval
constructor
A new instance of PriceInterval.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_current_billing_period_end_date ⇒ Object
- #to_custom_current_billing_period_start_date ⇒ Object
- #to_custom_end_date ⇒ Object
- #to_custom_start_date ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(id:, start_date:, end_date:, price:, billing_cycle_day:, can_defer_billing:, fixed_fee_quantity_transitions:, current_billing_period_start_date:, current_billing_period_end_date:, filter:, usage_customer_ids:, metric_parameter_overrides: SKIP, additional_properties: nil) ⇒ PriceInterval
Returns a new instance of PriceInterval.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/api_reference/models/price_interval.rb', line 124 def initialize(id:, start_date:, end_date:, price:, billing_cycle_day:, can_defer_billing:, fixed_fee_quantity_transitions:, current_billing_period_start_date:, current_billing_period_end_date:, filter:, usage_customer_ids:, metric_parameter_overrides: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @id = id @start_date = start_date @end_date = end_date @price = price @billing_cycle_day = billing_cycle_day @can_defer_billing = can_defer_billing @fixed_fee_quantity_transitions = fixed_fee_quantity_transitions @current_billing_period_start_date = current_billing_period_start_date @current_billing_period_end_date = current_billing_period_end_date @filter = filter @usage_customer_ids = usage_customer_ids unless metric_parameter_overrides == SKIP @metric_parameter_overrides = metric_parameter_overrides end @additional_properties = additional_properties end |
Instance Attribute Details
#billing_cycle_day ⇒ Integer
The day of the month that Orb bills for this price
44 45 46 |
# File 'lib/api_reference/models/price_interval.rb', line 44 def billing_cycle_day @billing_cycle_day end |
#can_defer_billing ⇒ TrueClass | FalseClass
For in-arrears prices. If true, and the price interval ends mid-cycle, the final line item will be deferred to the next scheduled invoice instead of being billed mid-cycle.
50 51 52 |
# File 'lib/api_reference/models/price_interval.rb', line 50 def can_defer_billing @can_defer_billing end |
#current_billing_period_end_date ⇒ DateTime
The end of the current billing period. This is an exclusive timestamp, such that the instant returned is exactly the end of the billing period. Set to null if this price interval is not currently active.
67 68 69 |
# File 'lib/api_reference/models/price_interval.rb', line 67 def current_billing_period_end_date @current_billing_period_end_date end |
#current_billing_period_start_date ⇒ DateTime
The start date of the current billing period. This is an inclusive timestamp; the instant returned is exactly the beginning of the billing period. Set to null if this price interval is not currently active.
61 62 63 |
# File 'lib/api_reference/models/price_interval.rb', line 61 def current_billing_period_start_date @current_billing_period_start_date end |
#end_date ⇒ DateTime
The end date of the price interval. This is the date that Orb stops billing for this price.
27 28 29 |
# File 'lib/api_reference/models/price_interval.rb', line 27 def end_date @end_date end |
#filter ⇒ String
An additional filter to apply to usage queries.
71 72 73 |
# File 'lib/api_reference/models/price_interval.rb', line 71 def filter @filter end |
#fixed_fee_quantity_transitions ⇒ Array[FixedFeeQuantityTransition]
The fixed fee quantity transitions for this price interval. This is only relevant for fixed fees.
55 56 57 |
# File 'lib/api_reference/models/price_interval.rb', line 55 def fixed_fee_quantity_transitions @fixed_fee_quantity_transitions end |
#id ⇒ String
TODO: Write general description for this method
17 18 19 |
# File 'lib/api_reference/models/price_interval.rb', line 17 def id @id end |
#metric_parameter_overrides ⇒ Object
Override values for parameterized billable metric variables. Keys are parameter names, values are the override values.
81 82 83 |
# File 'lib/api_reference/models/price_interval.rb', line 81 def metric_parameter_overrides @metric_parameter_overrides end |
#price ⇒ Object
The Price resource represents a price that can be billed on a subscription, resulting in a charge on an invoice in the form of an invoice line item. Prices take a quantity and determine an amount to bill. Orb supports a few different pricing models out of the box. Each of these models is serialized differently in a given Price object. The model_type field determines the key for the configuration object that is present. For more on the types of prices, see the core concepts documentation
40 41 42 |
# File 'lib/api_reference/models/price_interval.rb', line 40 def price @price end |
#start_date ⇒ DateTime
The start date of the price interval. This is the date that Orb starts billing for this price.
22 23 24 |
# File 'lib/api_reference/models/price_interval.rb', line 22 def start_date @start_date end |
#usage_customer_ids ⇒ Array[String]
A list of customer IDs whose usage events will be aggregated and billed under this price interval.
76 77 78 |
# File 'lib/api_reference/models/price_interval.rb', line 76 def usage_customer_ids @usage_customer_ids end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/api_reference/models/price_interval.rb', line 152 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil start_date = if hash.key?('start_date') (DateTimeHelper.from_rfc3339(hash['start_date']) if hash['start_date']) end end_date = if hash.key?('end_date') (DateTimeHelper.from_rfc3339(hash['end_date']) if hash['end_date']) end price = hash.key?('price') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:Price), hash['price'] ) : nil billing_cycle_day = hash.key?('billing_cycle_day') ? hash['billing_cycle_day'] : nil can_defer_billing = hash.key?('can_defer_billing') ? hash['can_defer_billing'] : nil # Parameter is an array, so we need to iterate through it fixed_fee_quantity_transitions = nil unless hash['fixed_fee_quantity_transitions'].nil? fixed_fee_quantity_transitions = [] hash['fixed_fee_quantity_transitions'].each do |structure| fixed_fee_quantity_transitions << (FixedFeeQuantityTransition.from_hash(structure) if structure) end end fixed_fee_quantity_transitions = nil unless hash.key?('fixed_fee_quantity_transitions') current_billing_period_start_date = if hash.key?('current_billing_period_start_date') (DateTimeHelper.from_rfc3339(hash['current_billing_period_start_date']) if hash['current_billing_period_start_date']) end current_billing_period_end_date = if hash.key?('current_billing_period_end_date') (DateTimeHelper.from_rfc3339(hash['current_billing_period_end_date']) if hash['current_billing_period_end_date']) end filter = hash.key?('filter') ? hash['filter'] : nil usage_customer_ids = hash.key?('usage_customer_ids') ? hash['usage_customer_ids'] : nil metric_parameter_overrides = hash.key?('metric_parameter_overrides') ? hash['metric_parameter_overrides'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. PriceInterval.new(id: id, start_date: start_date, end_date: end_date, price: price, billing_cycle_day: billing_cycle_day, can_defer_billing: can_defer_billing, fixed_fee_quantity_transitions: fixed_fee_quantity_transitions, current_billing_period_start_date: current_billing_period_start_date, current_billing_period_end_date: current_billing_period_end_date, filter: filter, usage_customer_ids: usage_customer_ids, metric_parameter_overrides: metric_parameter_overrides, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/api_reference/models/price_interval.rb', line 84 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['start_date'] = 'start_date' @_hash['end_date'] = 'end_date' @_hash['price'] = 'price' @_hash['billing_cycle_day'] = 'billing_cycle_day' @_hash['can_defer_billing'] = 'can_defer_billing' @_hash['fixed_fee_quantity_transitions'] = 'fixed_fee_quantity_transitions' @_hash['current_billing_period_start_date'] = 'current_billing_period_start_date' @_hash['current_billing_period_end_date'] = 'current_billing_period_end_date' @_hash['filter'] = 'filter' @_hash['usage_customer_ids'] = 'usage_customer_ids' @_hash['metric_parameter_overrides'] = 'metric_parameter_overrides' @_hash end |
.nullables ⇒ Object
An array for nullable fields
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/api_reference/models/price_interval.rb', line 112 def self.nullables %w[ end_date fixed_fee_quantity_transitions current_billing_period_start_date current_billing_period_end_date filter usage_customer_ids metric_parameter_overrides ] end |
.optionals ⇒ Object
An array for optional fields
105 106 107 108 109 |
# File 'lib/api_reference/models/price_interval.rb', line 105 def self.optionals %w[ metric_parameter_overrides ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/api_reference/models/price_interval.rb', line 233 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.start_date, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.end_date, ->(val) { val.instance_of? DateTime }) and UnionTypeLookUp.get(:Price) .validate(value.price) and APIHelper.valid_type?(value.billing_cycle_day, ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value.can_defer_billing, ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and APIHelper.valid_type?(value.fixed_fee_quantity_transitions, ->(val) { FixedFeeQuantityTransition.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value.current_billing_period_start_date, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.current_billing_period_end_date, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.filter, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.usage_customer_ids, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['start_date'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['end_date'], ->(val) { val.instance_of? String }) and UnionTypeLookUp.get(:Price) .validate(value['price']) and APIHelper.valid_type?(value['billing_cycle_day'], ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value['can_defer_billing'], ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and APIHelper.valid_type?(value['fixed_fee_quantity_transitions'], ->(val) { FixedFeeQuantityTransition.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value['current_billing_period_start_date'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['current_billing_period_end_date'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['filter'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['usage_customer_ids'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/api_reference/models/price_interval.rb', line 306 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, start_date: #{@start_date.inspect}, end_date:"\ " #{@end_date.inspect}, price: #{@price.inspect}, billing_cycle_day:"\ " #{@billing_cycle_day.inspect}, can_defer_billing: #{@can_defer_billing.inspect},"\ " fixed_fee_quantity_transitions: #{@fixed_fee_quantity_transitions.inspect},"\ " current_billing_period_start_date: #{@current_billing_period_start_date.inspect},"\ " current_billing_period_end_date: #{@current_billing_period_end_date.inspect}, filter:"\ " #{@filter.inspect}, usage_customer_ids: #{@usage_customer_ids.inspect},"\ " metric_parameter_overrides: #{@metric_parameter_overrides.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_custom_current_billing_period_end_date ⇒ Object
227 228 229 |
# File 'lib/api_reference/models/price_interval.rb', line 227 def to_custom_current_billing_period_end_date DateTimeHelper.to_rfc3339(current_billing_period_end_date) end |
#to_custom_current_billing_period_start_date ⇒ Object
223 224 225 |
# File 'lib/api_reference/models/price_interval.rb', line 223 def to_custom_current_billing_period_start_date DateTimeHelper.to_rfc3339(current_billing_period_start_date) end |
#to_custom_end_date ⇒ Object
219 220 221 |
# File 'lib/api_reference/models/price_interval.rb', line 219 def to_custom_end_date DateTimeHelper.to_rfc3339(end_date) end |
#to_custom_start_date ⇒ Object
215 216 217 |
# File 'lib/api_reference/models/price_interval.rb', line 215 def to_custom_start_date DateTimeHelper.to_rfc3339(start_date) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
294 295 296 297 298 299 300 301 302 303 |
# File 'lib/api_reference/models/price_interval.rb', line 294 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, start_date: #{@start_date}, end_date: #{@end_date}, price:"\ " #{@price}, billing_cycle_day: #{@billing_cycle_day}, can_defer_billing:"\ " #{@can_defer_billing}, fixed_fee_quantity_transitions: #{@fixed_fee_quantity_transitions},"\ " current_billing_period_start_date: #{@current_billing_period_start_date},"\ " current_billing_period_end_date: #{@current_billing_period_end_date}, filter: #{@filter},"\ " usage_customer_ids: #{@usage_customer_ids}, metric_parameter_overrides:"\ " #{@metric_parameter_overrides}, additional_properties: #{@additional_properties}>" end |