Class: CyberSourceMergedSpec::AmountDetails12

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/cyber_source_merged_spec/models/amount_details12.rb

Overview

AmountDetails12 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(cashback_amount: SKIP, settlement_amount: SKIP, settlement_currency: SKIP, exchange_rate: SKIP, foreign_amount: SKIP, foreign_currency: SKIP, additional_properties: nil) ⇒ AmountDetails12

Returns a new instance of AmountDetails12.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/cyber_source_merged_spec/models/amount_details12.rb', line 75

def initialize(cashback_amount: SKIP, settlement_amount: SKIP,
               settlement_currency: SKIP, exchange_rate: SKIP,
               foreign_amount: SKIP, foreign_currency: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @cashback_amount = cashback_amount unless cashback_amount == SKIP
  @settlement_amount = settlement_amount unless settlement_amount == SKIP
  @settlement_currency = settlement_currency unless settlement_currency == SKIP
  @exchange_rate = exchange_rate unless exchange_rate == SKIP
  @foreign_amount = foreign_amount unless foreign_amount == SKIP
  @foreign_currency = foreign_currency unless foreign_currency == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#cashback_amountString

This field contains the purchase cashback amount expressed in the acquirer transaction currency. Use this field only for clearing with your acquirer.

Returns:

  • (String)


16
17
18
# File 'lib/cyber_source_merged_spec/models/amount_details12.rb', line 16

def cashback_amount
  @cashback_amount
end

#exchange_rateString

Exchange rate returned by the DCC service. Includes a decimal point and a maximum of 4 decimal places.

Returns:

  • (String)


34
35
36
# File 'lib/cyber_source_merged_spec/models/amount_details12.rb', line 34

def exchange_rate
  @exchange_rate
end

#foreign_amountString

Set this field to the converted amount that was returned by the DCC provider.

Returns:

  • (String)


39
40
41
# File 'lib/cyber_source_merged_spec/models/amount_details12.rb', line 39

def foreign_amount
  @foreign_amount
end

#foreign_currencyString

Set this field to the converted amount that was returned by the DCC provider.

Returns:

  • (String)


44
45
46
# File 'lib/cyber_source_merged_spec/models/amount_details12.rb', line 44

def foreign_currency
  @foreign_currency
end

#settlement_amountString

This is a multicurrency field. It contains the transaction amount (field 4), converted to the Currency used to bill the cardholder’s account. This field is returned for OCT transactions.

Returns:

  • (String)


22
23
24
# File 'lib/cyber_source_merged_spec/models/amount_details12.rb', line 22

def settlement_amount
  @settlement_amount
end

#settlement_currencyString

This is a multicurrency-only field. It contains a 3-digit numeric code that identifies the currency used by the issuer to bill the cardholder's account. This field is returned for OCT transactions.

Returns:

  • (String)


29
30
31
# File 'lib/cyber_source_merged_spec/models/amount_details12.rb', line 29

def settlement_currency
  @settlement_currency
end

Class Method Details

.from_element(root) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/cyber_source_merged_spec/models/amount_details12.rb', line 124

def self.from_element(root)
  cashback_amount = XmlUtilities.from_element(root, 'cashbackAmount',
                                              String)
  settlement_amount = XmlUtilities.from_element(root, 'settlementAmount',
                                                String)
  settlement_currency = XmlUtilities.from_element(root,
                                                  'settlementCurrency',
                                                  String)
  exchange_rate = XmlUtilities.from_element(root, 'exchangeRate', String)
  foreign_amount = XmlUtilities.from_element(root, 'foreignAmount', String)
  foreign_currency = XmlUtilities.from_element(root, 'foreignCurrency',
                                               String)

  new(cashback_amount: cashback_amount,
      settlement_amount: settlement_amount,
      settlement_currency: settlement_currency,
      exchange_rate: exchange_rate,
      foreign_amount: foreign_amount,
      foreign_currency: foreign_currency,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/cyber_source_merged_spec/models/amount_details12.rb', line 92

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  cashback_amount =
    hash.key?('cashbackAmount') ? hash['cashbackAmount'] : SKIP
  settlement_amount =
    hash.key?('settlementAmount') ? hash['settlementAmount'] : SKIP
  settlement_currency =
    hash.key?('settlementCurrency') ? hash['settlementCurrency'] : SKIP
  exchange_rate = hash.key?('exchangeRate') ? hash['exchangeRate'] : SKIP
  foreign_amount = hash.key?('foreignAmount') ? hash['foreignAmount'] : SKIP
  foreign_currency =
    hash.key?('foreignCurrency') ? hash['foreignCurrency'] : 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.
  AmountDetails12.new(cashback_amount: cashback_amount,
                      settlement_amount: settlement_amount,
                      settlement_currency: settlement_currency,
                      exchange_rate: exchange_rate,
                      foreign_amount: foreign_amount,
                      foreign_currency: foreign_currency,
                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



47
48
49
50
51
52
53
54
55
56
# File 'lib/cyber_source_merged_spec/models/amount_details12.rb', line 47

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['cashback_amount'] = 'cashbackAmount'
  @_hash['settlement_amount'] = 'settlementAmount'
  @_hash['settlement_currency'] = 'settlementCurrency'
  @_hash['exchange_rate'] = 'exchangeRate'
  @_hash['foreign_amount'] = 'foreignAmount'
  @_hash['foreign_currency'] = 'foreignCurrency'
  @_hash
end

.nullablesObject

An array for nullable fields



71
72
73
# File 'lib/cyber_source_merged_spec/models/amount_details12.rb', line 71

def self.nullables
  []
end

.optionalsObject

An array for optional fields



59
60
61
62
63
64
65
66
67
68
# File 'lib/cyber_source_merged_spec/models/amount_details12.rb', line 59

def self.optionals
  %w[
    cashback_amount
    settlement_amount
    settlement_currency
    exchange_rate
    foreign_amount
    foreign_currency
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



175
176
177
178
179
180
181
182
# File 'lib/cyber_source_merged_spec/models/amount_details12.rb', line 175

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} cashback_amount: #{@cashback_amount.inspect}, settlement_amount:"\
  " #{@settlement_amount.inspect}, settlement_currency: #{@settlement_currency.inspect},"\
  " exchange_rate: #{@exchange_rate.inspect}, foreign_amount: #{@foreign_amount.inspect},"\
  " foreign_currency: #{@foreign_currency.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



166
167
168
169
170
171
172
# File 'lib/cyber_source_merged_spec/models/amount_details12.rb', line 166

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} cashback_amount: #{@cashback_amount}, settlement_amount:"\
  " #{@settlement_amount}, settlement_currency: #{@settlement_currency}, exchange_rate:"\
  " #{@exchange_rate}, foreign_amount: #{@foreign_amount}, foreign_currency:"\
  " #{@foreign_currency}, additional_properties: #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/cyber_source_merged_spec/models/amount_details12.rb', line 146

def to_xml_element(doc, root_name)
  root = doc.create_element(root_name)

  XmlUtilities.add_as_subelement(doc, root, 'cashbackAmount',
                                 cashback_amount)
  XmlUtilities.add_as_subelement(doc, root, 'settlementAmount',
                                 settlement_amount)
  XmlUtilities.add_as_subelement(doc, root, 'settlementCurrency',
                                 settlement_currency)
  XmlUtilities.add_as_subelement(doc, root, 'exchangeRate', exchange_rate)
  XmlUtilities.add_as_subelement(doc, root, 'foreignAmount', foreign_amount)
  XmlUtilities.add_as_subelement(doc, root, 'foreignCurrency',
                                 foreign_currency)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end