class KoronaClient::Product

Attributes

active[RW]

indicates whether the object is active for use or not

alternative_sector[RW]
assortment[RW]
codes[RW]
commodity_group[RW]
conversion[RW]
costs[RW]
deactivated[RW]
deposit[RW]
descriptions[RW]
discountable[RW]
id[RW]

global object uuid (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

image[RW]
info_texts[RW]
item_sequence[RW]
last_purchase_price[RW]
listed[RW]
listed_since[RW]
max_price[RW]
media_urls[RW]
min_price[RW]
name[RW]
number[RW]

number of the object, like it is set in backoffice; will be removed when active=false

packaging_quantity[RW]
packaging_required[RW]
packaging_unit[RW]
personalization_required[RW]
price_changable[RW]
prices[RW]
print_tickets_separately[RW]
production_type[RW]
quantity_denomination[RW]
revision[RW]

the revision number of the object. revision numbers are unique per object-type. there is is no object of the same type with identical revision numbers.

sector[RW]
serial_number_required[RW]
stock_return_unsellable[RW]
subproduct_presentation[RW]
subproducts[RW]
supplier_prices[RW]
tags[RW]
ticket_definition[RW]
track_inventory[RW]

Public Class Methods

attribute_map() click to toggle source

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

# File lib/korona_client/models/product.rb, line 132
def self.attribute_map
  {
    :'active' => :'active',
    :'id' => :'id',
    :'number' => :'number',
    :'revision' => :'revision',
    :'alternative_sector' => :'alternativeSector',
    :'assortment' => :'assortment',
    :'codes' => :'codes',
    :'commodity_group' => :'commodityGroup',
    :'conversion' => :'conversion',
    :'costs' => :'costs',
    :'deactivated' => :'deactivated',
    :'deposit' => :'deposit',
    :'descriptions' => :'descriptions',
    :'discountable' => :'discountable',
    :'image' => :'image',
    :'info_texts' => :'infoTexts',
    :'item_sequence' => :'itemSequence',
    :'last_purchase_price' => :'lastPurchasePrice',
    :'listed' => :'listed',
    :'listed_since' => :'listedSince',
    :'max_price' => :'maxPrice',
    :'min_price' => :'minPrice',
    :'name' => :'name',
    :'packaging_quantity' => :'packagingQuantity',
    :'packaging_required' => :'packagingRequired',
    :'packaging_unit' => :'packagingUnit',
    :'personalization_required' => :'personalizationRequired',
    :'price_changable' => :'priceChangable',
    :'prices' => :'prices',
    :'print_tickets_separately' => :'printTicketsSeparately',
    :'production_type' => :'productionType',
    :'recommended_retail_price' => :'recommendedRetailPrice',
    :'related_products' => :'relatedProducts',
    :'sector' => :'sector',
    :'serial_number_required' => :'serialNumberRequired',
    :'subproduct_presentation' => :'subproductPresentation',
    :'subproducts' => :'subproducts',
    :'supplier_prices' => :'supplierPrices',
    :'tags' => :'tags',
    :'ticket_definition' => :'ticketDefinition',
    :'track_inventory' => :'trackInventory',
    :'media_urls' => :'mediaUrls',
    :'quantity_denomination' => :'quantityDenomination',
    :'stock_return_unsellable' => :'stockReturnUnsellable'
  }
end
new(attributes = {}) click to toggle source

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

# File lib/korona_client/models/product.rb, line 233
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?(:'active')
    self.active = attributes[:'active']
  end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Attribute type mapping.

# File lib/korona_client/models/product.rb, line 182
def self.swagger_types
  {
    :'active' => :'BOOLEAN',
    :'id' => :'String',
    :'number' => :'String',
    :'revision' => :'Integer',
    :'alternative_sector' => :'ModelReference',
    :'assortment' => :'ModelReference',
    :'codes' => :'Array<ProductCode>',
    :'commodity_group' => :'ModelReference',
    :'conversion' => :'BOOLEAN',
    :'costs' => :'Float',
    :'deactivated' => :'BOOLEAN',
    :'deposit' => :'BOOLEAN',
    :'descriptions' => :'Array<ProductDescription>',
    :'discountable' => :'BOOLEAN',
    :'image' => :'ModelReference',
    :'info_texts' => :'Array<ModelReference>',
    :'item_sequence' => :'ModelReference',
    :'last_purchase_price' => :'Float',
    :'listed' => :'BOOLEAN',
    :'listed_since' => :'DateTime',
    :'max_price' => :'Float',
    :'min_price' => :'Float',
    :'name' => :'String',
    :'packaging_quantity' => :'Float',
    :'packaging_required' => :'BOOLEAN',
    :'packaging_unit' => :'String',
    :'personalization_required' => :'BOOLEAN',
    :'price_changable' => :'BOOLEAN',
    :'prices' => :'Array<ProductPrice>',
    :'print_tickets_separately' => :'BOOLEAN',
    :'production_type' => :'ModelReference',
    :'recommended_retail_price' => :'Float',
    :'related_products' => :'ModelReference',
    :'sector' => :'ModelReference',
    :'serial_number_required' => :'BOOLEAN',
    :'subproduct_presentation' => :'String',
    :'subproducts' => :'Array<ProductSubproduct>',
    :'supplier_prices' => :'Array<ProductSupplierPrice>',
    :'tags' => :'Array<ModelReference>',
    :'ticket_definition' => :'ModelReference',
    :'track_inventory' => :'BOOLEAN',
    :'media_urls' => :'Array<MediaUrl>',
    :'quantity_denomination' => :'Float',
    :'stock_return_unsellable' => :'BOOLEAN'
  }
end

Public Instance Methods

==(o) click to toggle source

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

# File lib/korona_client/models/product.rb, line 471
def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      active == o.active &&
      id == o.id &&
      number == o.number &&
      revision == o.revision &&
      alternative_sector == o.alternative_sector &&
      assortment == o.assortment &&
      codes == o.codes &&
      commodity_group == o.commodity_group &&
      conversion == o.conversion &&
      costs == o.costs &&
      deactivated == o.deactivated &&
      deposit == o.deposit &&
      descriptions == o.descriptions &&
      discountable == o.discountable &&
      image == o.image &&
      info_texts == o.info_texts &&
      item_sequence == o.item_sequence &&
      last_purchase_price == o.last_purchase_price &&
      listed == o.listed &&
      listed_since == o.listed_since &&
      max_price == o.max_price &&
      min_price == o.min_price &&
      name == o.name &&
      packaging_quantity == o.packaging_quantity &&
      packaging_required == o.packaging_required &&
      packaging_unit == o.packaging_unit &&
      personalization_required == o.personalization_required &&
      price_changable == o.price_changable &&
      prices == o.prices &&
      print_tickets_separately == o.print_tickets_separately &&
      production_type == o.production_type &&
      recommended_retail_price == o.recommended_retail_price &&
      related_products == o.related_products &&
      sector == o.sector &&
      serial_number_required == o.serial_number_required &&
      subproduct_presentation == o.subproduct_presentation &&
      subproducts == o.subproducts &&
      supplier_prices == o.supplier_prices &&
      tags == o.tags &&
      ticket_definition == o.ticket_definition &&
      track_inventory == o.track_inventory &&
      media_urls == o.media_urls &&
      quantity_denomination == o.quantity_denomination &&
      stock_return_unsellable == o.stock_return_unsellable
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/korona_client/models/product.rb, line 556
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 = KoronaClient.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/korona_client/models/product.rb, line 622
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/korona_client/models/product.rb, line 535
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 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/korona_client/models/product.rb, line 522
def eql?(o)
  self == o
end
hash() click to toggle source

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

# File lib/korona_client/models/product.rb, line 528
def hash
  [active, id, number, revision, alternative_sector, assortment, codes, commodity_group, conversion, costs, deactivated, deposit, descriptions, discountable, image, info_texts, item_sequence, last_purchase_price, listed, listed_since, max_price, min_price, name, packaging_quantity, packaging_required, packaging_unit, personalization_required, price_changable, prices, print_tickets_separately, production_type, recommended_retail_price, related_products, sector, serial_number_required, subproduct_presentation, subproducts, supplier_prices, tags, ticket_definition, track_inventory, media_urls, quantity_denomination, stock_return_unsellable].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/korona_client/models/product.rb, line 434
def list_invalid_properties
  invalid_properties = Array.new
  invalid_properties
end
packaging_unit=(packaging_unit) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] packaging_unit Object to be assigned

