Class: Asdawqw::FeeTax

Inherits:
BaseModel show all
Defined in:
lib/asdawqw/models/fee_tax.rb

Overview

FeeTax Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

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

#feesList of Fee

List of models

Returns:

  • (List of Fee)


15
16
17
# File 'lib/asdawqw/models/fee_tax.rb', line 15

def fees
  @fees
end

#product_idInteger

ID of the product

Returns:

  • (Integer)


11
12
13
# File 'lib/asdawqw/models/fee_tax.rb', line 11

def product_id
  @product_id
end

#taxesList of Taxes

List of models

Returns:



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

.namesObject

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