Class: Raas::ExchangeRateResponseModel
- Defined in:
- lib/raas/models/exchange_rate_response_model.rb
Overview
Represents the response from the get exchange rates call
Instance Attribute Summary collapse
-
#disclaimer ⇒ String
A disclaimer about the exchange rates returned.
-
#exchange_rates ⇒ List of ExchangeRateModel
An array of ExchangeRate objects.
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(disclaimer = nil, exchange_rates = nil) ⇒ ExchangeRateResponseModel
constructor
A new instance of ExchangeRateResponseModel.
Methods inherited from BaseModel
Constructor Details
#initialize(disclaimer = nil, exchange_rates = nil) ⇒ ExchangeRateResponseModel
Returns a new instance of ExchangeRateResponseModel.
23 24 25 26 27 |
# File 'lib/raas/models/exchange_rate_response_model.rb', line 23 def initialize(disclaimer = nil, exchange_rates = nil) @disclaimer = disclaimer @exchange_rates = exchange_rates end |
Instance Attribute Details
#disclaimer ⇒ String
A disclaimer about the exchange rates returned
9 10 11 |
# File 'lib/raas/models/exchange_rate_response_model.rb', line 9 def disclaimer @disclaimer end |
#exchange_rates ⇒ List of ExchangeRateModel
An array of ExchangeRate objects
13 14 15 |
# File 'lib/raas/models/exchange_rate_response_model.rb', line 13 def exchange_rates @exchange_rates end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/raas/models/exchange_rate_response_model.rb', line 30 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. disclaimer = hash['disclaimer'] # Parameter is an array, so we need to iterate through it exchange_rates = nil unless hash['exchangeRates'].nil? exchange_rates = [] hash['exchangeRates'].each do |structure| exchange_rates << (ExchangeRateModel.from_hash(structure) if structure) end end # Create object from extracted values. ExchangeRateResponseModel.new(disclaimer, exchange_rates) end |
.names ⇒ Object
A mapping from model property names to API property names.
16 17 18 19 20 21 |
# File 'lib/raas/models/exchange_rate_response_model.rb', line 16 def self.names @_hash = {} if @_hash.nil? @_hash['disclaimer'] = 'disclaimer' @_hash['exchange_rates'] = 'exchangeRates' @_hash end |