Class: VisaAcceptanceMergedSpec::AmountDetails26

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/visa_acceptance_merged_spec/models/amount_details26.rb

Overview

AmountDetails26 Model.

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(total_amount: SKIP, currency: SKIP, sub_total_amount: SKIP, handling_amount: SKIP, shipping_amount: SKIP, shipping_discount_amount: SKIP, tax_amount: SKIP, insurance_amount: SKIP, gift_wrap_amount: SKIP, additional_properties: nil) ⇒ AmountDetails26

Returns a new instance of AmountDetails26.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/visa_acceptance_merged_spec/models/amount_details26.rb', line 105

def initialize(total_amount: SKIP, currency: SKIP, sub_total_amount: SKIP,
               handling_amount: SKIP, shipping_amount: SKIP,
               shipping_discount_amount: SKIP, tax_amount: SKIP,
               insurance_amount: SKIP, gift_wrap_amount: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @total_amount = total_amount unless total_amount == SKIP
  @currency = currency unless currency == SKIP
  @sub_total_amount = sub_total_amount unless sub_total_amount == SKIP
  @handling_amount = handling_amount unless handling_amount == SKIP
  @shipping_amount = shipping_amount unless shipping_amount == SKIP
  @shipping_discount_amount = shipping_discount_amount unless shipping_discount_amount == SKIP
  @tax_amount = tax_amount unless tax_amount == SKIP
  @insurance_amount = insurance_amount unless insurance_amount == SKIP
  @gift_wrap_amount = gift_wrap_amount unless gift_wrap_amount == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#currencyString

Currency used for the order

Returns:

  • (String)


21
22
23
# File 'lib/visa_acceptance_merged_spec/models/amount_details26.rb', line 21

def currency
  @currency
end

#gift_wrap_amountString

Amount being charged as gift wrap fee.

Returns:

  • (String)


68
69
70
# File 'lib/visa_acceptance_merged_spec/models/amount_details26.rb', line 68

def gift_wrap_amount
  @gift_wrap_amount
end

#handling_amountString

Aggregate handling charges for the transaction. If this amount has changed since the initial sessions request, you must include the new value in the order request. You must also include all additional amount fields that apply to the order and ensure the total amount equals the purchaseTotals_grandTotalAmount value.

Returns:

  • (String)


37
38
39
# File 'lib/visa_acceptance_merged_spec/models/amount_details26.rb', line 37

def handling_amount
  @handling_amount
end

#insurance_amountString

Amount being charged for the insurance fee. Only supported when the payment_method is set to paypal.

Returns:

  • (String)


64
65
66
# File 'lib/visa_acceptance_merged_spec/models/amount_details26.rb', line 64

def insurance_amount
  @insurance_amount
end

#shipping_amountString

Aggregate shipping charges for the transaction If this amount has changed since the initial sessions request, you must include the new value in the order request. You must also include all additional amount fields that apply to the order and ensure the total amount equals the purchaseTotals_grandTotalAmount value.

Returns:

  • (String)


45
46
47
# File 'lib/visa_acceptance_merged_spec/models/amount_details26.rb', line 45

def shipping_amount
  @shipping_amount
end

#shipping_discount_amountString

Shipping discount amount for the transaction. If this amount has changed since the initial sessions request, you must include the new value in the order request. You must also include all additional amount fields that apply to the order and ensure the total amount equals the purchaseTotals_grandTotalAmount value.

Returns:

  • (String)


53
54
55
# File 'lib/visa_acceptance_merged_spec/models/amount_details26.rb', line 53

def shipping_discount_amount
  @shipping_discount_amount
end

#sub_total_amountString

Shipping discount amount for the transaction. If this amount has changed since the initial sessions request, you must include the new value in the order request. You must also include all additional amount fields that apply to the order and ensure the total amount equals the purchaseTotals_grandTotalAmount value.

Returns:

  • (String)


29
30
31
# File 'lib/visa_acceptance_merged_spec/models/amount_details26.rb', line 29

def sub_total_amount
  @sub_total_amount
end

#tax_amountString

Total tax amount. When the purchaseTotals_ taxAmount and ap_subtotalAmount fields are included in the request, do not include the tax amount as part of the subtotal amount calculation.

Returns:

  • (String)


59
60
61
# File 'lib/visa_acceptance_merged_spec/models/amount_details26.rb', line 59

def tax_amount
  @tax_amount
end

#total_amountString

Grand total for the order. This value cannot be negative. You can include a decimal point (.), but you cannot include any other special characters. Visa Acceptance truncates the amount to the correct number of decimal places

Returns:

  • (String)


17
18
19
# File 'lib/visa_acceptance_merged_spec/models/amount_details26.rb', line 17

def total_amount
  @total_amount
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/visa_acceptance_merged_spec/models/amount_details26.rb', line 126

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  total_amount = hash.key?('totalAmount') ? hash['totalAmount'] : SKIP
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  sub_total_amount =
    hash.key?('subTotalAmount') ? hash['subTotalAmount'] : SKIP
  handling_amount =
    hash.key?('handlingAmount') ? hash['handlingAmount'] : SKIP
  shipping_amount =
    hash.key?('shippingAmount') ? hash['shippingAmount'] : SKIP
  shipping_discount_amount =
    hash.key?('shippingDiscountAmount') ? hash['shippingDiscountAmount'] : SKIP
  tax_amount = hash.key?('taxAmount') ? hash['taxAmount'] : SKIP
  insurance_amount =
    hash.key?('insuranceAmount') ? hash['insuranceAmount'] : SKIP
  gift_wrap_amount =
    hash.key?('giftWrapAmount') ? hash['giftWrapAmount'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  AmountDetails26.new(total_amount: total_amount,
                      currency: currency,
                      sub_total_amount: sub_total_amount,
                      handling_amount: handling_amount,
                      shipping_amount: shipping_amount,
                      shipping_discount_amount: shipping_discount_amount,
                      tax_amount: tax_amount,
                      insurance_amount: insurance_amount,
                      gift_wrap_amount: gift_wrap_amount,
                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/visa_acceptance_merged_spec/models/amount_details26.rb', line 71

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['total_amount'] = 'totalAmount'
  @_hash['currency'] = 'currency'
  @_hash['sub_total_amount'] = 'subTotalAmount'
  @_hash['handling_amount'] = 'handlingAmount'
  @_hash['shipping_amount'] = 'shippingAmount'
  @_hash['shipping_discount_amount'] = 'shippingDiscountAmount'
  @_hash['tax_amount'] = 'taxAmount'
  @_hash['insurance_amount'] = 'insuranceAmount'
  @_hash['gift_wrap_amount'] = 'giftWrapAmount'
  @_hash
end

.nullablesObject

An array for nullable fields



101
102
103
# File 'lib/visa_acceptance_merged_spec/models/amount_details26.rb', line 101

def self.nullables
  []
end

.optionalsObject

An array for optional fields



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/visa_acceptance_merged_spec/models/amount_details26.rb', line 86

def self.optionals
  %w[
    total_amount
    currency
    sub_total_amount
    handling_amount
    shipping_amount
    shipping_discount_amount
    tax_amount
    insurance_amount
    gift_wrap_amount
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



177
178
179
180
181
182
183
184
185
# File 'lib/visa_acceptance_merged_spec/models/amount_details26.rb', line 177

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} total_amount: #{@total_amount.inspect}, currency: #{@currency.inspect},"\
  " sub_total_amount: #{@sub_total_amount.inspect}, handling_amount:"\
  " #{@handling_amount.inspect}, shipping_amount: #{@shipping_amount.inspect},"\
  " shipping_discount_amount: #{@shipping_discount_amount.inspect}, tax_amount:"\
  " #{@tax_amount.inspect}, insurance_amount: #{@insurance_amount.inspect}, gift_wrap_amount:"\
  " #{@gift_wrap_amount.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



167
168
169
170
171
172
173
174
# File 'lib/visa_acceptance_merged_spec/models/amount_details26.rb', line 167

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} total_amount: #{@total_amount}, currency: #{@currency}, sub_total_amount:"\
  " #{@sub_total_amount}, handling_amount: #{@handling_amount}, shipping_amount:"\
  " #{@shipping_amount}, shipping_discount_amount: #{@shipping_discount_amount}, tax_amount:"\
  " #{@tax_amount}, insurance_amount: #{@insurance_amount}, gift_wrap_amount:"\
  " #{@gift_wrap_amount}, additional_properties: #{@additional_properties}>"
end