# File lib/korona_client/models/product.rb, line 451
def packaging_unit=(packaging_unit)
  validator = EnumAttributeValidator.new('String', ['CUBIC_INCH', 'CUBIC_METER', 'FLUID_OUNCE', 'GALLON_FL', 'GRAM', 'INCH', 'KILOGRAM', 'LITER', 'METER', 'MILLILITER', 'OUNCE', 'POUND', 'SQUARE_INCH', 'SQUARE_METER'])
  unless validator.valid?(packaging_unit)
    fail ArgumentError, 'invalid value for "packaging_unit", must be one of #{validator.allowable_values}.'
  end
  @packaging_unit = packaging_unit
end
subproduct_presentation=(subproduct_presentation) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] subproduct_presentation Object to be assigned

# File lib/korona_client/models/product.rb, line 461
def subproduct_presentation=(subproduct_presentation)
  validator = EnumAttributeValidator.new('String', ['DEFAULT', 'HIDE_ALL', 'HIDE_PRICES', 'HIDE_QUANTITIES'])
  unless validator.valid?(subproduct_presentation)
    fail ArgumentError, 'invalid value for "subproduct_presentation", must be one of #{validator.allowable_values}.'
  end
  @subproduct_presentation = subproduct_presentation
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/korona_client/models/product.rb, line 602
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/korona_client/models/product.rb, line 608
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/korona_client/models/product.rb, line 596
def to_s
  to_hash.to_s
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/korona_client/models/product.rb, line 441
def valid?
  packaging_unit_validator = EnumAttributeValidator.new('String', ['CUBIC_INCH', 'CUBIC_METER', 'FLUID_OUNCE', 'GALLON_FL', 'GRAM', 'INCH', 'KILOGRAM', 'LITER', 'METER', 'MILLILITER', 'OUNCE', 'POUND', 'SQUARE_INCH', 'SQUARE_METER'])
  return false unless packaging_unit_validator.valid?(@packaging_unit)
  subproduct_presentation_validator = EnumAttributeValidator.new('String', ['DEFAULT', 'HIDE_ALL', 'HIDE_PRICES', 'HIDE_QUANTITIES'])
  return false unless subproduct_presentation_validator.valid?(@subproduct_presentation)
  true
end