Class: CyberSourceMergedSpec::LineItem16

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

Overview

LineItem16 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(product_code: SKIP, product_name: SKIP, product_sku: SKIP, tax_amount: SKIP, quantity: 1, unit_price: SKIP, fulfillment_type: SKIP, additional_properties: nil) ⇒ LineItem16

Returns a new instance of LineItem16.



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/cyber_source_merged_spec/models/line_item16.rb', line 97

def initialize(product_code: SKIP, product_name: SKIP, product_sku: SKIP,
               tax_amount: SKIP, quantity: 1, unit_price: SKIP,
               fulfillment_type: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @product_code = product_code unless product_code == SKIP
  @product_name = product_name unless product_name == SKIP
  @product_sku = product_sku unless product_sku == SKIP
  @tax_amount = tax_amount unless tax_amount == SKIP
  @quantity = quantity unless quantity == SKIP
  @unit_price = unit_price unless unit_price == SKIP
  @fulfillment_type = fulfillment_type unless fulfillment_type == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#fulfillment_typeString

The description for this field is not available.

Returns:

  • (String)


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

def fulfillment_type
  @fulfillment_type
end

#product_codeString

Type of product. This value is used to determine the category that the product is in: electronic, handling, physical, service, or shipping. The default value is default. For a payment, when you set this field to a value other than default or any of the values related to shipping and handling, below fields quantity, productName, and productSKU are required.

Returns:

  • (String)


20
21
22
# File 'lib/cyber_source_merged_spec/models/line_item16.rb', line 20

def product_code
  @product_code
end

#product_nameString

For PAYMENT and CAPTURE API, this field is required when above productCode is not default or one of the values related to shipping and handling.

Returns:

  • (String)


26
27
28
# File 'lib/cyber_source_merged_spec/models/line_item16.rb', line 26

def product_name
  @product_name
end

#product_skuString

Identification code for the product. For Payment and Capture APIs, this field is required when above productCode is not default or one of the values related to shipping and/or handling.

Returns:

  • (String)


33
34
35
# File 'lib/cyber_source_merged_spec/models/line_item16.rb', line 33

def product_sku
  @product_sku
end

#quantityInteger

For a payment or capture, this field is required when productCode is not default or one of the values related to shipping and handling.

Returns:

  • (Integer)


52
53
54
# File 'lib/cyber_source_merged_spec/models/line_item16.rb', line 52

def quantity
  @quantity
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. This field is frequently used for Level II and Level III transactions.

Returns:

  • (String)


46
47
48
# File 'lib/cyber_source_merged_spec/models/line_item16.rb', line 46

def tax_amount
  @tax_amount
end

#unit_priceString

Per-item price of the product. This value cannot be negative. You can include a decimal point (.), but you cannot include any other special characters. CyberSource truncates the amount to the correct number of decimal places.

Returns:

  • (String)


60
61
62
# File 'lib/cyber_source_merged_spec/models/line_item16.rb', line 60

def unit_price
  @unit_price
end

Class Method Details

.from_element(root) ⇒ Object



145
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/line_item16.rb', line 145

def self.from_element(root)
  product_code = XmlUtilities.from_element(root, 'productCode', String)
  product_name = XmlUtilities.from_element(root, 'productName', String)
  product_sku = XmlUtilities.from_element(root, 'productSku', String)
  tax_amount = XmlUtilities.from_element(root, 'taxAmount', String)
  quantity = XmlUtilities.from_element(root, 'quantity', Integer)
  unit_price = XmlUtilities.from_element(root, 'unitPrice', String)
  fulfillment_type = XmlUtilities.from_element(root, 'fulfillmentType',
                                               String)

  new(product_code: product_code,
      product_name: product_name,
      product_sku: product_sku,
      tax_amount: tax_amount,
      quantity: quantity,
      unit_price: unit_price,
      fulfillment_type: fulfillment_type,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/cyber_source_merged_spec/models/line_item16.rb', line 114

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  product_code = hash.key?('productCode') ? hash['productCode'] : SKIP
  product_name = hash.key?('productName') ? hash['productName'] : SKIP
  product_sku = hash.key?('productSku') ? hash['productSku'] : SKIP
  tax_amount = hash.key?('taxAmount') ? hash['taxAmount'] : SKIP
  quantity = hash['quantity'] ||= 1
  unit_price = hash.key?('unitPrice') ? hash['unitPrice'] : SKIP
  fulfillment_type =
    hash.key?('fulfillmentType') ? hash['fulfillmentType'] : 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.
  LineItem16.new(product_code: product_code,
                 product_name: product_name,
                 product_sku: product_sku,
                 tax_amount: tax_amount,
                 quantity: quantity,
                 unit_price: unit_price,
                 fulfillment_type: fulfillment_type,
                 additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/cyber_source_merged_spec/models/line_item16.rb', line 67

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['product_code'] = 'productCode'
  @_hash['product_name'] = 'productName'
  @_hash['product_sku'] = 'productSku'
  @_hash['tax_amount'] = 'taxAmount'
  @_hash['quantity'] = 'quantity'
  @_hash['unit_price'] = 'unitPrice'
  @_hash['fulfillment_type'] = 'fulfillmentType'
  @_hash
end

.nullablesObject

An array for nullable fields



93
94
95
# File 'lib/cyber_source_merged_spec/models/line_item16.rb', line 93

def self.nullables
  []
end

.optionalsObject

An array for optional fields



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/cyber_source_merged_spec/models/line_item16.rb', line 80

def self.optionals
  %w[
    product_code
    product_name
    product_sku
    tax_amount
    quantity
    unit_price
    fulfillment_type
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



192
193
194
195
196
197
198
199
# File 'lib/cyber_source_merged_spec/models/line_item16.rb', line 192

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} product_code: #{@product_code.inspect}, product_name:"\
  " #{@product_name.inspect}, product_sku: #{@product_sku.inspect}, tax_amount:"\
  " #{@tax_amount.inspect}, quantity: #{@quantity.inspect}, unit_price:"\
  " #{@unit_price.inspect}, fulfillment_type: #{@fulfillment_type.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



183
184
185
186
187
188
189
# File 'lib/cyber_source_merged_spec/models/line_item16.rb', line 183

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} product_code: #{@product_code}, product_name: #{@product_name},"\
  " product_sku: #{@product_sku}, tax_amount: #{@tax_amount}, quantity: #{@quantity},"\
  " unit_price: #{@unit_price}, fulfillment_type: #{@fulfillment_type}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/cyber_source_merged_spec/models/line_item16.rb', line 165

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

  XmlUtilities.add_as_subelement(doc, root, 'productCode', product_code)
  XmlUtilities.add_as_subelement(doc, root, 'productName', product_name)
  XmlUtilities.add_as_subelement(doc, root, 'productSku', product_sku)
  XmlUtilities.add_as_subelement(doc, root, 'taxAmount', tax_amount)
  XmlUtilities.add_as_subelement(doc, root, 'quantity', quantity)
  XmlUtilities.add_as_subelement(doc, root, 'unitPrice', unit_price)
  XmlUtilities.add_as_subelement(doc, root, 'fulfillmentType',
                                 fulfillment_type)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end