class Wallee::LineItem

Attributes

aggregated_tax_rate[RW]

The aggregated tax rate is the sum of all tax rates of the line item.

amount_excluding_tax[RW]
amount_including_tax[RW]
attributes[RW]
discount_excluding_tax[RW]
discount_including_tax[RW]
name[RW]
quantity[RW]
shipping_required[RW]
sku[RW]
tax_amount[RW]
tax_amount_per_unit[RW]
taxes[RW]
type[RW]
undiscounted_amount_excluding_tax[RW]
undiscounted_amount_including_tax[RW]
undiscounted_unit_price_excluding_tax[RW]
undiscounted_unit_price_including_tax[RW]
unique_id[RW]

The unique id identifies the line item within the set of line items associated with the transaction.

unit_price_excluding_tax[RW]
unit_price_including_tax[RW]

Public Class Methods

attribute_map() click to toggle source

Attribute mapping from ruby-style variable name to JSON key.

# File lib/wallee-ruby-sdk/models/line_item.rb, line 87
def self.attribute_map
  {
    :'aggregated_tax_rate' => :'aggregatedTaxRate',
    :'amount_excluding_tax' => :'amountExcludingTax',
    :'amount_including_tax' => :'amountIncludingTax',
    :'attributes' => :'attributes',
    :'discount_excluding_tax' => :'discountExcludingTax',
    :'discount_including_tax' => :'discountIncludingTax',
    :'name' => :'name',
    :'quantity' => :'quantity',
    :'shipping_required' => :'shippingRequired',
    :'sku' => :'sku',
    :'tax_amount' => :'taxAmount',
    :'tax_amount_per_unit' => :'taxAmountPerUnit',
    :'taxes' => :'taxes',
    :'type' => :'type',
    :'undiscounted_amount_excluding_tax' => :'undiscountedAmountExcludingTax',
    :'undiscounted_amount_including_tax' => :'undiscountedAmountIncludingTax',
    :'undiscounted_unit_price_excluding_tax' => :'undiscountedUnitPriceExcludingTax',
    :'undiscounted_unit_price_including_tax' => :'undiscountedUnitPriceIncludingTax',
    :'unique_id' => :'uniqueId',
    :'unit_price_excluding_tax' => :'unitPriceExcludingTax',
    :'unit_price_including_tax' => :'unitPriceIncludingTax'
  }
end
new(attributes = {}) click to toggle source

Initializes the object @param [Hash] attributes Model attributes in the form of hash

# File lib/wallee-ruby-sdk/models/line_item.rb, line 142
def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  if attributes.has_key?(:'aggregatedTaxRate')
    self.aggregated_tax_rate = attributes[:'aggregatedTaxRate']
  end

  if attributes.has_key?(:'amountExcludingTax')
    self.amount_excluding_tax = attributes[:'amountExcludingTax']
  end

  if attributes.has_key?(:'amountIncludingTax')
    self.amount_including_tax = attributes[:'amountIncludingTax']
  end

  if attributes.has_key?(:'attributes')
    if (value = attributes[:'attributes']).is_a?(Hash)
      self.attributes = value
    end
  end

  if attributes.has_key?(:'discountExcludingTax')
    self.discount_excluding_tax = attributes[:'discountExcludingTax']
  end

  if attributes.has_key?(:'discountIncludingTax')
    self.discount_including_tax = attributes[:'discountIncludingTax']
  end

  if attributes.has_key?(:'name')
    self.name = attributes[:'name']
  end

  if attributes.has_key?(:'quantity')
    self.quantity = attributes[:'quantity']
  end

  if attributes.has_key?(:'shippingRequired')
    self.shipping_required = attributes[:'shippingRequired']
  end

  if attributes.has_key?(:'sku')
    self.sku = attributes[:'sku']
  end

  if attributes.has_key?(:'taxAmount')
    self.tax_amount = attributes[:'taxAmount']
  end

  if attributes.has_key?(:'taxAmountPerUnit')
    self.tax_amount_per_unit = attributes[:'taxAmountPerUnit']
  end

  if attributes.has_key?(:'taxes')
    if (value = attributes[:'taxes']).is_a?(Array)
      self.taxes = value
    end
  end

  if attributes.has_key?(:'type')
    self.type = attributes[:'type']
  end

  if attributes.has_key?(:'undiscountedAmountExcludingTax')
    self.undiscounted_amount_excluding_tax = attributes[:'undiscountedAmountExcludingTax']
  end

  if attributes.has_key?(:'undiscountedAmountIncludingTax')
    self.undiscounted_amount_including_tax = attributes[:'undiscountedAmountIncludingTax']
  end

  if attributes.has_key?(:'undiscountedUnitPriceExcludingTax')
    self.undiscounted_unit_price_excluding_tax = attributes[:'undiscountedUnitPriceExcludingTax']
  end

  if attributes.has_key?(:'undiscountedUnitPriceIncludingTax')
    self.undiscounted_unit_price_including_tax = attributes[:'undiscountedUnitPriceIncludingTax']
  end

  if attributes.has_key?(:'uniqueId')
    self.unique_id = attributes[:'uniqueId']
  end

  if attributes.has_key?(:'unitPriceExcludingTax')
    self.unit_price_excluding_tax = attributes[:'unitPriceExcludingTax']
  end

  if attributes.has_key?(:'unitPriceIncludingTax')
    self.unit_price_including_tax = attributes[:'unitPriceIncludingTax']
  end
