Class: VisaAcceptanceMergedSpec::LineItem1

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/visa_acceptance_merged_spec/models/line_item1.rb

Overview

LineItem1 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(quantity: 1, unit_price: SKIP, additional_properties: nil) ⇒ LineItem1

Returns a new instance of LineItem1.



69
70
71
72
73
74
75
76
# File 'lib/visa_acceptance_merged_spec/models/line_item1.rb', line 69

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

  @quantity = quantity unless quantity == SKIP
  @unit_price = unit_price unless unit_price == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#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)


22
23
24
# File 'lib/visa_acceptance_merged_spec/models/line_item1.rb', line 22

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


46
47
48
# File 'lib/visa_acceptance_merged_spec/models/line_item1.rb', line 46

def unit_price
  @unit_price
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/visa_acceptance_merged_spec/models/line_item1.rb', line 79

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  quantity = hash['quantity'] ||= 1
  unit_price = hash.key?('unitPrice') ? hash['unitPrice'] : 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.
  LineItem1.new(quantity: quantity,
                unit_price: unit_price,
                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



49
50
51
52
53
54
# File 'lib/visa_acceptance_merged_spec/models/line_item1.rb', line 49

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['quantity'] = 'quantity'
  @_hash['unit_price'] = 'unitPrice'
  @_hash
end

.nullablesObject

An array for nullable fields



65
66
67
# File 'lib/visa_acceptance_merged_spec/models/line_item1.rb', line 65

def self.nullables
  []
end

.optionalsObject

An array for optional fields



57
58
59
60
61
62
# File 'lib/visa_acceptance_merged_spec/models/line_item1.rb', line 57

def self.optionals
  %w[
    quantity
    unit_price
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



107
108
109
110
111
# File 'lib/visa_acceptance_merged_spec/models/line_item1.rb', line 107

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

#to_sObject

Provides a human-readable string representation of the object.



100
101
102
103
104
# File 'lib/visa_acceptance_merged_spec/models/line_item1.rb', line 100

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