Class: Edi::Amazon::JsonListingGenerator::Attributes::ItemLengthWidthHeight
- Inherits:
-
BaseAttribute
- Object
- BaseAttribute
- Edi::Amazon::JsonListingGenerator::Attributes::ItemLengthWidthHeight
- Defined in:
- app/services/edi/amazon/json_listing_generator/attributes/item_length_width_height.rb
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
#build ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/services/edi/amazon/json_listing_generator/attributes/item_length_width_height.rb', line 3 def build # This is one of those rare one in canada that doesn't take inches but centimeters target_unit = @marketplace_country_iso == 'US' ? 'in' : 'cm' mapped_unit = map_unit(target_unit) dimensions = { length: { value: fetch_value(:length, output_unit: target_unit), unit: mapped_unit }, height: { value: fetch_value(:height, output_unit: target_unit), unit: mapped_unit }, width: { value: fetch_value(:width, output_unit: target_unit), unit: mapped_unit } } return if dimensions.any? { |_, dim| dim[:value].nil? || dim[:unit].nil? } dimensions[:marketplace_id] = marketplace_id [dimensions] end |