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](developer.paypal.com/api/rest/reference/currency-codes/) that identifies the currency.
-
#value ⇒ String
The value, which might be: An integer for currencies like ‘JPY` that are not typically fractional.
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.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(currency_code:, value:) ⇒ Money
Returns a new instance of Money.
45 46 47 48 |
# File 'lib/paypal_server_sdk/models/money.rb', line 45 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](developer.paypal.com/api/rest/reference/currency-codes/) that identifies the currency.
17 18 19 |
# File 'lib/paypal_server_sdk/models/money.rb', line 17 def currency_code @currency_code end |
#value ⇒ String
The value, which might be: An integer for currencies like ‘JPY` that are not typically fractional. A decimal fraction for currencies like `TND` that are subdivided into thousandths. For the required number of decimal places for a currency code, see [Currency Codes](developer.paypal.com/api/rest/reference/currency-codes/).
25 26 27 |
# File 'lib/paypal_server_sdk/models/money.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 |
# File 'lib/paypal_server_sdk/models/money.rb', line 51 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.
28 29 30 31 32 33 |
# File 'lib/paypal_server_sdk/models/money.rb', line 28 def self.names @_hash = {} if @_hash.nil? @_hash['currency_code'] = 'currency_code' @_hash['value'] = 'value' @_hash end |
.nullables ⇒ Object
An array for nullable fields
41 42 43 |
# File 'lib/paypal_server_sdk/models/money.rb', line 41 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
36 37 38 |
# File 'lib/paypal_server_sdk/models/money.rb', line 36 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
70 71 72 73 |
# File 'lib/paypal_server_sdk/models/money.rb', line 70 def inspect class_name = self.class.name.split('::').last "<#{class_name} currency_code: #{@currency_code.inspect}, value: #{@value.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
64 65 66 67 |
# File 'lib/paypal_server_sdk/models/money.rb', line 64 def to_s class_name = self.class.name.split('::').last "<#{class_name} currency_code: #{@currency_code}, value: #{@value}>" end |