Class: VisaAcceptanceMergedSpec::AmountDetails32

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

Overview

AmountDetails32 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, discount_amount: SKIP, shipping_amount: SKIP, shipping_discount_amount: SKIP, tax_amount: SKIP, insurance_amount: SKIP, duty_amount: SKIP, additional_properties: nil) ⇒ AmountDetails32

Returns a new instance of AmountDetails32.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/visa_acceptance_merged_spec/models/amount_details32.rb', line 80

def initialize(total_amount: SKIP, currency: SKIP, discount_amount: SKIP,
               shipping_amount: SKIP, shipping_discount_amount: SKIP,
               tax_amount: SKIP, insurance_amount: SKIP, duty_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
  @discount_amount = discount_amount unless discount_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
  @duty_amount = duty_amount unless duty_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_details32.rb', line 21

def currency
  @currency
end

#discount_amountString

Discount amount for the transaction.

Returns:

  • (String)


25
26
27
# File 'lib/visa_acceptance_merged_spec/models/amount_details32.rb', line 25

def discount_amount
  @discount_amount
end

#duty_amountString

Amount being charged as duty amount.

Returns:

  • (String)


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

def duty_amount
  @duty_amount
end

#insurance_amountString

Amount being charged for the insurance fee.

Returns:

  • (String)


41
42
43
# File 'lib/visa_acceptance_merged_spec/models/amount_details32.rb', line 41

def insurance_amount
  @insurance_amount
end

#shipping_amountString

Aggregate shipping charges for the transactions.

Returns:

  • (String)


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

def shipping_amount
  @shipping_amount
end

#shipping_discount_amountString

Shipping discount amount for the transaction.

Returns:

  • (String)


33
34
35
# File 'lib/visa_acceptance_merged_spec/models/amount_details32.rb', line 33

def shipping_discount_amount
  @shipping_discount_amount
end

#tax_amountString

Total tax amount.

Returns:

  • (String)


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

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_details32.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.



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/visa_acceptance_merged_spec/models/amount_details32.rb', line 99

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
  discount_amount =
    hash.key?('discountAmount') ? hash['discountAmount'] : 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
  duty_amount = hash.key?('dutyAmount') ? hash['dutyAmount'] : 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.
  AmountDetails32.new(total_amount: total_amount,
                      currency: currency,
                      discount_amount: discount_amount,
                      shipping_amount: shipping_amount,
                      shipping_discount_amount: shipping_discount_amount,
                      tax_amount: tax_amount,
                      insurance_amount: insurance_amount,
                      duty_amount: duty_amount,
                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/visa_acceptance_merged_spec/models/amount_details32.rb', line 48

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['total_amount'] = 'totalAmount'
  @_hash['currency'] = 'currency'
  @_hash['discount_amount'] = 'discountAmount'
  @_hash['shipping_amount'] = 'shippingAmount'
  @_hash['shipping_discount_amount'] = 'shippingDiscountAmount'
  @_hash['tax_amount'] = 'taxAmount'
  @_hash['insurance_amount'] = 'insuranceAmount'
  @_hash['duty_amount'] = 'dutyAmount'
  @_hash
end

.nullablesObject

An array for nullable fields



76
77
78
# File 'lib/visa_acceptance_merged_spec/models/amount_details32.rb', line 76

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    total_amount
    currency
    discount_amount
    shipping_amount
    shipping_discount_amount
    tax_amount
    insurance_amount
    duty_amount
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



146
147
148
149
150
151
152
153
154
# File 'lib/visa_acceptance_merged_spec/models/amount_details32.rb', line 146

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

#to_sObject

Provides a human-readable string representation of the object.



136
137
138
139
140
141
142
143
# File 'lib/visa_acceptance_merged_spec/models/amount_details32.rb', line 136

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