end
swagger_types() click to toggle source

Attribute type mapping.

# File lib/wallee-ruby-sdk/models/line_item.rb, line 114
def self.swagger_types
  {
    :'aggregated_tax_rate' => :'Float',
    :'amount_excluding_tax' => :'Float',
    :'amount_including_tax' => :'Float',
    :'attributes' => :'Hash<String, LineItemAttribute>',
    :'discount_excluding_tax' => :'Float',
    :'discount_including_tax' => :'Float',
    :'name' => :'String',
    :'quantity' => :'Float',
    :'shipping_required' => :'BOOLEAN',
    :'sku' => :'String',
    :'tax_amount' => :'Float',
    :'tax_amount_per_unit' => :'Float',
    :'taxes' => :'Array<Tax>',
    :'type' => :'LineItemType',
    :'undiscounted_amount_excluding_tax' => :'Float',
    :'undiscounted_amount_including_tax' => :'Float',
    :'undiscounted_unit_price_excluding_tax' => :'Float',
    :'undiscounted_unit_price_including_tax' => :'Float',
    :'unique_id' => :'String',
    :'unit_price_excluding_tax' => :'Float',
    :'unit_price_including_tax' => :'Float'
  }
end

Public Instance Methods

==(o) click to toggle source

Checks equality by comparing each attribute. @param [Object] Object to be compared

# File lib/wallee-ruby-sdk/models/line_item.rb, line 306
def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      aggregated_tax_rate == o.aggregated_tax_rate &&
      amount_excluding_tax == o.amount_excluding_tax &&
      amount_including_tax == o.amount_including_tax &&
      attributes == o.attributes &&
      discount_excluding_tax == o.discount_excluding_tax &&
      discount_including_tax == o.discount_including_tax &&
      name == o.name &&
      quantity == o.quantity &&
      shipping_required == o.shipping_required &&
      sku == o.sku &&
      tax_amount == o.tax_amount &&
      tax_amount_per_unit == o.tax_amount_per_unit &&
      taxes == o.taxes &&
      type == o.type &&
      undiscounted_amount_excluding_tax == o.undiscounted_amount_excluding_tax &&
      undiscounted_amount_including_tax == o.undiscounted_amount_including_tax &&
      undiscounted_unit_price_excluding_tax == o.undiscounted_unit_price_excluding_tax &&
      undiscounted_unit_price_including_tax == o.undiscounted_unit_price_including_tax &&
      unique_id == o.unique_id &&
      unit_price_excluding_tax == o.unit_price_excluding_tax &&
      unit_price_including_tax == o.unit_price_including_tax
end
_deserialize(type, value) click to toggle source

Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data

# File lib/wallee-ruby-sdk/models/line_item.rb, line 368
def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :BOOLEAN
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    temp_model = Wallee.const_get(type).new
    temp_model.build_from_hash(value)
  end
