Class: CyberSourceMergedSpec::LineItem12

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

Overview

LineItem12 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(unit_price:, total_amount: SKIP, quantity: 1, gift_card_currency: SKIP, product_sku: SKIP, product_description: SKIP, product_name: SKIP, passenger: SKIP, shipping_destination_types: SKIP, tax_amount: SKIP, shipping_address1: SKIP, shipping_address2: SKIP, shipping_city: SKIP, shipping_country_code: SKIP, shipping_first_name: SKIP, shipping_last_name: SKIP, shipping_middle_name: SKIP, shipping_phone: SKIP, shipping_postal_code: SKIP, shipping_state: SKIP, additional_properties: nil) ⇒ LineItem12

Returns a new instance of LineItem12.



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 225

def initialize(unit_price:, total_amount: SKIP, quantity: 1,
               gift_card_currency: SKIP, product_sku: SKIP,
               product_description: SKIP, product_name: SKIP,
               passenger: SKIP, shipping_destination_types: SKIP,
               tax_amount: SKIP, shipping_address1: SKIP,
               shipping_address2: SKIP, shipping_city: SKIP,
               shipping_country_code: SKIP, shipping_first_name: SKIP,
               shipping_last_name: SKIP, shipping_middle_name: SKIP,
               shipping_phone: SKIP, shipping_postal_code: SKIP,
               shipping_state: 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
  @unit_price = unit_price
  @quantity = quantity unless quantity == SKIP
  @gift_card_currency = gift_card_currency unless gift_card_currency == SKIP
  @product_sku = product_sku unless product_sku == SKIP
  @product_description = product_description unless product_description == SKIP
  @product_name = product_name unless product_name == SKIP
  @passenger = passenger unless passenger == SKIP
  unless shipping_destination_types == SKIP
    @shipping_destination_types =
      shipping_destination_types
  end
  @tax_amount = tax_amount unless tax_amount == SKIP
  @shipping_address1 = shipping_address1 unless shipping_address1 == SKIP
  @shipping_address2 = shipping_address2 unless shipping_address2 == SKIP
  @shipping_city = shipping_city unless shipping_city == SKIP
  @shipping_country_code = shipping_country_code unless shipping_country_code == SKIP
  @shipping_first_name = shipping_first_name unless shipping_first_name == SKIP
  @shipping_last_name = shipping_last_name unless shipping_last_name == SKIP
  @shipping_middle_name = shipping_middle_name unless shipping_middle_name == SKIP
  @shipping_phone = shipping_phone unless shipping_phone == SKIP
  @shipping_postal_code = shipping_postal_code unless shipping_postal_code == SKIP
  @shipping_state = shipping_state unless shipping_state == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#gift_card_currencyInteger

When orderInformation.lineItems[].productCode is "gift_card", this is the currency used for the gift card purchase. For the possible values, see the [ISO Standard Currency Codes.](http://apps.cybersource.com/library/documentation/sbc/quickref/cur rencies.pdf)

Returns:

  • (Integer)


64
65
66
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 64

def gift_card_currency
  @gift_card_currency
end

#passengerPassenger

Contains travel-related passenger details used by DM service only.

Returns:



99
100
101
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 99

def passenger
  @passenger
end

#product_descriptionString

Brief description of item.

Returns:

  • (String)


84
85
86
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 84

def product_description
  @product_description
end

#product_nameString

For an authorization or capture transaction (processingOptions.capture is true or false), this field is required when orderInformation.lineItems[].productCode is not default or one of the other values that are related to shipping and/or handling.

Tax Calculation

Optional field for U.S., Canadian, international tax, and value added taxes.

Returns:

  • (String)


95
96
97
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 95

def product_name
  @product_name
end

#product_skuString

Product identifier code. Also known as the Stock Keeping Unit (SKU) code for the product. For an authorization or capture transaction (processingOptions.capture is set to true or false), this field is required when orderInformation.lineItems[].productCode is not set to default or one of the other values that are related to shipping and/or handling.

Tax Calculation

Optional field for U.S. and Canadian taxes. Not applicable to international and value added taxes. For an authorization or capture transaction (processingOptions.capture is set to true or false), this field is required when orderInformation.lineItems[].productCode is not default or one of the values related to shipping and/or handling.

Returns:

  • (String)


80
81
82
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 80

def product_sku
  @product_sku
end

#quantityInteger

Number of units for this order. Must be a non-negative integer. The default is 1. For an authorization or capture transaction (processingOptions.capture is set to true or false), this field is required when orderInformation.lineItems[].productCode is not default or one of the other values related to shipping and/or handling.

Tax Calculation

Optional field for U.S., Canadian, international tax, and value added taxes.

Returns:

  • (Integer)


55
56
57
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 55

def quantity
  @quantity
end

#shipping_address1String

Address where item will be shipped

Returns:

  • (String)


131
132
133
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 131

def shipping_address1
  @shipping_address1
end

#shipping_address2String

Address where item will be shipped

Returns:

  • (String)


135
136
137
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 135

def shipping_address2
  @shipping_address2
end

#shipping_cityString

City where item will be shipped

Returns:

  • (String)


139
140
141
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 139

def shipping_city
  @shipping_city
end

#shipping_country_codeString

Country where item will be shipped

Returns:

  • (String)


143
144
145
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 143

def shipping_country_code
  @shipping_country_code
end

#shipping_destination_typesString

Destination to where the item will be shipped. Example: Commercial, Residential, Store

Returns:

  • (String)


104
105
106
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 104

def shipping_destination_types
  @shipping_destination_types
end

#shipping_first_nameString

Customer's first name

Returns:

  • (String)


147
148
149
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 147

def shipping_first_name
  @shipping_first_name
end

#shipping_last_nameString

Customer's last name

Returns:

  • (String)


151
152
153
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 151

def shipping_last_name
  @shipping_last_name
end

#shipping_middle_nameString

Customer's middle name

Returns:

  • (String)


155
156
157
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 155

def shipping_middle_name
  @shipping_middle_name
end

#shipping_phoneInteger

Phone number where item will be shipped

Returns:

  • (Integer)


159
160
161
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 159

def shipping_phone
  @shipping_phone
end

#shipping_postal_codeInteger

Postal code where item will be shipped

Returns:

  • (Integer)


163
164
165
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 163

def shipping_postal_code
  @shipping_postal_code
end

#shipping_stateString

State where item will be shipped

Returns:

  • (String)


167
168
169
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 167

def shipping_state
  @shipping_state
end

#tax_amountString

Total tax to apply to the product. This value cannot be negative. The tax amount and the offer amount must be in the same currency. The tax amount field is additive. The following example uses a two-exponent currency such as USD:

  1. You include each line item in your request. ..- 1st line item has amount=10.00, quantity=1, and taxAmount=0.80 ..- 2nd line item has amount=20.00, quantity=1, and taxAmount=1.60
  2. The total amount authorized will be 32.40, not 30.00 with 2.40 of tax included. Optional field.

Airlines processing

Tax portion of the order amount. This value cannot exceed 99999999999999 (fourteen 9s). Format: English characters only. Optional request field for a line item.

Tax Calculation

Optional field for U.S., Canadian, international tax, and value added taxes. Note if you send this field in your tax request, the value in the field will override the tax engine

Returns:

  • (String)


127
128
129
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 127

def tax_amount
  @tax_amount
end

#total_amountString

Total amount for the item. Normally calculated as the unit price times quantity. When orderInformation.lineItems[].productCode is "gift_card", this is the purchase amount total for prepaid gift cards in major units. Example: 123.45 USD = 123

Returns:

  • (String)


19
20
21
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 19

def total_amount
  @total_amount
end

#unit_priceString

Per-item price of the product. This value for this field cannot be negative. You must include either this field or the request-level field orderInformation.amountDetails.totalAmount in your request. You can include a decimal point (.), but you cannot include any other special characters. The value is truncated to the correct number of decimal places.

DCC with a Third-Party Provider

Set this field to the converted amount that was returned by the DCC provider. You must include either the 1st line item in the order and this field, or the request-level field orderInformation.amountDetails.totalAmount in your request.

Tax Calculation

Required field for U.S., Canadian, international and value added taxes.

Zero Amount Authorizations

If your processor supports zero amount authorizations, you can set this field to 0 for the authorization to check if the card is lost or stolen.

Maximum Field Lengths

For GPN and JCN Gateway: Decimal (10) All other processors: Decimal (15)

Returns:

  • (String)


43
44
45
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 43

def unit_price
  @unit_price
end

Class Method Details

.from_element(root) ⇒ Object



331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 331

def self.from_element(root)
  unit_price = XmlUtilities.from_element(root, 'unitPrice', String)
  total_amount = XmlUtilities.from_element(root, 'totalAmount', String)
  quantity = XmlUtilities.from_element(root, 'quantity', Integer)
  gift_card_currency = XmlUtilities.from_element(root, 'giftCardCurrency',
                                                 Integer)
  product_sku = XmlUtilities.from_element(root, 'productSKU', String)
  product_description = XmlUtilities.from_element(root,
                                                  'productDescription',
                                                  String)
  product_name = XmlUtilities.from_element(root, 'productName', String)
  passenger = XmlUtilities.from_element(root, 'Passenger', Passenger)
  shipping_destination_types = XmlUtilities.from_element(
    root, 'shippingDestinationTypes', String
  )
  tax_amount = XmlUtilities.from_element(root, 'taxAmount', String)
  shipping_address1 = XmlUtilities.from_element(root, 'shippingAddress1',
                                                String)
  shipping_address2 = XmlUtilities.from_element(root, 'shippingAddress2',
                                                String)
  shipping_city = XmlUtilities.from_element(root, 'shippingCity', String)
  shipping_country_code = XmlUtilities.from_element(root,
                                                    'shippingCountryCode',
                                                    String)
  shipping_first_name = XmlUtilities.from_element(root, 'shippingFirstName',
                                                  String)
  shipping_last_name = XmlUtilities.from_element(root, 'shippingLastName',
                                                 String)
  shipping_middle_name = XmlUtilities.from_element(root,
                                                   'shippingMiddleName',
                                                   String)
  shipping_phone = XmlUtilities.from_element(root, 'shippingPhone', Integer)
  shipping_postal_code = XmlUtilities.from_element(root,
                                                   'shippingPostalCode',
                                                   Integer)
  shipping_state = XmlUtilities.from_element(root, 'shippingState', String)

  new(unit_price: unit_price,
      total_amount: total_amount,
      quantity: quantity,
      gift_card_currency: gift_card_currency,
      product_sku: product_sku,
      product_description: product_description,
      product_name: product_name,
      passenger: passenger,
      shipping_destination_types: shipping_destination_types,
      tax_amount: tax_amount,
      shipping_address1: shipping_address1,
      shipping_address2: shipping_address2,
      shipping_city: shipping_city,
      shipping_country_code: shipping_country_code,
      shipping_first_name: shipping_first_name,
      shipping_last_name: shipping_last_name,
      shipping_middle_name: shipping_middle_name,
      shipping_phone: shipping_phone,
      shipping_postal_code: shipping_postal_code,
      shipping_state: shipping_state,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



265
266
267
268
269
270
271
272
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 265

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  unit_price = hash.key?('unitPrice') ? hash['unitPrice'] : nil
  total_amount = hash.key?('totalAmount') ? hash['totalAmount'] : SKIP
  quantity = hash['quantity'] ||= 1
  gift_card_currency =
    hash.key?('giftCardCurrency') ? hash['giftCardCurrency'] : SKIP
  product_sku = hash.key?('productSKU') ? hash['productSKU'] : SKIP
  product_description =
    hash.key?('productDescription') ? hash['productDescription'] : SKIP
  product_name = hash.key?('productName') ? hash['productName'] : SKIP
  passenger = Passenger.from_hash(hash['passenger']) if hash['passenger']
  shipping_destination_types =
    hash.key?('shippingDestinationTypes') ? hash['shippingDestinationTypes'] : SKIP
  tax_amount = hash.key?('taxAmount') ? hash['taxAmount'] : SKIP
  shipping_address1 =
    hash.key?('shippingAddress1') ? hash['shippingAddress1'] : SKIP
  shipping_address2 =
    hash.key?('shippingAddress2') ? hash['shippingAddress2'] : SKIP
  shipping_city = hash.key?('shippingCity') ? hash['shippingCity'] : SKIP
  shipping_country_code =
    hash.key?('shippingCountryCode') ? hash['shippingCountryCode'] : SKIP
  shipping_first_name =
    hash.key?('shippingFirstName') ? hash['shippingFirstName'] : SKIP
  shipping_last_name =
    hash.key?('shippingLastName') ? hash['shippingLastName'] : SKIP
  shipping_middle_name =
    hash.key?('shippingMiddleName') ? hash['shippingMiddleName'] : SKIP
  shipping_phone = hash.key?('shippingPhone') ? hash['shippingPhone'] : SKIP
  shipping_postal_code =
    hash.key?('shippingPostalCode') ? hash['shippingPostalCode'] : SKIP
  shipping_state = hash.key?('shippingState') ? hash['shippingState'] : 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.
  LineItem12.new(unit_price: unit_price,
                 total_amount: total_amount,
                 quantity: quantity,
                 gift_card_currency: gift_card_currency,
                 product_sku: product_sku,
                 product_description: product_description,
                 product_name: product_name,
                 passenger: passenger,
                 shipping_destination_types: shipping_destination_types,
                 tax_amount: tax_amount,
                 shipping_address1: shipping_address1,
                 shipping_address2: shipping_address2,
                 shipping_city: shipping_city,
                 shipping_country_code: shipping_country_code,
                 shipping_first_name: shipping_first_name,
                 shipping_last_name: shipping_last_name,
                 shipping_middle_name: shipping_middle_name,
                 shipping_phone: shipping_phone,
                 shipping_postal_code: shipping_postal_code,
                 shipping_state: shipping_state,
                 additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 170

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['total_amount'] = 'totalAmount'
  @_hash['unit_price'] = 'unitPrice'
  @_hash['quantity'] = 'quantity'
  @_hash['gift_card_currency'] = 'giftCardCurrency'
  @_hash['product_sku'] = 'productSKU'
  @_hash['product_description'] = 'productDescription'
  @_hash['product_name'] = 'productName'
  @_hash['passenger'] = 'passenger'
  @_hash['shipping_destination_types'] = 'shippingDestinationTypes'
  @_hash['tax_amount'] = 'taxAmount'
  @_hash['shipping_address1'] = 'shippingAddress1'
  @_hash['shipping_address2'] = 'shippingAddress2'
  @_hash['shipping_city'] = 'shippingCity'
  @_hash['shipping_country_code'] = 'shippingCountryCode'
  @_hash['shipping_first_name'] = 'shippingFirstName'
  @_hash['shipping_last_name'] = 'shippingLastName'
  @_hash['shipping_middle_name'] = 'shippingMiddleName'
  @_hash['shipping_phone'] = 'shippingPhone'
  @_hash['shipping_postal_code'] = 'shippingPostalCode'
  @_hash['shipping_state'] = 'shippingState'
  @_hash
end

.nullablesObject

An array for nullable fields



221
222
223
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 221

def self.nullables
  []
end

.optionalsObject

An array for optional fields



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 196

def self.optionals
  %w[
    total_amount
    quantity
    gift_card_currency
    product_sku
    product_description
    product_name
    passenger
    shipping_destination_types
    tax_amount
    shipping_address1
    shipping_address2
    shipping_city
    shipping_country_code
    shipping_first_name
    shipping_last_name
    shipping_middle_name
    shipping_phone
    shipping_postal_code
    shipping_state
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 447

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} total_amount: #{@total_amount.inspect}, unit_price: #{@unit_price.inspect},"\
  " quantity: #{@quantity.inspect}, gift_card_currency: #{@gift_card_currency.inspect},"\
  " product_sku: #{@product_sku.inspect}, product_description:"\
  " #{@product_description.inspect}, product_name: #{@product_name.inspect}, passenger:"\
  " #{@passenger.inspect}, shipping_destination_types: #{@shipping_destination_types.inspect},"\
  " tax_amount: #{@tax_amount.inspect}, shipping_address1: #{@shipping_address1.inspect},"\
  " shipping_address2: #{@shipping_address2.inspect}, shipping_city:"\
  " #{@shipping_city.inspect}, shipping_country_code: #{@shipping_country_code.inspect},"\
  " shipping_first_name: #{@shipping_first_name.inspect}, shipping_last_name:"\
  " #{@shipping_last_name.inspect}, shipping_middle_name: #{@shipping_middle_name.inspect},"\
  " shipping_phone: #{@shipping_phone.inspect}, shipping_postal_code:"\
  " #{@shipping_postal_code.inspect}, shipping_state: #{@shipping_state.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



431
432
433
434
435
436
437
438
439
440
441
442
443
444
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 431

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} total_amount: #{@total_amount}, unit_price: #{@unit_price}, quantity:"\
  " #{@quantity}, gift_card_currency: #{@gift_card_currency}, product_sku: #{@product_sku},"\
  " product_description: #{@product_description}, product_name: #{@product_name}, passenger:"\
  " #{@passenger}, shipping_destination_types: #{@shipping_destination_types}, tax_amount:"\
  " #{@tax_amount}, shipping_address1: #{@shipping_address1}, shipping_address2:"\
  " #{@shipping_address2}, shipping_city: #{@shipping_city}, shipping_country_code:"\
  " #{@shipping_country_code}, shipping_first_name: #{@shipping_first_name},"\
  " shipping_last_name: #{@shipping_last_name}, shipping_middle_name:"\
  " #{@shipping_middle_name}, shipping_phone: #{@shipping_phone}, shipping_postal_code:"\
  " #{@shipping_postal_code}, shipping_state: #{@shipping_state}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
# File 'lib/cyber_source_merged_spec/models/line_item12.rb', line 391

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

  XmlUtilities.add_as_subelement(doc, root, 'unitPrice', unit_price)
  XmlUtilities.add_as_subelement(doc, root, 'totalAmount', total_amount)
  XmlUtilities.add_as_subelement(doc, root, 'quantity', quantity)
  XmlUtilities.add_as_subelement(doc, root, 'giftCardCurrency',
                                 gift_card_currency)
  XmlUtilities.add_as_subelement(doc, root, 'productSKU', product_sku)
  XmlUtilities.add_as_subelement(doc, root, 'productDescription',
                                 product_description)
  XmlUtilities.add_as_subelement(doc, root, 'productName', product_name)
  XmlUtilities.add_as_subelement(doc, root, 'Passenger', passenger)
  XmlUtilities.add_as_subelement(doc, root, 'shippingDestinationTypes',
                                 shipping_destination_types)
  XmlUtilities.add_as_subelement(doc, root, 'taxAmount', tax_amount)
  XmlUtilities.add_as_subelement(doc, root, 'shippingAddress1',
                                 shipping_address1)
  XmlUtilities.add_as_subelement(doc, root, 'shippingAddress2',
                                 shipping_address2)
  XmlUtilities.add_as_subelement(doc, root, 'shippingCity', shipping_city)
  XmlUtilities.add_as_subelement(doc, root, 'shippingCountryCode',
                                 shipping_country_code)
  XmlUtilities.add_as_subelement(doc, root, 'shippingFirstName',
                                 shipping_first_name)
  XmlUtilities.add_as_subelement(doc, root, 'shippingLastName',
                                 shipping_last_name)
  XmlUtilities.add_as_subelement(doc, root, 'shippingMiddleName',
                                 shipping_middle_name)
  XmlUtilities.add_as_subelement(doc, root, 'shippingPhone', shipping_phone)
  XmlUtilities.add_as_subelement(doc, root, 'shippingPostalCode',
                                 shipping_postal_code)
  XmlUtilities.add_as_subelement(doc, root, 'shippingState', shipping_state)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end