Class: Raas::ExchangeRateModel
- Defined in:
- lib/raas/models/exchange_rate_model.rb
Overview
Represents an Exchange Rate
Instance Attribute Summary collapse
-
#base_currency ⇒ String
The base currency.
-
#base_fx ⇒ Float
The exchange rate.
-
#last_modified_date ⇒ DateTime
When the exchange rate was last updated.
-
#reward_currency ⇒ String
The reward currency.
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(last_modified_date = nil, reward_currency = nil, base_currency = nil, base_fx = nil) ⇒ ExchangeRateModel
constructor
A new instance of ExchangeRateModel.
Methods inherited from BaseModel
Constructor Details
#initialize(last_modified_date = nil, reward_currency = nil, base_currency = nil, base_fx = nil) ⇒ ExchangeRateModel
Returns a new instance of ExchangeRateModel.
34 35 36 37 38 39 40 41 42 |
# File 'lib/raas/models/exchange_rate_model.rb', line 34 def initialize(last_modified_date = nil, reward_currency = nil, base_currency = nil, base_fx = nil) @last_modified_date = last_modified_date @reward_currency = reward_currency @base_currency = base_currency @base_fx = base_fx end |
Instance Attribute Details
#base_currency ⇒ String
The base currency
18 19 20 |
# File 'lib/raas/models/exchange_rate_model.rb', line 18 def base_currency @base_currency end |
#base_fx ⇒ Float
The exchange rate
22 23 24 |
# File 'lib/raas/models/exchange_rate_model.rb', line 22 def base_fx @base_fx end |
#last_modified_date ⇒ DateTime
When the exchange rate was last updated
10 11 12 |
# File 'lib/raas/models/exchange_rate_model.rb', line 10 def last_modified_date @last_modified_date end |
#reward_currency ⇒ String
The reward currency
14 15 16 |
# File 'lib/raas/models/exchange_rate_model.rb', line 14 def reward_currency @reward_currency end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/raas/models/exchange_rate_model.rb', line 45 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. last_modified_date = APIHelper.rfc3339(hash['lastModifiedDate']) if hash['lastModifiedDate'] reward_currency = hash['rewardCurrency'] base_currency = hash['baseCurrency'] base_fx = hash['baseFx'] # Create object from extracted values. ExchangeRateModel.new(last_modified_date, reward_currency, base_currency, base_fx) end |
.names ⇒ Object
A mapping from model property names to API property names.
25 26 27 28 29 30 31 32 |
# File 'lib/raas/models/exchange_rate_model.rb', line 25 def self.names @_hash = {} if @_hash.nil? @_hash['last_modified_date'] = 'lastModifiedDate' @_hash['reward_currency'] = 'rewardCurrency' @_hash['base_currency'] = 'baseCurrency' @_hash['base_fx'] = 'baseFx' @_hash end |