Class: Asdawqw::FeeTax
- Defined in:
- lib/asdawqw/models/fee_tax.rb
Overview
FeeTax Model.
Instance Attribute Summary collapse
-
#fees ⇒ List of Fee
List of models.
-
#product_id ⇒ Integer
ID of the product.
-
#taxes ⇒ List of Taxes
List of models.
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.
Instance Method Summary collapse
-
#initialize(product_id = nil, fees = nil, taxes = nil) ⇒ FeeTax
constructor
A new instance of FeeTax.
Methods inherited from BaseModel
Constructor Details
#initialize(product_id = nil, fees = nil, taxes = nil) ⇒ FeeTax
Returns a new instance of FeeTax.
30 31 32 33 34 35 36 |
# File 'lib/asdawqw/models/fee_tax.rb', line 30 def initialize(product_id = nil, fees = nil, taxes = nil) @product_id = product_id @fees = fees @taxes = taxes end |
Instance Attribute Details
#fees ⇒ List of Fee
List of models
15 16 17 |
# File 'lib/asdawqw/models/fee_tax.rb', line 15 def fees @fees end |
#product_id ⇒ Integer
ID of the product
11 12 13 |
# File 'lib/asdawqw/models/fee_tax.rb', line 11 def product_id @product_id end |
#taxes ⇒ List of Taxes
List of models
19 20 21 |
# File 'lib/asdawqw/models/fee_tax.rb', line 19 def taxes @taxes end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/asdawqw/models/fee_tax.rb', line 39 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. product_id = hash['productId'] # Parameter is an array, so we need to iterate through it fees = nil unless hash['fees'].nil? fees = [] hash['fees'].each do |structure| fees << (Fee.from_hash(structure) if structure) end end # Parameter is an array, so we need to iterate through it taxes = nil unless hash['taxes'].nil? taxes = [] hash['taxes'].each do |structure| taxes << (Taxes.from_hash(structure) if structure) end end # Create object from extracted values. FeeTax.new(product_id, fees, taxes) end |
.names ⇒ Object
A mapping from model property names to API property names.
22 23 24 25 26 27 28 |
# File 'lib/asdawqw/models/fee_tax.rb', line 22 def self.names @_hash = {} if @_hash.nil? @_hash['product_id'] = 'productId' @_hash['fees'] = 'fees' @_hash['taxes'] = 'taxes' @_hash end |