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

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

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

Returns a new instance of ExchangeRate.



54
55
56
57
58
# File 'lib/paypal_server_sdk/models/exchange_rate.rb', line 54

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](developer.paypal.com/api/rest/reference/currency-codes/) that identifies the currency.

Returns:

  • (String)


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

def source_currency
  @source_currency
end

#target_currencyString

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

Returns:

  • (String)


23
24
25
# File 'lib/paypal_server_sdk/models/exchange_rate.rb', line 23

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)


29
30
31
# File 'lib/paypal_server_sdk/models/exchange_rate.rb', line 29

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

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.



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

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



50
51
52
# File 'lib/paypal_server_sdk/models/exchange_rate.rb', line 50

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



85
86
87
88
89
# File 'lib/paypal_server_sdk/models/exchange_rate.rb', line 85

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} source_currency: #{@source_currency.inspect}, target_currency:"\
  " #{@target_currency.inspect}, value: #{@value.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



78
79
80
81
82
# File 'lib/paypal_server_sdk/models/exchange_rate.rb', line 78

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} source_currency: #{@source_currency}, target_currency: #{@target_currency},"\
  " value: #{@value}>"
end