Class: Raas::ExchangeRateModel

Inherits:
BaseModel show all
Defined in:
lib/raas/models/exchange_rate_model.rb

Overview

Represents an Exchange Rate

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

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_currencyString

The base currency

Returns:



18
19
20
# File 'lib/raas/models/exchange_rate_model.rb', line 18

def base_currency
  @base_currency
end

#base_fxFloat

The exchange rate

Returns:

  • (Float)


22
23
24
# File 'lib/raas/models/exchange_rate_model.rb', line 22

def base_fx
  @base_fx
end

#last_modified_dateDateTime

When the exchange rate was last updated

Returns:

  • (DateTime)


10
11
12
# File 'lib/raas/models/exchange_rate_model.rb', line 10

def last_modified_date
  @last_modified_date
end

#reward_currencyString

The reward currency

Returns:



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

.namesObject

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