Class: PaypalServerSdk::AmountWithBreakdown

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

Overview

The total order amount with an optional breakdown that provides details, such as the total item amount, total tax amount, shipping, handling, insurance, and discounts, if any.<br/>If you specify ‘amount.breakdown`, the amount equals `item_total` plus `tax_total` plus `shipping` plus `handling` plus `insurance` minus `shipping_discount` minus discount.<br/>The amount must be a positive number. For listed of supported currencies and decimal precision, see the PayPal REST APIs <a href=“/docs/integration/direct/rest/currency-codes/”>Currency Codes</a>.

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:, breakdown: SKIP) ⇒ AmountWithBreakdown

Returns a new instance of AmountWithBreakdown.



59
60
61
62
63
# File 'lib/paypal_server_sdk/models/amount_with_breakdown.rb', line 59

def initialize(currency_code:, value:, breakdown: SKIP)
  @currency_code = currency_code
  @value = value
  @breakdown = breakdown unless breakdown == SKIP
end

Instance Attribute Details

#breakdownAmountBreakdown

The breakdown of the amount. Breakdown provides details such as total item amount, total tax amount, shipping, handling, insurance, and discounts, if any.

Returns:



36
37
38
# File 'lib/paypal_server_sdk/models/amount_with_breakdown.rb', line 36

def breakdown
  @breakdown
end

#currency_codeString

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

Returns:

  • (String)


22
23
24
# File 'lib/paypal_server_sdk/models/amount_with_breakdown.rb', line 22

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)


30
31
32
# File 'lib/paypal_server_sdk/models/amount_with_breakdown.rb', line 30

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/paypal_server_sdk/models/amount_with_breakdown.rb', line 66

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
  breakdown = AmountBreakdown.from_hash(hash['breakdown']) if hash['breakdown']

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

.namesObject

A mapping from model property names to API property names.



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

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

.nullablesObject

An array for nullable fields



55
56
57
# File 'lib/paypal_server_sdk/models/amount_with_breakdown.rb', line 55

def self.nullables
  []
end

.optionalsObject

An array for optional fields



48
49
50
51
52
# File 'lib/paypal_server_sdk/models/amount_with_breakdown.rb', line 48

def self.optionals
  %w[
    breakdown
  ]
end