Class: Raas::CurrencyBreakdownModel

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/raas/models/currency_breakdown_model.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(currency_code = nil, exchange_rate = nil, fee = nil, total = nil, value = nil) ⇒ CurrencyBreakdownModel

Returns a new instance of CurrencyBreakdownModel.



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/raas/models/currency_breakdown_model.rb', line 38

def initialize(currency_code = nil,
               exchange_rate = nil,
               fee = nil,
               total = nil,
               value = nil)
  @currency_code = currency_code
  @exchange_rate = exchange_rate
  @fee = fee
  @total = total
  @value = value
end

Instance Attribute Details

#currency_codeString

Currency Code

Returns:



7
8
9
# File 'lib/raas/models/currency_breakdown_model.rb', line 7

def currency_code
  @currency_code
end

#exchange_rateFloat

Exchange Rate

Returns:

  • (Float)


11
12
13
# File 'lib/raas/models/currency_breakdown_model.rb', line 11

def exchange_rate
  @exchange_rate
end

#feeFloat

Fee

Returns:

  • (Float)


15
16
17
# File 'lib/raas/models/currency_breakdown_model.rb', line 15

def fee
  @fee
end

#totalFloat

Total

Returns:

  • (Float)


19
20
21
# File 'lib/raas/models/currency_breakdown_model.rb', line 19

def total
  @total
end

#valueFloat

Value

Returns:

  • (Float)


23
24
25
# File 'lib/raas/models/currency_breakdown_model.rb', line 23

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/raas/models/currency_breakdown_model.rb', line 51

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash
  currency_code = hash['currencyCode']
  exchange_rate = hash['exchangeRate']
  fee = hash['fee']
  total = hash['total']
  value = hash['value']

  # Create object from extracted values
  CurrencyBreakdownModel.new(currency_code,
                             exchange_rate,
                             fee,
                             total,
                             value)
end

.namesObject

A mapping from model property names to API property names



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/raas/models/currency_breakdown_model.rb', line 26

def self.names
  if @_hash.nil?
    @_hash = {}
    @_hash["currency_code"] = "currencyCode"
    @_hash["exchange_rate"] = "exchangeRate"
    @_hash["fee"] = "fee"
    @_hash["total"] = "total"
    @_hash["value"] = "value"
  end
  @_hash
end