Class: CyberSource::Ucv1sessionsDataOrderInformationAmountDetails

Inherits:
Object
  • Object
show all
Defined in:
lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Ucv1sessionsDataOrderInformationAmountDetails

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
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
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 106

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  if attributes.has_key?(:'totalAmount')
    self.total_amount = attributes[:'totalAmount']
  end

  if attributes.has_key?(:'freightAmount')
    self.freight_amount = attributes[:'freightAmount']
  end

  if attributes.has_key?(:'dutyAmount')
    self.duty_amount = attributes[:'dutyAmount']
  end

  if attributes.has_key?(:'discountAmount')
    self.discount_amount = attributes[:'discountAmount']
  end

  if attributes.has_key?(:'taxAppliedAfterDiscount')
    self.tax_applied_after_discount = attributes[:'taxAppliedAfterDiscount']
  end

  if attributes.has_key?(:'taxAppliedLevel')
    self.tax_applied_level = attributes[:'taxAppliedLevel']
  end

  if attributes.has_key?(:'currency')
    self.currency = attributes[:'currency']
  end

  if attributes.has_key?(:'surcharge')
    self.surcharge = attributes[:'surcharge']
  end

  if attributes.has_key?(:'subTotalAmount')
    self.sub_total_amount = attributes[:'subTotalAmount']
  end

  if attributes.has_key?(:'serviceFeeAmount')
    self.service_fee_amount = attributes[:'serviceFeeAmount']
  end

  if attributes.has_key?(:'taxAmount')
    self.tax_amount = attributes[:'taxAmount']
  end

  if attributes.has_key?(:'taxDetails')
    if (value = attributes[:'taxDetails']).is_a?(Array)
      self.tax_details = value
    end
  end
end

Instance Attribute Details

#currencyObject

This field defines the currency applicable to the order.



35
36
37
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 35

def currency
  @currency
end

#discount_amountObject

Total discount amount applied to the order.



26
27
28
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 26

def discount_amount
  @discount_amount
end

#duty_amountObject

Total charges for any import or export duties included in the order.



23
24
25
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 23

def duty_amount
  @duty_amount
end

#freight_amountObject

Total freight or shipping and handling charges for the order. When you include this field in your request, you must also include the totalAmount field.



20
21
22
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 20

def freight_amount
  @freight_amount
end

#service_fee_amountObject

This field defines the service fee amount applicable to the order.



43
44
45
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 43

def service_fee_amount
  @service_fee_amount
end

#sub_total_amountObject

This field defines the sub total amount applicable to the order.



40
41
42
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 40

def sub_total_amount
  @sub_total_amount
end

#surchargeObject

Returns the value of attribute surcharge.



37
38
39
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 37

def surcharge
  @surcharge
end

#tax_amountObject

This field defines the tax amount applicable to the order.



46
47
48
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 46

def tax_amount
  @tax_amount
end

#tax_applied_after_discountObject

Flag that indicates how the merchant manages discounts. Possible values: - 0: no invoice level discount included - 1: tax calculated on the postdiscount invoice total - 2: tax calculated on the prediscount invoice total



29
30
31
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 29

def tax_applied_after_discount
  @tax_applied_after_discount
end

#tax_applied_levelObject

Flag that indicates how you calculate tax. Possible values: - 0: net prices with tax calculated at line item level - 1: net prices with tax calculated at invoice level - 2: gross prices with tax provided at line item level - 3: gross prices with tax provided at invoice level - 4: no tax applies on the invoice for the transaction



32
33
34
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 32

def tax_applied_level
  @tax_applied_level
end

#tax_detailsObject

Returns the value of attribute tax_details.



48
49
50
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 48

def tax_details
  @tax_details
end

#total_amountObject

This field defines the total order amount.



17
18
19
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 17

def total_amount
  @total_amount
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 51

def self.attribute_map
  {
    :'total_amount' => :'totalAmount',
    :'freight_amount' => :'freightAmount',
    :'duty_amount' => :'dutyAmount',
    :'discount_amount' => :'discountAmount',
    :'tax_applied_after_discount' => :'taxAppliedAfterDiscount',
    :'tax_applied_level' => :'taxAppliedLevel',
    :'currency' => :'currency',
    :'surcharge' => :'surcharge',
    :'sub_total_amount' => :'subTotalAmount',
    :'service_fee_amount' => :'serviceFeeAmount',
    :'tax_amount' => :'taxAmount',
    :'tax_details' => :'taxDetails'
  }
end

.json_mapObject

Attribute mapping from JSON key to ruby-style variable name.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 69

def self.json_map
  {
    :'total_amount' => :'total_amount',
    :'freight_amount' => :'freight_amount',
    :'duty_amount' => :'duty_amount',
    :'discount_amount' => :'discount_amount',
    :'tax_applied_after_discount' => :'tax_applied_after_discount',
    :'tax_applied_level' => :'tax_applied_level',
    :'currency' => :'currency',
    :'surcharge' => :'surcharge',
    :'sub_total_amount' => :'sub_total_amount',
    :'service_fee_amount' => :'service_fee_amount',
    :'tax_amount' => :'tax_amount',
    :'tax_details' => :'tax_details'
  }
end

.swagger_typesObject

Attribute type mapping.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 87

def self.swagger_types
  {
    :'total_amount' => :'String',
    :'freight_amount' => :'String',
    :'duty_amount' => :'String',
    :'discount_amount' => :'String',
    :'tax_applied_after_discount' => :'String',
    :'tax_applied_level' => :'String',
    :'currency' => :'String',
    :'surcharge' => :'Upv1capturecontextsDataOrderInformationAmountDetailsSurcharge',
    :'sub_total_amount' => :'String',
    :'service_fee_amount' => :'String',
    :'tax_amount' => :'String',
    :'tax_details' => :'Array<Ucv1sessionsDataOrderInformationAmountDetailsTaxDetails>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 220

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      total_amount == o.total_amount &&
      freight_amount == o.freight_amount &&
      duty_amount == o.duty_amount &&
      discount_amount == o.discount_amount &&
      tax_applied_after_discount == o.tax_applied_after_discount &&
      tax_applied_level == o.tax_applied_level &&
      currency == o.currency &&
      surcharge == o.surcharge &&
      sub_total_amount == o.sub_total_amount &&
      service_fee_amount == o.service_fee_amount &&
      tax_amount == o.tax_amount &&
      tax_details == o.tax_details
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 273

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :BOOLEAN
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    temp_model = CyberSource.const_get(type).new
    temp_model.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



339
340
341
342
343
344
345
346
347
348
349
350
351
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 339

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 252

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{self.class.json_map[key]}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{self.class.json_map[key]}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


239
240
241
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 239

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



245
246
247
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 245

def hash
  [total_amount, freight_amount, duty_amount, discount_amount, tax_applied_after_discount, tax_applied_level, currency, surcharge, sub_total_amount, service_fee_amount, tax_amount, tax_details].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



165
166
167
168
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 165

def list_invalid_properties
  invalid_properties = Array.new
  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



319
320
321
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 319

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



325
326
327
328
329
330
331
332
333
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 325

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



313
314
315
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 313

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



172
173
174
# File 'lib/cybersource_rest_client/models/ucv1sessions_data_order_information_amount_details.rb', line 172

def valid?
  true
end