Class: PaypalServerSdk::Money

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

Overview

The currency and amount for a financial transaction, such as a balance or payment due.

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:, value:) ⇒ Money

Returns a new instance of Money.



44
45
46
47
# File 'lib/paypal_server_sdk/models/money.rb', line 44

def initialize(currency_code:, value:)
  @currency_code = currency_code
  @value = value
end

Instance Attribute Details

#currency_codeString

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/money.rb', line 16

def currency_code
  @currency_code
end

#valueString

The value, which might be:<ul><li>An integer for currencies like ‘JPY` that are not typically fractional.</li><li>A decimal fraction for currencies like `TND` that are subdivided into thousandths.</li></ul>For the required number of decimal places for a currency code, see [Currency Codes](/api/rest/reference/currency-codes/).

Returns:

  • (String)


24
25
26
# File 'lib/paypal_server_sdk/models/money.rb', line 24

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/paypal_server_sdk/models/money.rb', line 50

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  currency_code = hash.key?('currency_code') ? hash['currency_code'] : nil
  value = hash.key?('value') ? hash['value'] : nil

  # Create object from extracted values.
  Money.new(currency_code: currency_code,
            value: value)
end

.namesObject

A mapping from model property names to API property names.



27
28
29
30
31
32
# File 'lib/paypal_server_sdk/models/money.rb', line 27

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

.nullablesObject

An array for nullable fields



40
41
42
# File 'lib/paypal_server_sdk/models/money.rb', line 40

def self.nullables
  []
end

.optionalsObject

An array for optional fields



35
36
37
# File 'lib/paypal_server_sdk/models/money.rb', line 35

def self.optionals
  []
end