Class: Edi::Wayfair::ListingGenerator::Attributes::FuelType

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

Overview

Maps fuel type from Item to Wayfair's Fuel Type attribute
Taxonomy Attribute ID: 913
Datatype: MULTI_CHOICE
Values: Electric, Dual Fuel, Induction, Natural Gas, Propane, Kerosene, Oil, Wood, Pellet, Coal, Gel, Solar

Constant Summary collapse

FUEL_TYPE_MAP =

Mapping from our internal values to Wayfair's expected values

{
  'electric' => 'Electric',
  'electricity' => 'Electric',
  'natural_gas' => 'Natural Gas',
  'gas' => 'Natural Gas',
  'propane' => 'Propane',
  'kerosene' => 'Kerosene',
  'oil' => 'Oil',
  'wood' => 'Wood',
  'pellet' => 'Pellet',
  'coal' => 'Coal',
  'gel' => 'Gel',
  'solar' => 'Solar',
  'dual' => 'Dual Fuel',
  'infrared' => 'Electric' # Infrared heaters are typically electric
}.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
# File 'app/services/edi/wayfair/listing_generator/attributes/fuel_type.rb', line 29

def value
  fuel = fetch_value(:fuel_type) || fetch_value(:power_source)

  # Default to Electric for our radiant heating products
  fuel ||= 'Electric' if item.watts.present? && item.watts > 0

  return nil if fuel.blank?

  # Map to Wayfair's expected value
  mapped = FUEL_TYPE_MAP[fuel.to_s.downcase.strip]
  mapped || fuel.to_s.titleize
end