Class: PaypalServerSdk::AmountBreakdown

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

Overview

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(item_total: SKIP, shipping: SKIP, handling: SKIP, tax_total: SKIP, insurance: SKIP, shipping_discount: SKIP, discount: SKIP) ⇒ AmountBreakdown

Returns a new instance of AmountBreakdown.



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/paypal_server_sdk/models/amount_breakdown.rb', line 80

def initialize(item_total: SKIP, shipping: SKIP, handling: SKIP,
               tax_total: SKIP, insurance: SKIP, shipping_discount: SKIP,
               discount: SKIP)
  @item_total = item_total unless item_total == SKIP
  @shipping = shipping unless shipping == SKIP
  @handling = handling unless handling == SKIP
  @tax_total = tax_total unless tax_total == SKIP
  @insurance = insurance unless insurance == SKIP
  @shipping_discount = shipping_discount unless shipping_discount == SKIP
  @discount = discount unless discount == SKIP
end

Instance Attribute Details

#discountMoney

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

Returns:



47
48
49
# File 'lib/paypal_server_sdk/models/amount_breakdown.rb', line 47

def discount
  @discount
end

#handlingMoney

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

Returns:



27
28
29
# File 'lib/paypal_server_sdk/models/amount_breakdown.rb', line 27

def handling
  @handling
end

#insuranceMoney

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

Returns:



37
38
39
# File 'lib/paypal_server_sdk/models/amount_breakdown.rb', line 37

def insurance
  @insurance
end

#item_totalMoney

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

Returns:



17
18
19
# File 'lib/paypal_server_sdk/models/amount_breakdown.rb', line 17

def item_total
  @item_total
end

#shippingMoney

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

Returns:



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

def shipping
  @shipping
end

#shipping_discountMoney

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

Returns:



42
43
44
# File 'lib/paypal_server_sdk/models/amount_breakdown.rb', line 42

def shipping_discount
  @shipping_discount
end

#tax_totalMoney

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

Returns:



32
33
34
# File 'lib/paypal_server_sdk/models/amount_breakdown.rb', line 32

def tax_total
  @tax_total
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/paypal_server_sdk/models/amount_breakdown.rb', line 93

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  item_total = Money.from_hash(hash['item_total']) if hash['item_total']
  shipping = Money.from_hash(hash['shipping']) if hash['shipping']
  handling = Money.from_hash(hash['handling']) if hash['handling']
  tax_total = Money.from_hash(hash['tax_total']) if hash['tax_total']
  insurance = Money.from_hash(hash['insurance']) if hash['insurance']
  shipping_discount = Money.from_hash(hash['shipping_discount']) if hash['shipping_discount']
  discount = Money.from_hash(hash['discount']) if hash['discount']

  # Create object from extracted values.
  AmountBreakdown.new(item_total: item_total,
                      shipping: shipping,
                      handling: handling,
                      tax_total: tax_total,
                      insurance: insurance,
                      shipping_discount: shipping_discount,
                      discount: discount)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['item_total'] = 'item_total'
  @_hash['shipping'] = 'shipping'
  @_hash['handling'] = 'handling'
  @_hash['tax_total'] = 'tax_total'
  @_hash['insurance'] = 'insurance'
  @_hash['shipping_discount'] = 'shipping_discount'
  @_hash['discount'] = 'discount'
  @_hash
end

.nullablesObject

An array for nullable fields



76
77
78
# File 'lib/paypal_server_sdk/models/amount_breakdown.rb', line 76

def self.nullables
  []
end

.optionalsObject

An array for optional fields



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/paypal_server_sdk/models/amount_breakdown.rb', line 63

def self.optionals
  %w[
    item_total
    shipping
    handling
    tax_total
    insurance
    shipping_discount
    discount
  ]
end