Class: Raas::CurrencyBreakdownModel

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

Overview

Represents a breakdown of an amount and currency information

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

A 3 digit currency code

Returns:



9
10
11
# File 'lib/raas/models/currency_breakdown_model.rb', line 9

def currency_code
  @currency_code
end

#exchange_rateFloat

The exchange rate

Returns:

  • (Float)


13
14
15
# File 'lib/raas/models/currency_breakdown_model.rb', line 13

def exchange_rate
  @exchange_rate
end

#feeFloat

The amount of the fee applied

Returns:

  • (Float)


17
18
19
# File 'lib/raas/models/currency_breakdown_model.rb', line 17

def fee
  @fee
end

#totalFloat

The order total

Returns:

  • (Float)


21
22
23
# File 'lib/raas/models/currency_breakdown_model.rb', line 21

def total
  @total
end

#valueFloat

The value of the order

Returns:

  • (Float)


25
26
27
# File 'lib/raas/models/currency_breakdown_model.rb', line 25

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.



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

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