Class: CyberSourceMergedSpec::AmountDetails43

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

Overview

AmountDetails43 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:, currency:, service_fee: SKIP, foreign_exchange_fee: SKIP, surcharge: SKIP, additional_properties: nil) ⇒ AmountDetails43

Returns a new instance of AmountDetails43.



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/cyber_source_merged_spec/models/amount_details43.rb', line 72

def initialize(total_amount:, currency:, service_fee: SKIP,
               foreign_exchange_fee: SKIP, surcharge: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @total_amount = total_amount
  @currency = currency
  @service_fee = service_fee unless service_fee == SKIP
  @foreign_exchange_fee = foreign_exchange_fee unless foreign_exchange_fee == SKIP
  @surcharge = surcharge unless surcharge == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#currencyString

Use a 3-character alpha currency code for currency of the sender. ISO standard currencies: [http://apps.cybersource.com/library/documentation/sbc/quickref/currencies .pdf](http://apps.cybersource.com/library/documentation/sbc/quickref/curre ncies.pdf)
Currency must be supported by the processor.

Returns:

  • (String)


25
26
27
# File 'lib/cyber_source_merged_spec/models/amount_details43.rb', line 25

def currency
  @currency
end

#foreign_exchange_feeString

When present, this field contains the sender's foreign exchange markup fee (markup above the wholesale or VisaNet exchange rate as assessed by the originator). Values in this field must be in the same currency and format as defined in the amount field.

Returns:

  • (String)


38
39
40
# File 'lib/cyber_source_merged_spec/models/amount_details43.rb', line 38

def foreign_exchange_fee
  @foreign_exchange_fee
end

#service_feeString

When present, this field contains the sender's surcharge as assessed by the originator. Values in this field must be in the same currency and format as defined in the amount field.

Returns:

  • (String)


31
32
33
# File 'lib/cyber_source_merged_spec/models/amount_details43.rb', line 31

def service_fee
  @service_fee
end

#surchargeSurcharge2

When present, this field contains the sender's foreign exchange markup fee (markup above the wholesale or VisaNet exchange rate as assessed by the originator). Values in this field must be in the same currency and format as defined in the amount field.

Returns:



45
46
47
# File 'lib/cyber_source_merged_spec/models/amount_details43.rb', line 45

def surcharge
  @surcharge
end

#total_amountString

The total amount of the funds transfer including all fees. This value cannot be negative.
You can include a decimal point (.), but no other special characters.

Returns:

  • (String)


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

def total_amount
  @total_amount
end

Class Method Details

.from_element(root) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/cyber_source_merged_spec/models/amount_details43.rb', line 114

def self.from_element(root)
  total_amount = XmlUtilities.from_element(root, 'totalAmount', String)
  currency = XmlUtilities.from_element(root, 'currency', String)
  service_fee = XmlUtilities.from_element(root, 'serviceFee', String)
  foreign_exchange_fee = XmlUtilities.from_element(root,
                                                   'foreignExchangeFee',
                                                   String)
  surcharge = XmlUtilities.from_element(root, 'Surcharge2', Surcharge2)

  new(total_amount: total_amount,
      currency: currency,
      service_fee: service_fee,
      foreign_exchange_fee: foreign_exchange_fee,
      surcharge: surcharge,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/cyber_source_merged_spec/models/amount_details43.rb', line 87

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  total_amount = hash.key?('totalAmount') ? hash['totalAmount'] : nil
  currency = hash.key?('currency') ? hash['currency'] : nil
  service_fee = hash.key?('serviceFee') ? hash['serviceFee'] : SKIP
  foreign_exchange_fee =
    hash.key?('foreignExchangeFee') ? hash['foreignExchangeFee'] : SKIP
  surcharge = Surcharge2.from_hash(hash['surcharge']) if hash['surcharge']

  # 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.
  AmountDetails43.new(total_amount: total_amount,
                      currency: currency,
                      service_fee: service_fee,
                      foreign_exchange_fee: foreign_exchange_fee,
                      surcharge: surcharge,
                      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
# File 'lib/cyber_source_merged_spec/models/amount_details43.rb', line 48

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['total_amount'] = 'totalAmount'
  @_hash['currency'] = 'currency'
  @_hash['service_fee'] = 'serviceFee'
  @_hash['foreign_exchange_fee'] = 'foreignExchangeFee'
  @_hash['surcharge'] = 'surcharge'
  @_hash
end

.nullablesObject

An array for nullable fields



68
69
70
# File 'lib/cyber_source_merged_spec/models/amount_details43.rb', line 68

def self.nullables
  []
end

.optionalsObject

An array for optional fields



59
60
61
62
63
64
65
# File 'lib/cyber_source_merged_spec/models/amount_details43.rb', line 59

def self.optionals
  %w[
    service_fee
    foreign_exchange_fee
    surcharge
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



155
156
157
158
159
160
161
# File 'lib/cyber_source_merged_spec/models/amount_details43.rb', line 155

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} total_amount: #{@total_amount.inspect}, currency: #{@currency.inspect},"\
  " service_fee: #{@service_fee.inspect}, foreign_exchange_fee:"\
  " #{@foreign_exchange_fee.inspect}, surcharge: #{@surcharge.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



147
148
149
150
151
152
# File 'lib/cyber_source_merged_spec/models/amount_details43.rb', line 147

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} total_amount: #{@total_amount}, currency: #{@currency}, service_fee:"\
  " #{@service_fee}, foreign_exchange_fee: #{@foreign_exchange_fee}, surcharge: #{@surcharge},"\
  " additional_properties: #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/cyber_source_merged_spec/models/amount_details43.rb', line 131

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

  XmlUtilities.add_as_subelement(doc, root, 'totalAmount', total_amount)
  XmlUtilities.add_as_subelement(doc, root, 'currency', currency)
  XmlUtilities.add_as_subelement(doc, root, 'serviceFee', service_fee)
  XmlUtilities.add_as_subelement(doc, root, 'foreignExchangeFee',
                                 foreign_exchange_fee)
  XmlUtilities.add_as_subelement(doc, root, 'Surcharge2', surcharge)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end