Class: Asdawqw::LosRatesProduct

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

Overview

Model for product LOS rates

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, los_rates = nil) ⇒ LosRatesProduct

Returns a new instance of LosRatesProduct.



25
26
27
28
29
# File 'lib/asdawqw/models/los_rates_product.rb', line 25

def initialize(product_id = nil,
               los_rates = nil)
  @product_id = product_id
  @los_rates = los_rates
end

Instance Attribute Details

#los_ratesList of LosRate

List of models. Max size array for LosRates object 1000

Returns:



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

def los_rates
  @los_rates
end

#product_idInteger

ID of the product

Returns:

  • (Integer)


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

def product_id
  @product_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/asdawqw/models/los_rates_product.rb', line 32

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
  los_rates = nil
  unless hash['losRates'].nil?
    los_rates = []
    hash['losRates'].each do |structure|
      los_rates << (LosRate.from_hash(structure) if structure)
    end
  end

  # Create object from extracted values.
  LosRatesProduct.new(product_id,
                      los_rates)
end

.namesObject

A mapping from model property names to API property names.



18
19
20
21
22
23
# File 'lib/asdawqw/models/los_rates_product.rb', line 18

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['product_id'] = 'productId'
  @_hash['los_rates'] = 'losRates'
  @_hash
end