Class: AdvancedBilling::UpdatePrice
- Defined in:
- lib/advanced_billing/models/update_price.rb
Overview
UpdatePrice Model.
Instance Attribute Summary collapse
-
#destroy ⇒ TrueClass | FalseClass
The price can contain up to 8 decimal places.
-
#ending_quantity ⇒ Object
TODO: Write general description for this method.
-
#id ⇒ Integer
TODO: Write general description for this method.
-
#starting_quantity ⇒ Object
The price can contain up to 8 decimal places.
-
#unit_price ⇒ Object
The price can contain up to 8 decimal places.
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: SKIP, ending_quantity: SKIP, unit_price: SKIP, destroy: SKIP, starting_quantity: SKIP, additional_properties: {}) ⇒ UpdatePrice
constructor
A new instance of UpdatePrice.
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: SKIP, ending_quantity: SKIP, unit_price: SKIP, destroy: SKIP, starting_quantity: SKIP, additional_properties: {}) ⇒ UpdatePrice
Returns a new instance of UpdatePrice.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/advanced_billing/models/update_price.rb', line 62 def initialize(id: SKIP, ending_quantity: SKIP, unit_price: SKIP, destroy: SKIP, starting_quantity: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @id = id unless id == SKIP @ending_quantity = ending_quantity unless ending_quantity == SKIP @unit_price = unit_price unless unit_price == SKIP @destroy = destroy unless destroy == SKIP @starting_quantity = starting_quantity unless starting_quantity == SKIP end |
Instance Attribute Details
#destroy ⇒ TrueClass | FalseClass
The price can contain up to 8 decimal places. i.e. 1.00 or 0.0012 or 0.00000065
28 29 30 |
# File 'lib/advanced_billing/models/update_price.rb', line 28 def destroy @destroy end |
#ending_quantity ⇒ Object
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/update_price.rb', line 18 def ending_quantity @ending_quantity end |
#id ⇒ Integer
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/update_price.rb', line 14 def id @id end |
#starting_quantity ⇒ Object
The price can contain up to 8 decimal places. i.e. 1.00 or 0.0012 or 0.00000065
33 34 35 |
# File 'lib/advanced_billing/models/update_price.rb', line 33 def starting_quantity @starting_quantity end |
#unit_price ⇒ Object
The price can contain up to 8 decimal places. i.e. 1.00 or 0.0012 or 0.00000065
23 24 25 |
# File 'lib/advanced_billing/models/update_price.rb', line 23 def unit_price @unit_price end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
78 79 80 81 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/update_price.rb', line 78 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : SKIP ending_quantity = hash.key?('ending_quantity') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:UpdatePriceEndingQuantity), hash['ending_quantity'] ) : SKIP unit_price = hash.key?('unit_price') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:UpdatePriceUnitPrice), hash['unit_price'] ) : SKIP destroy = hash.key?('_destroy') ? hash['_destroy'] : SKIP starting_quantity = hash.key?('starting_quantity') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:UpdatePriceStartingQuantity), hash['starting_quantity'] ) : SKIP # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. UpdatePrice.new(id: id, ending_quantity: ending_quantity, unit_price: unit_price, destroy: destroy, starting_quantity: starting_quantity, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
36 37 38 39 40 41 42 43 44 |
# File 'lib/advanced_billing/models/update_price.rb', line 36 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['ending_quantity'] = 'ending_quantity' @_hash['unit_price'] = 'unit_price' @_hash['destroy'] = '_destroy' @_hash['starting_quantity'] = 'starting_quantity' @_hash end |
.nullables ⇒ Object
An array for nullable fields
58 59 60 |
# File 'lib/advanced_billing/models/update_price.rb', line 58 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
47 48 49 50 51 52 53 54 55 |
# File 'lib/advanced_billing/models/update_price.rb', line 47 def self.optionals %w[ id ending_quantity unit_price destroy starting_quantity ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
108 109 110 111 112 113 114 |
# File 'lib/advanced_billing/models/update_price.rb', line 108 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |