Class: AdvancedBilling::MeteredUsage
- Defined in:
- lib/advanced_billing/models/metered_usage.rb
Overview
MeteredUsage Model.
Instance Attribute Summary collapse
-
#component_handle ⇒ String
TODO: Write general description for this method.
-
#component_id ⇒ Integer
TODO: Write general description for this method.
-
#memo ⇒ String
TODO: Write general description for this method.
-
#new_unit_balance ⇒ Integer
TODO: Write general description for this method.
-
#previous_unit_balance ⇒ String
TODO: Write general description for this method.
-
#usage_quantity ⇒ Integer
TODO: Write general description for this method.
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(previous_unit_balance:, new_unit_balance:, usage_quantity:, component_id:, component_handle:, memo:, additional_properties: {}) ⇒ MeteredUsage
constructor
A new instance of MeteredUsage.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(previous_unit_balance:, new_unit_balance:, usage_quantity:, component_id:, component_handle:, memo:, additional_properties: {}) ⇒ MeteredUsage
Returns a new instance of MeteredUsage.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/advanced_billing/models/metered_usage.rb', line 58 def initialize(previous_unit_balance:, new_unit_balance:, usage_quantity:, component_id:, component_handle:, memo:, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @previous_unit_balance = previous_unit_balance @new_unit_balance = new_unit_balance @usage_quantity = usage_quantity @component_id = component_id @component_handle = component_handle @memo = memo end |
Instance Attribute Details
#component_handle ⇒ String
TODO: Write general description for this method
30 31 32 |
# File 'lib/advanced_billing/models/metered_usage.rb', line 30 def component_handle @component_handle end |
#component_id ⇒ Integer
TODO: Write general description for this method
26 27 28 |
# File 'lib/advanced_billing/models/metered_usage.rb', line 26 def component_id @component_id end |
#memo ⇒ String
TODO: Write general description for this method
34 35 36 |
# File 'lib/advanced_billing/models/metered_usage.rb', line 34 def memo @memo end |
#new_unit_balance ⇒ Integer
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/metered_usage.rb', line 18 def new_unit_balance @new_unit_balance end |
#previous_unit_balance ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/metered_usage.rb', line 14 def previous_unit_balance @previous_unit_balance end |
#usage_quantity ⇒ Integer
TODO: Write general description for this method
22 23 24 |
# File 'lib/advanced_billing/models/metered_usage.rb', line 22 def usage_quantity @usage_quantity end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/advanced_billing/models/metered_usage.rb', line 75 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. previous_unit_balance = hash.key?('previous_unit_balance') ? hash['previous_unit_balance'] : nil new_unit_balance = hash.key?('new_unit_balance') ? hash['new_unit_balance'] : nil usage_quantity = hash.key?('usage_quantity') ? hash['usage_quantity'] : nil component_id = hash.key?('component_id') ? hash['component_id'] : nil component_handle = hash.key?('component_handle') ? hash['component_handle'] : nil memo = hash.key?('memo') ? hash['memo'] : nil # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. MeteredUsage.new(previous_unit_balance: previous_unit_balance, new_unit_balance: new_unit_balance, usage_quantity: usage_quantity, component_id: component_id, component_handle: component_handle, memo: memo, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/advanced_billing/models/metered_usage.rb', line 37 def self.names @_hash = {} if @_hash.nil? @_hash['previous_unit_balance'] = 'previous_unit_balance' @_hash['new_unit_balance'] = 'new_unit_balance' @_hash['usage_quantity'] = 'usage_quantity' @_hash['component_id'] = 'component_id' @_hash['component_handle'] = 'component_handle' @_hash['memo'] = 'memo' @_hash end |
.nullables ⇒ Object
An array for nullable fields
54 55 56 |
# File 'lib/advanced_billing/models/metered_usage.rb', line 54 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
49 50 51 |
# File 'lib/advanced_billing/models/metered_usage.rb', line 49 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/advanced_billing/models/metered_usage.rb', line 105 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.previous_unit_balance, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.new_unit_balance, ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value.usage_quantity, ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value.component_id, ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value.component_handle, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.memo, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['previous_unit_balance'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['new_unit_balance'], ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value['usage_quantity'], ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value['component_id'], ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value['component_handle'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['memo'], ->(val) { val.instance_of? String }) ) end |