Class: PaypalServerSdk::ExchangeRate

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/paypal_server_sdk/models/exchange_rate.rb

Overview

The exchange rate that determines the amount to convert from one currency to another currency.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(source_currency: SKIP, target_currency: SKIP, value: SKIP) ⇒ ExchangeRate

Returns a new instance of ExchangeRate.



52
53
54
55
56
# File 'lib/paypal_server_sdk/models/exchange_rate.rb', line 52

def initialize(source_currency: SKIP, target_currency: SKIP, value: SKIP)
  @source_currency = source_currency unless source_currency == SKIP
  @target_currency = target_currency unless target_currency == SKIP
  @value = value unless value == SKIP
end

Instance Attribute Details

#source_currencyString

The [three-character ISO-4217 currency code](/api/rest/reference/currency-codes/) that identifies the currency.

Returns:

  • (String)


16
17
18
# File 'lib/paypal_server_sdk/models/exchange_rate.rb', line 16

def source_currency
  @source_currency
end

#target_currencyString

The [three-character ISO-4217 currency code](/api/rest/reference/currency-codes/) that identifies the currency.

Returns:

  • (String)


21
22
23
# File 'lib/paypal_server_sdk/models/exchange_rate.rb', line 21

def target_currency
  @target_currency
end

#valueString

The target currency amount. Equivalent to one unit of the source currency. Formatted as integer or decimal value with one to 15 digits to the right of the decimal point.

Returns:

  • (String)


27
28
29
# File 'lib/paypal_server_sdk/models/exchange_rate.rb', line 27

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/paypal_server_sdk/models/exchange_rate.rb', line 59

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  source_currency =
    hash.key?('source_currency') ? hash['source_currency'] : SKIP
  target_currency =
    hash.key?('target_currency') ? hash['target_currency'] : SKIP
  value = hash.key?('value') ? hash['value'] : SKIP

  # Create object from extracted values.
  ExchangeRate.new(source_currency: source_currency,
                   target_currency: target_currency,
                   value: value)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
# File 'lib/paypal_server_sdk/models/exchange_rate.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['source_currency'] = 'source_currency'
  @_hash['target_currency'] = 'target_currency'
  @_hash['value'] = 'value'
  @_hash
end

.nullablesObject

An array for nullable fields



48
49
50
# File 'lib/paypal_server_sdk/models/exchange_rate.rb', line 48

def self.nullables
  []
end

.optionalsObject

An array for optional fields



39
40
41
42
43
44
45
# File 'lib/paypal_server_sdk/models/exchange_rate.rb', line 39

def self.optionals
  %w[
    source_currency
    target_currency
    value
  ]
end