Class: AdvancedBilling::CreateUsage
- Defined in:
- lib/advanced_billing/models/create_usage.rb
Overview
CreateUsage Model.
Instance Attribute Summary collapse
-
#billing_schedule ⇒ BillingSchedule
Billing schedule settings for component allocations or usages on multi-frequency subscriptions.
-
#custom_price ⇒ ComponentCustomPrice
Create or update custom pricing unique to the 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, custom_price: SKIP, additional_properties: {}) ⇒ CreateUsage
constructor
A new instance of CreateUsage.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #get_additional_properties, #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, custom_price: SKIP, additional_properties: {}) ⇒ CreateUsage
Returns a new instance of CreateUsage.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/advanced_billing/models/create_usage.rb', line 66 def initialize(quantity: SKIP, price_point_id: SKIP, memo: SKIP, billing_schedule: SKIP, custom_price: 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 @custom_price = custom_price unless custom_price == SKIP end |
Instance Attribute Details
#billing_schedule ⇒ BillingSchedule
Billing schedule settings for component allocations or usages on multi-frequency subscriptions. Use this to start a component’s billing period on a custom date instead of aligning with the product charge schedule.
32 33 34 |
# File 'lib/advanced_billing/models/create_usage.rb', line 32 def billing_schedule @billing_schedule end |
#custom_price ⇒ ComponentCustomPrice
Create or update custom pricing unique to the subscription. Used in place of ‘price_point_id`.
37 38 39 |
# File 'lib/advanced_billing/models/create_usage.rb', line 37 def custom_price @custom_price 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.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/advanced_billing/models/create_usage.rb', line 82 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'] custom_price = ComponentCustomPrice.from_hash(hash['custom_price']) if hash['custom_price'] # 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, custom_price: custom_price, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
40 41 42 43 44 45 46 47 48 |
# File 'lib/advanced_billing/models/create_usage.rb', line 40 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['custom_price'] = 'custom_price' @_hash end |
.nullables ⇒ Object
An array for nullable fields
62 63 64 |
# File 'lib/advanced_billing/models/create_usage.rb', line 62 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
51 52 53 54 55 56 57 58 59 |
# File 'lib/advanced_billing/models/create_usage.rb', line 51 def self.optionals %w[ quantity price_point_id memo billing_schedule custom_price ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
115 116 117 118 119 120 |
# File 'lib/advanced_billing/models/create_usage.rb', line 115 def inspect class_name = self.class.name.split('::').last "<#{class_name} quantity: #{@quantity.inspect}, price_point_id: #{@price_point_id.inspect},"\ " memo: #{@memo.inspect}, billing_schedule: #{@billing_schedule.inspect}, custom_price:"\ " #{@custom_price.inspect}, additional_properties: #{get_additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
107 108 109 110 111 112 |
# File 'lib/advanced_billing/models/create_usage.rb', line 107 def to_s class_name = self.class.name.split('::').last "<#{class_name} quantity: #{@quantity}, price_point_id: #{@price_point_id}, memo: #{@memo},"\ " billing_schedule: #{@billing_schedule}, custom_price: #{@custom_price},"\ " additional_properties: #{get_additional_properties}>" end |