end
_to_hash(value) click to toggle source

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash

# File lib/wallee-ruby-sdk/models/line_item.rb, line 434
def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map{ |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end
build_from_hash(attributes) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself

# File lib/wallee-ruby-sdk/models/line_item.rb, line 347
def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end
eql?(o) click to toggle source

@see the `==` method @param [Object] Object to be compared

# File lib/wallee-ruby-sdk/models/line_item.rb, line 334
def eql?(o)
  self == o
end
hash() click to toggle source

Calculates hash code according to all attributes. @return [Fixnum] Hash code

# File lib/wallee-ruby-sdk/models/line_item.rb, line 340
def hash
  [aggregated_tax_rate, amount_excluding_tax, amount_including_tax, attributes, discount_excluding_tax, discount_including_tax, name, quantity, shipping_required, sku, tax_amount, tax_amount_per_unit, taxes, type, undiscounted_amount_excluding_tax, undiscounted_amount_including_tax, undiscounted_unit_price_excluding_tax, undiscounted_unit_price_including_tax, unique_id, unit_price_excluding_tax, unit_price_including_tax].hash
end
list_invalid_properties() click to toggle source

Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons

# File lib/wallee-ruby-sdk/models/line_item.rb, line 239
def list_invalid_properties
  invalid_properties = Array.new
  if !@name.nil? && @name.to_s.length > 150
    invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 150.')
  end

  if !@name.nil? && @name.to_s.length < 1
    invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
  end

  if !@sku.nil? && @sku.to_s.length > 200
    invalid_properties.push('invalid value for "sku", the character length must be smaller than or equal to 200.')
  end

  if !@unique_id.nil? && @unique_id.to_s.length > 200
    invalid_properties.push('invalid value for "unique_id", the character length must be smaller than or equal to 200.')
  end

  invalid_properties
end
name=(name) click to toggle source

Custom attribute writer method with validation @param [Object] name Value to be assigned

# File lib/wallee-ruby-sdk/models/line_item.rb, line 272
def name=(name)
  if !name.nil? && name.to_s.length > 150
    fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 150.'
  end

  if !name.nil? && name.to_s.length < 1
    fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
  end

  @name = name
end
sku=(sku) click to toggle source

Custom attribute writer method with validation @param [Object] sku Value to be assigned

# File lib/wallee-ruby-sdk/models/line_item.rb, line 286
def sku=(sku)
  if !sku.nil? && sku.to_s.length > 200
    fail ArgumentError, 'invalid value for "sku", the character length must be smaller than or equal to 200.'
  end

  @sku = sku
end
to_body() click to toggle source

to_body is an alias to to_hash (backward compatibility) @return [Hash] Returns the object in the form of hash

# File lib/wallee-ruby-sdk/models/line_item.rb, line 414
def to_body
  to_hash
end
to_hash() click to toggle source

Returns the object in the form of hash @return [Hash] Returns the object in the form of hash

# File lib/wallee-ruby-sdk/models/line_item.rb, line 420
def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end
to_s() click to toggle source

Returns the string representation of the object @return [String] String presentation of the object

# File lib/wallee-ruby-sdk/models/line_item.rb, line 408
def to_s
  to_hash.to_s
end
unique_id=(unique_id) click to toggle source

Custom attribute writer method with validation @param [Object] unique_id Value to be assigned

# File lib/wallee-ruby-sdk/models/line_item.rb, line 296
def unique_id=(unique_id)
  if !unique_id.nil? && unique_id.to_s.length > 200
    fail ArgumentError, 'invalid value for "unique_id", the character length must be smaller than or equal to 200.'
  end

  @unique_id = unique_id
end
valid?() click to toggle source

Check to see if the all the properties in the model are valid @return true if the model is valid

# File lib/wallee-ruby-sdk/models/line_item.rb, line 262
def valid?
  return false if !@name.nil? && @name.to_s.length > 150
  return false if !@name.nil? && @name.to_s.length < 1
  return false if !@sku.nil? && @sku.to_s.length > 200
  return false if !@unique_id.nil? && @unique_id.to_s.length > 200
  true
end