Class: CyberSourceMergedSpec::LineItem15

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

Overview

LineItem15 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: SKIP, allowed_export_countries: SKIP, restricted_export_countries: SKIP, quantity: 1, product_sku: SKIP, product_risk: SKIP, product_name: SKIP, product_code: SKIP, additional_properties: nil) ⇒ LineItem15

Returns a new instance of LineItem15.



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/cyber_source_merged_spec/models/line_item15.rb', line 130

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

  @unit_price = unit_price unless unit_price == SKIP
  @allowed_export_countries = allowed_export_countries unless allowed_export_countries == SKIP
  unless restricted_export_countries == SKIP
    @restricted_export_countries =
      restricted_export_countries
  end
  @quantity = quantity unless quantity == SKIP
  @product_sku = product_sku unless product_sku == SKIP
  @product_risk = product_risk unless product_risk == SKIP
  @product_name = product_name unless product_name == SKIP
  @product_code = product_code unless product_code == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#allowed_export_countriesArray[String]

Per-item price of the product. If line items are present in the request, the unit price is a mandatory field.

Returns:

  • (Array[String])


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

def allowed_export_countries
  @allowed_export_countries
end

#product_codeString

Type of product. The value for this field is used to identify the product category (electronic, handling, physical, service, or shipping). The default value is default. If you are performing an authorization transaction (processingOptions.capture is set to false), and you set this field to a value other than default or one of the values related to shipping and/or handling, then orderInformation.lineItems[].quantity, orderInformation.lineItems[].productName, and orderInformation.lineItems[].productSku fields are required. Optional field.

Tax Calculation

Optional field for U.S., Canadian, international tax, and value added taxes. The Product Codes for the tax service are located in the Cybersource Tax Codes guide. Contact Customer Support to request the guide. If you don’t send a tax service Product Code in your tax request, product-based rules or exemptions will not be applied and the transaction will default to fully taxable in the locations where you’ve indicated you need to collect tax [by way of nexus, no nexus, or seller registration number fields].

Returns:

  • (String)


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

def product_code
  @product_code
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)


72
73
74
# File 'lib/cyber_source_merged_spec/models/line_item15.rb', line 72

def product_name
  @product_name
end

#product_riskString

Indicates the level of risk for the product. This field can contain one of the following values:

  • low: The product is associated with few chargebacks.
  • normal: The product is associated with a normal number of chargebacks.
  • high: The product is associated with many chargebacks.

Returns:

  • (String)


61
62
63
# File 'lib/cyber_source_merged_spec/models/line_item15.rb', line 61

def product_risk
  @product_risk
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)


53
54
55
# File 'lib/cyber_source_merged_spec/models/line_item15.rb', line 53

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)


37
38
39
# File 'lib/cyber_source_merged_spec/models/line_item15.rb', line 37

def quantity
  @quantity
end

#restricted_export_countriesArray[String]

Per-item price of the product. If line items are present in the request, the unit price is a mandatory field.

Returns:

  • (Array[String])


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

def restricted_export_countries
  @restricted_export_countries
end

#unit_priceString

Per-item price of the product. If line items are present in the request, the unit price is a mandatory field.

Returns:

  • (String)


15
16
17
# File 'lib/cyber_source_merged_spec/models/line_item15.rb', line 15

def unit_price
  @unit_price
end

Class Method Details

.from_element(root) ⇒ Object



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/cyber_source_merged_spec/models/line_item15.rb', line 186

def self.from_element(root)
  unit_price = XmlUtilities.from_element(root, 'unitPrice', String)
  allowed_export_countries = XmlUtilities.from_element_to_array(
    root, 'allowedExportCountries', String
  )
  restricted_export_countries = XmlUtilities.from_element_to_array(
    root, 'restrictedExportCountries', String
  )
  quantity = XmlUtilities.from_element(root, 'quantity', Integer)
  product_sku = XmlUtilities.from_element(root, 'productSKU', String)
  product_risk = XmlUtilities.from_element(root, 'productRisk', String)
  product_name = XmlUtilities.from_element(root, 'productName', String)
  product_code = XmlUtilities.from_element(root, 'productCode', String)

  new(unit_price: unit_price,
      allowed_export_countries: allowed_export_countries,
      restricted_export_countries: restricted_export_countries,
      quantity: quantity,
      product_sku: product_sku,
      product_risk: product_risk,
      product_name: product_name,
      product_code: product_code,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/cyber_source_merged_spec/models/line_item15.rb', line 152

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  unit_price = hash.key?('unitPrice') ? hash['unitPrice'] : SKIP
  allowed_export_countries =
    hash.key?('allowedExportCountries') ? hash['allowedExportCountries'] : SKIP
  restricted_export_countries =
    hash.key?('restrictedExportCountries') ? hash['restrictedExportCountries'] : SKIP
  quantity = hash['quantity'] ||= 1
  product_sku = hash.key?('productSKU') ? hash['productSKU'] : SKIP
  product_risk = hash.key?('productRisk') ? hash['productRisk'] : SKIP
  product_name = hash.key?('productName') ? hash['productName'] : SKIP
  product_code = hash.key?('productCode') ? hash['productCode'] : 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.
  LineItem15.new(unit_price: unit_price,
                 allowed_export_countries: allowed_export_countries,
                 restricted_export_countries: restricted_export_countries,
                 quantity: quantity,
                 product_sku: product_sku,
                 product_risk: product_risk,
                 product_name: product_name,
                 product_code: product_code,
                 additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['unit_price'] = 'unitPrice'
  @_hash['allowed_export_countries'] = 'allowedExportCountries'
  @_hash['restricted_export_countries'] = 'restrictedExportCountries'
  @_hash['quantity'] = 'quantity'
  @_hash['product_sku'] = 'productSKU'
  @_hash['product_risk'] = 'productRisk'
  @_hash['product_name'] = 'productName'
  @_hash['product_code'] = 'productCode'
  @_hash
end

.nullablesObject

An array for nullable fields



126
127
128
# File 'lib/cyber_source_merged_spec/models/line_item15.rb', line 126

def self.nullables
  []
end

.optionalsObject

An array for optional fields



112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/cyber_source_merged_spec/models/line_item15.rb', line 112

def self.optionals
  %w[
    unit_price
    allowed_export_countries
    restricted_export_countries
    quantity
    product_sku
    product_risk
    product_name
    product_code
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



242
243
244
245
246
247
248
249
250
# File 'lib/cyber_source_merged_spec/models/line_item15.rb', line 242

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

#to_sObject

Provides a human-readable string representation of the object.



232
233
234
235
236
237
238
239
# File 'lib/cyber_source_merged_spec/models/line_item15.rb', line 232

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

#to_xml_element(doc, root_name) ⇒ Object



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/cyber_source_merged_spec/models/line_item15.rb', line 211

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

  XmlUtilities.add_as_subelement(doc, root, 'unitPrice', unit_price)
  XmlUtilities.add_array_as_subelement(doc, root, 'allowedExportCountries',
                                       allowed_export_countries)
  XmlUtilities.add_array_as_subelement(doc, root,
                                       'restrictedExportCountries',
                                       restricted_export_countries)
  XmlUtilities.add_as_subelement(doc, root, 'quantity', quantity)
  XmlUtilities.add_as_subelement(doc, root, 'productSKU', product_sku)
  XmlUtilities.add_as_subelement(doc, root, 'productRisk', product_risk)
  XmlUtilities.add_as_subelement(doc, root, 'productName', product_name)
  XmlUtilities.add_as_subelement(doc, root, 'productCode', product_code)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end