Class: Edi::Wayfair::ListingGenerator::Attributes::HeatingElement

Inherits:
BaseAttribute
  • Object
show all
Defined in:
app/services/edi/wayfair/listing_generator/attributes/heating_element.rb

Overview

Maps heating element type from Item to Wayfair's Heating Element attribute
Taxonomy Attribute ID: 186664
Datatype: MULTI_CHOICE
Values: Coil, Ceramic, Oil / Water Filled, Mica, PTC, Quartz, Carbon, Ribbon, Fan, Halogen, Infrared

Constant Summary collapse

HEATING_ELEMENT_MAP =
{
  'coil' => 'Coil',
  'ceramic' => 'Ceramic',
  'oil' => 'Oil / Water Filled',
  'oil_filled' => 'Oil / Water Filled',
  'water_filled' => 'Oil / Water Filled',
  'mica' => 'Mica',
  'ptc' => 'PTC',
  'quartz' => 'Quartz',
  'carbon' => 'Carbon',
  'carbon_fiber' => 'Carbon',
  'ribbon' => 'Ribbon',
  'fan' => 'Fan',
  'halogen' => 'Halogen',
  'infrared' => 'Infrared',
  'radiant' => 'Infrared'
}.with_indifferent_access.freeze

Constants inherited from BaseAttribute

BaseAttribute::UNIT_MAPPINGS

Instance Attribute Summary

Attributes inherited from BaseAttribute

#attribute_definition, #catalog_item, #item, #taxonomy_attribute_id, #wayfair_schema

Instance Method Summary collapse

Methods inherited from BaseAttribute

attribute_name, #attribute_title, #build, #build_attribute_hash, #can_build?, #custom_values_allowed?, #datatype, #fetch_value, #format_boolean, #format_decimal, #initialize, #map_unit, #possible_values, #requirement, set_taxonomy_attribute_id, taxonomy_attribute_id, #valid_value?

Constructor Details

This class inherits a constructor from Edi::Wayfair::ListingGenerator::Attributes::BaseAttribute

Instance Method Details

#valueObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/services/edi/wayfair/listing_generator/attributes/heating_element.rb', line 29

def value
  element = fetch_value(:heating_element) || fetch_value(:heat_element)

  # Default for radiant panels is typically Carbon or Infrared
  if element.blank?
    # Check item name or description for hints
    name = item.name.to_s.downcase
    if name.include?('infrared') || name.include?('radiant')
      element = 'Infrared'
    elsif name.include?('carbon')
      element = 'Carbon'
    end
  end

  return nil if element.blank?

  # Handle array or single value
  elements = element.is_a?(Array) ? element : [element]

  elements.map do |el|
    mapped = HEATING_ELEMENT_MAP[el.to_s.downcase.strip]
    mapped || el.to_s.titleize
  end.compact.uniq
end