Class: AdvancedBilling::CreateUsage
- Defined in:
- lib/advanced_billing/models/create_usage.rb
Overview
CreateUsage Model.
Instance Attribute Summary collapse
-
#billing_schedule ⇒ BillingSchedule
This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription.
-
#memo ⇒ String
integer by default or decimal number if fractional quantities are enabled for the component.
-
#price_point_id ⇒ String
integer by default or decimal number if fractional quantities are enabled for the component.
-
#quantity ⇒ Float
integer by default or decimal number if fractional quantities are enabled for the component.
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.
Instance Method Summary collapse
-
#initialize(quantity: SKIP, price_point_id: SKIP, memo: SKIP, billing_schedule: SKIP, additional_properties: {}) ⇒ CreateUsage
constructor
A new instance of CreateUsage.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(quantity: SKIP, price_point_id: SKIP, memo: SKIP, billing_schedule: SKIP, additional_properties: {}) ⇒ CreateUsage
Returns a new instance of CreateUsage.
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/advanced_billing/models/create_usage.rb', line 59 def initialize(quantity: SKIP, price_point_id: SKIP, memo: SKIP, billing_schedule: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @quantity = quantity unless quantity == SKIP @price_point_id = price_point_id unless price_point_id == SKIP @memo = memo unless memo == SKIP @billing_schedule = billing_schedule unless billing_schedule == SKIP end |
Instance Attribute Details
#billing_schedule ⇒ BillingSchedule
This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. Please note this only works for site with Multifrequency enabled
32 33 34 |
# File 'lib/advanced_billing/models/create_usage.rb', line 32 def billing_schedule @billing_schedule end |
#memo ⇒ String
integer by default or decimal number if fractional quantities are enabled for the component
25 26 27 |
# File 'lib/advanced_billing/models/create_usage.rb', line 25 def memo @memo end |
#price_point_id ⇒ String
integer by default or decimal number if fractional quantities are enabled for the component
20 21 22 |
# File 'lib/advanced_billing/models/create_usage.rb', line 20 def price_point_id @price_point_id end |
#quantity ⇒ Float
integer by default or decimal number if fractional quantities are enabled for the component
15 16 17 |
# File 'lib/advanced_billing/models/create_usage.rb', line 15 def quantity @quantity end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/advanced_billing/models/create_usage.rb', line 73 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. quantity = hash.key?('quantity') ? hash['quantity'] : SKIP price_point_id = hash.key?('price_point_id') ? hash['price_point_id'] : SKIP memo = hash.key?('memo') ? hash['memo'] : SKIP billing_schedule = BillingSchedule.from_hash(hash['billing_schedule']) if hash['billing_schedule'] # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. CreateUsage.new(quantity: quantity, price_point_id: price_point_id, memo: memo, billing_schedule: billing_schedule, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
35 36 37 38 39 40 41 42 |
# File 'lib/advanced_billing/models/create_usage.rb', line 35 def self.names @_hash = {} if @_hash.nil? @_hash['quantity'] = 'quantity' @_hash['price_point_id'] = 'price_point_id' @_hash['memo'] = 'memo' @_hash['billing_schedule'] = 'billing_schedule' @_hash end |
.nullables ⇒ Object
An array for nullable fields
55 56 57 |
# File 'lib/advanced_billing/models/create_usage.rb', line 55 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
45 46 47 48 49 50 51 52 |
# File 'lib/advanced_billing/models/create_usage.rb', line 45 def self.optionals %w[ quantity price_point_id memo billing_schedule ] end |