Class: Edi::Amazon::JsonListingGenerator::Attributes::UnitCount

Inherits:
BaseAttribute
  • Object
show all
Defined in:
app/services/edi/amazon/json_listing_generator/attributes/unit_count.rb

Overview

I'm perplexed by this value, the enum value is count lower case but it
only takes Count in uppercase, at least for electric heating pad

Constant Summary

Constants inherited from BaseAttribute

BaseAttribute::RUBY_UNIT_TO_AMAZON_UNIT

Instance Attribute Summary

Attributes inherited from BaseAttribute

#amazon_schema, #attribute_name, #catalog_item, #enum_mapper, #fba, #item, #language_tag, #marketplace, #marketplace_country_iso, #marketplace_id, #value_attribute_name, #variation

Instance Method Summary collapse

Methods inherited from BaseAttribute

#fetch_unit, #fetch_value, #initialize, #map_unit, #value

Constructor Details

This class inherits a constructor from Edi::Amazon::JsonListingGenerator::Attributes::BaseAttribute

Instance Method Details

#buildObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/services/edi/amazon/json_listing_generator/attributes/unit_count.rb', line 5

def build
  unit_count_value = case marketplace_country_iso
                     when 'US'
                       'Count'
                     else
                       'count'
                     end
  unit_value =  case marketplace_country_iso
                when 'US', 'CA'
                  1
                else
                  '1'
                end
  [
    {
      value: unit_value,
      type: {
        value: unit_count_value,
        language_tag:
      },
      marketplace_id:
    }
  ]
end