Class: CyberSourceMergedSpec::LineItem14
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- CyberSourceMergedSpec::LineItem14
- Defined in:
- lib/cyber_source_merged_spec/models/line_item14.rb
Overview
LineItem14 Model.
Instance Attribute Summary collapse
-
#product_code ⇒ String
Type of product.
-
#product_name ⇒ String
For an authorization or capture transaction (
processingOptions.captureistrueorfalse), this field is required whenorderInformation.lineItems[].productCodeis notdefaultor one of the other values that are related to shipping and/or handling. -
#product_risk ⇒ String
Indicates the level of risk for the product.
-
#product_sku ⇒ String
Product identifier code.
-
#quantity ⇒ Integer
Number of units for this order.
-
#unit_price ⇒ String
Per-item price of the product.
Class Method Summary collapse
- .from_element(root) ⇒ Object
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(unit_price: SKIP, quantity: 1, product_sku: SKIP, product_risk: SKIP, product_name: SKIP, product_code: SKIP, additional_properties: nil) ⇒ LineItem14
constructor
A new instance of LineItem14.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
- #to_xml_element(doc, root_name) ⇒ Object
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, quantity: 1, product_sku: SKIP, product_risk: SKIP, product_name: SKIP, product_code: SKIP, additional_properties: nil) ⇒ LineItem14
Returns a new instance of LineItem14.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/cyber_source_merged_spec/models/line_item14.rb', line 116 def initialize(unit_price: 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 @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
#product_code ⇒ String
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].
85 86 87 |
# File 'lib/cyber_source_merged_spec/models/line_item14.rb', line 85 def product_code @product_code end |
#product_name ⇒ String
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.
62 63 64 |
# File 'lib/cyber_source_merged_spec/models/line_item14.rb', line 62 def product_name @product_name end |
#product_risk ⇒ String
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.
51 52 53 |
# File 'lib/cyber_source_merged_spec/models/line_item14.rb', line 51 def product_risk @product_risk end |
#product_sku ⇒ String
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.
43 44 45 |
# File 'lib/cyber_source_merged_spec/models/line_item14.rb', line 43 def product_sku @product_sku end |
#quantity ⇒ Integer
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.
27 28 29 |
# File 'lib/cyber_source_merged_spec/models/line_item14.rb', line 27 def quantity @quantity end |
#unit_price ⇒ String
Per-item price of the product. If line items are present in the request, the unit price is a mandatory field.
15 16 17 |
# File 'lib/cyber_source_merged_spec/models/line_item14.rb', line 15 def unit_price @unit_price end |
Class Method Details
.from_element(root) ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/cyber_source_merged_spec/models/line_item14.rb', line 160 def self.from_element(root) unit_price = XmlUtilities.from_element(root, 'unitPrice', 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, 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.
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 |
# File 'lib/cyber_source_merged_spec/models/line_item14.rb', line 132 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. unit_price = hash.key?('unitPrice') ? hash['unitPrice'] : 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. LineItem14.new(unit_price: unit_price, quantity: quantity, product_sku: product_sku, product_risk: product_risk, product_name: product_name, product_code: product_code, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/cyber_source_merged_spec/models/line_item14.rb', line 88 def self.names @_hash = {} if @_hash.nil? @_hash['unit_price'] = 'unitPrice' @_hash['quantity'] = 'quantity' @_hash['product_sku'] = 'productSKU' @_hash['product_risk'] = 'productRisk' @_hash['product_name'] = 'productName' @_hash['product_code'] = 'productCode' @_hash end |
.nullables ⇒ Object
An array for nullable fields
112 113 114 |
# File 'lib/cyber_source_merged_spec/models/line_item14.rb', line 112 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
100 101 102 103 104 105 106 107 108 109 |
# File 'lib/cyber_source_merged_spec/models/line_item14.rb', line 100 def self.optionals %w[ unit_price quantity product_sku product_risk product_name product_code ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
201 202 203 204 205 206 207 |
# File 'lib/cyber_source_merged_spec/models/line_item14.rb', line 201 def inspect class_name = self.class.name.split('::').last "<#{class_name} unit_price: #{@unit_price.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_s ⇒ Object
Provides a human-readable string representation of the object.
193 194 195 196 197 198 |
# File 'lib/cyber_source_merged_spec/models/line_item14.rb', line 193 def to_s class_name = self.class.name.split('::').last "<#{class_name} unit_price: #{@unit_price}, 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
177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/cyber_source_merged_spec/models/line_item14.rb', line 177 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, '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 |