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. If you specify ‘amount.breakdown`, the amount equals `item_total` plus `tax_total` plus `shipping` plus `handling` plus `insurance` minus `shipping_discount` minus discount. The amount must be a positive number. For listed of supported currencies and decimal precision, see the PayPal REST APIs Currency Codes.

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

Returns a new instance of AmountWithBreakdown.



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

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:



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

def breakdown
  @breakdown
end

#currency_codeString

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

Returns:

  • (String)


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

def currency_code
  @currency_code
end

#valueString

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](/api/rest/reference/currency-codes/).

Returns:

  • (String)


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

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

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.



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

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



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    breakdown
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



87
88
89
90
91
# File 'lib/paypal_server_sdk/models/amount_with_breakdown.rb', line 87

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

#to_sObject

Provides a human-readable string representation of the object.



80
81
82
83
84
# File 'lib/paypal_server_sdk/models/amount_with_breakdown.rb', line 80

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