Class: PaypalServerSdk::Money
- 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
-
#currency_code ⇒ String
The [three-character ISO-4217 currency code](/api/rest/reference/currency-codes/) that identifies the currency.
-
#value ⇒ String
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/).
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(currency_code:, value:) ⇒ Money
constructor
A new instance of Money.
Methods inherited from BaseModel
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_code ⇒ String
The [three-character ISO-4217 currency code](/api/rest/reference/currency-codes/) that identifies the currency.
16 17 18 |
# File 'lib/paypal_server_sdk/models/money.rb', line 16 def currency_code @currency_code end |
#value ⇒ String
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/).
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 |
.names ⇒ Object
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 |
.nullables ⇒ Object
An array for nullable fields
40 41 42 |
# File 'lib/paypal_server_sdk/models/money.rb', line 40 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
35 36 37 |
# File 'lib/paypal_server_sdk/models/money.rb', line 35 def self.optionals [] end |