Class: Edi::Amazon::JsonListingGenerator::Attributes::FulfillmentAvailability
- Inherits:
-
BaseAttribute
- Object
- BaseAttribute
- Edi::Amazon::JsonListingGenerator::Attributes::FulfillmentAvailability
- Defined in:
- app/services/edi/amazon/json_listing_generator/attributes/fulfillment_availability.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
-
#build ⇒ Object
see: https://developer-docs.amazon.com/sp-api/docs/listings-items-api-v2021-08-01-reference#listingsitempatchrequest see: https://developer-docs.amazon.com/sp-api/docs/listings-items-api-v2021-08-01-reference#patchoperation see: https://developer-docs.amazon.com/sp-api/docs/listing-workflow-migration-tutorial#migrating-inventory-feeds-workflows "patches": [ { "op": "replace", "path": "/attributes/fulfillment_availability", "value": [ { "fulfillment_channel_code": "DEFAULT", "quantity": 10 } ] } ].
- #value ⇒ Object
Methods inherited from BaseAttribute
#fetch_unit, #fetch_value, #initialize, #map_unit
Constructor Details
This class inherits a constructor from Edi::Amazon::JsonListingGenerator::Attributes::BaseAttribute
Instance Method Details
#build ⇒ Object
see: https://developer-docs.amazon.com/sp-api/docs/listings-items-api-v2021-08-01-reference#listingsitempatchrequest
see: https://developer-docs.amazon.com/sp-api/docs/listings-items-api-v2021-08-01-reference#patchoperation
see: https://developer-docs.amazon.com/sp-api/docs/listing-workflow-migration-tutorial#migrating-inventory-feeds-workflows
"patches": [
{
"op": "replace",
"path": "/attributes/fulfillment_availability",
"value": [
{
"fulfillment_channel_code": "DEFAULT",
"quantity": 10
}
]
}
]
18 19 20 |
# File 'app/services/edi/amazon/json_listing_generator/attributes/fulfillment_availability.rb', line 18 def build [value] end |
#value ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/services/edi/amazon/json_listing_generator/attributes/fulfillment_availability.rb', line 22 def value if fba { fulfillment_channel_code: catalog_item.catalog.amazon_marketplace.fba_channel_code } else discontinued = catalog_item.discontinued? || catalog_item.pending_discontinue? || catalog_item.in_hide_from_feed_state? use_alternate_warehouse = true use_alternate_warehouse = false if catalog_item.catalog.country_iso3 == 'USA' # turn off because of very high/erroroneous tariffs/duties, and many other things that go wrong with Canada to US cross-border fulfillments quantity = (discontinued ? 0 : catalog_item.reported_stock(use_alternate_warehouse: use_alternate_warehouse, safety_stock: 0)) lead_time_to_ship_max_days = case catalog_item.catalog.country_iso3 when 'CAN' 2 when 'USA' 1 else # for Europe per Christian, use this logic: if catalog_item.sku.starts_with?('TWE') 1 elsif catalog_item.sku.starts_with?('IPE') 2 else 1 end end if quantity.zero? && !discontinued && %w[CAN].include?(catalog_item.catalog.country_iso3) # See if we would get quantity by fulfilling from alternate warehouses for US/Canada only, otherwise one fulfillment center/3PL for EU so skip quantity = catalog_item.reported_stock(use_alternate_warehouse: use_alternate_warehouse, safety_stock: 0) # In that case take a 5 day latency to fulfill from alternate warehouse for a regular item lead_time_to_ship_max_days += 4 if quantity.positive? end { fulfillment_channel_code: 'DEFAULT', quantity: quantity, lead_time_to_ship_max_days: lead_time_to_ship_max_days } end end |