Class: PaypalServerSdk::SubscriptionAmountWithBreakdown

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

Overview

The breakdown details for the amount. Includes the gross, tax, fee, and shipping amounts.

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(gross_amount:, total_item_amount: SKIP, fee_amount: SKIP, shipping_amount: SKIP, tax_amount: SKIP, net_amount: SKIP) ⇒ SubscriptionAmountWithBreakdown

Returns a new instance of SubscriptionAmountWithBreakdown.



71
72
73
74
75
76
77
78
79
# File 'lib/paypal_server_sdk/models/subscription_amount_with_breakdown.rb', line 71

def initialize(gross_amount:, total_item_amount: SKIP, fee_amount: SKIP,
               shipping_amount: SKIP, tax_amount: SKIP, net_amount: SKIP)
  @gross_amount = gross_amount
  @total_item_amount = total_item_amount unless total_item_amount == SKIP
  @fee_amount = fee_amount unless fee_amount == SKIP
  @shipping_amount = shipping_amount unless shipping_amount == SKIP
  @tax_amount = tax_amount unless tax_amount == SKIP
  @net_amount = net_amount unless net_amount == SKIP
end

Instance Attribute Details

#fee_amountMoney

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

Returns:



26
27
28
# File 'lib/paypal_server_sdk/models/subscription_amount_with_breakdown.rb', line 26

def fee_amount
  @fee_amount
end

#gross_amountMoney

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

Returns:



16
17
18
# File 'lib/paypal_server_sdk/models/subscription_amount_with_breakdown.rb', line 16

def gross_amount
  @gross_amount
end

#net_amountMoney

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

Returns:



41
42
43
# File 'lib/paypal_server_sdk/models/subscription_amount_with_breakdown.rb', line 41

def net_amount
  @net_amount
end

#shipping_amountMoney

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

Returns:



31
32
33
# File 'lib/paypal_server_sdk/models/subscription_amount_with_breakdown.rb', line 31

def shipping_amount
  @shipping_amount
end

#tax_amountMoney

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

Returns:



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

def tax_amount
  @tax_amount
end

#total_item_amountMoney

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

Returns:



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

def total_item_amount
  @total_item_amount
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/paypal_server_sdk/models/subscription_amount_with_breakdown.rb', line 82

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  gross_amount = Money.from_hash(hash['gross_amount']) if hash['gross_amount']
  total_item_amount = Money.from_hash(hash['total_item_amount']) if hash['total_item_amount']
  fee_amount = Money.from_hash(hash['fee_amount']) if hash['fee_amount']
  shipping_amount = Money.from_hash(hash['shipping_amount']) if hash['shipping_amount']
  tax_amount = Money.from_hash(hash['tax_amount']) if hash['tax_amount']
  net_amount = Money.from_hash(hash['net_amount']) if hash['net_amount']

  # Create object from extracted values.
  SubscriptionAmountWithBreakdown.new(gross_amount: gross_amount,
                                      total_item_amount: total_item_amount,
                                      fee_amount: fee_amount,
                                      shipping_amount: shipping_amount,
                                      tax_amount: tax_amount,
                                      net_amount: net_amount)
end

.namesObject

A mapping from model property names to API property names.



44
45
46
47
48
49
50
51
52
53
# File 'lib/paypal_server_sdk/models/subscription_amount_with_breakdown.rb', line 44

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['gross_amount'] = 'gross_amount'
  @_hash['total_item_amount'] = 'total_item_amount'
  @_hash['fee_amount'] = 'fee_amount'
  @_hash['shipping_amount'] = 'shipping_amount'
  @_hash['tax_amount'] = 'tax_amount'
  @_hash['net_amount'] = 'net_amount'
  @_hash
end

.nullablesObject

An array for nullable fields



67
68
69
# File 'lib/paypal_server_sdk/models/subscription_amount_with_breakdown.rb', line 67

def self.nullables
  []
end

.optionalsObject

An array for optional fields



56
57
58
59
60
61
62
63
64
# File 'lib/paypal_server_sdk/models/subscription_amount_with_breakdown.rb', line 56

def self.optionals
  %w[
    total_item_amount
    fee_amount
    shipping_amount
    tax_amount
    net_amount
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



111
112
113
114
115
116
117
# File 'lib/paypal_server_sdk/models/subscription_amount_with_breakdown.rb', line 111

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} gross_amount: #{@gross_amount.inspect}, total_item_amount:"\
  " #{@total_item_amount.inspect}, fee_amount: #{@fee_amount.inspect}, shipping_amount:"\
  " #{@shipping_amount.inspect}, tax_amount: #{@tax_amount.inspect}, net_amount:"\
  " #{@net_amount.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



103
104
105
106
107
108
# File 'lib/paypal_server_sdk/models/subscription_amount_with_breakdown.rb', line 103

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} gross_amount: #{@gross_amount}, total_item_amount: #{@total_item_amount},"\
  " fee_amount: #{@fee_amount}, shipping_amount: #{@shipping_amount}, tax_amount:"\
  " #{@tax_amount}, net_amount: #{@net_amount}>"
end