Class: Edi::AmazonVc::Orchestrator
- Inherits:
-
BaseOrchestrator
- Object
- BaseOrchestrator
- Edi::AmazonVc::Orchestrator
- Defined in:
- app/services/edi/amazon_vc/orchestrator.rb
Constant Summary collapse
- GOLIVE_DATE_STR =
'December 31, 2020'
Constants inherited from BaseOrchestrator
BaseOrchestrator::DEFAULT_PENDING_DISCONTINUE_LIFETIME, BaseOrchestrator::ORCHESTRATORS, BaseOrchestrator::RECOMMENDED_EXECUTE_FLOW_EVERY_X_HOUR
Instance Attribute Summary
Attributes inherited from BaseOrchestrator
Class Method Summary collapse
- .execute_transaction_message_processor(options = {}) ⇒ Object
- .partners ⇒ Object
- .populate_items_from_all_partners(limit: nil, skus: nil, force: false) ⇒ Object
Instance Method Summary collapse
- #acknowledge_message_enabled? ⇒ Boolean
- #acknowledge_message_sender ⇒ Object
- #catalog_item_information_enabled? ⇒ Boolean
- #catalog_item_information_processor ⇒ Object
- #catalog_item_information_retriever ⇒ Object
- #confirm_message_enabled? ⇒ Boolean
- #confirm_message_processor ⇒ Object
- #confirm_message_sender ⇒ Object (also: #shipment_message_sender)
-
#confirm_outbound_processing? ⇒ Boolean
Amazon VC is a two stage process on , processing.
- #delete_listing_from_catalog_item(catalog_item: nil, amazon_variation: nil, http_method: 'DELETE', attribute_actions: nil, use_fba_sku: false) ⇒ Object
- #delete_listing_message_processor ⇒ Object
- #execute_inventory_flow ⇒ Object
- #execute_order_flow ⇒ Object
- #ignore_back_orders ⇒ Object
- #inventory_message_enabled? ⇒ Boolean
- #inventory_message_processor ⇒ Object
- #inventory_message_sender ⇒ Object
- #invoice_message_enabled? ⇒ Boolean
- #invoice_message_processor ⇒ Object
- #invoice_message_sender ⇒ Object
- #listing_item_information_processor ⇒ Object
- #listing_item_information_retriever ⇒ Object
- #listing_message_enabled? ⇒ Boolean
- #listing_message_feed_enabled? ⇒ Boolean
- #listing_message_feed_processor ⇒ Object
- #listing_message_feed_sender ⇒ Object
- #listing_message_processor ⇒ Object
- #listing_message_sender ⇒ Object
- #merchant_id ⇒ Object
- #old_catalog_item_information_enabled? ⇒ Boolean
- #old_catalog_item_information_processor ⇒ Object
- #old_catalog_item_information_retriever ⇒ Object
- #old_listing_item_validation_errors_retriever ⇒ Object
- #old_listing_item_validation_errors_retriever? ⇒ Boolean
- #old_pull_catalog_information(catalog_item) ⇒ Object
- #order_message_enabled? ⇒ Boolean
- #order_message_processor ⇒ Object
- #order_message_retriever ⇒ Object
- #packing_slip_enabled? ⇒ Boolean
- #packing_slip_processor ⇒ Object
- #packing_slip_retriever ⇒ Object
-
#populate_items_from_catalog(limit: nil, skus: nil, force: false) ⇒ Object
A method to populate our item data with amazon's catalog data limit: how many records to process skus: specific skus to process force: normally we only will pull if the information is not present, use this to force a reset.
- #pull_amazon_variation_listing_information(amazon_variation) ⇒ Object
- #pull_catalog_information(catalog_item) ⇒ Object
- #pull_listing_information(catalog_item) ⇒ Object
- #push_listing_from_amazon_variation(amazon_variation) ⇒ Object
- #push_listing_from_catalog_item(catalog_item, http_method: 'PATCH', attribute_actions: nil, use_fba_sku: false) ⇒ Object
- #return_notification_message_enabled? ⇒ Boolean
- #return_notification_message_processor ⇒ Object
- #return_notification_message_sender ⇒ Object
- #ship_code_mapper ⇒ Object
- #transaction_message_enabled? ⇒ Boolean
- #transaction_message_processor ⇒ Object
Methods inherited from BaseOrchestrator
all_orchestrators_class, build, cached_build, cached_orchestrators, catalog_id_to_pending_discontinue_lifetime, catalog_ids_edi_enabled, #customer, #customer_catalog, customer_id_to_partner_key_map, #customer_ids, customer_ids_edi_enabled, customer_ids_with_invoice_message_enabled, #customers, execute_discontinue_flow, execute_flow, execute_inventory_flow, execute_listing_message_feed_flow, execute_order_flow, execute_price_flow, #execute_price_flow, execute_product_data_flow, #execute_product_data_flow, #initialize, orchestrator_for_customer_id, orchestrators, #pending_discontinue_lifetime, #price_message_enabled?, #product_data_enabled?, #should_execute_flow?, #should_execute_order_flow?, #should_execute_product_data_flow?, #test_mode?
Constructor Details
This class inherits a constructor from Edi::BaseOrchestrator
Class Method Details
.execute_transaction_message_processor(options = {}) ⇒ Object
211 212 213 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 211 def self.( = {}) orchestrators().each { |o| o..process } end |
.partners ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 7 def self.partners { amazon_vc_seller_api_wax7v: { active: true, partner: :amazon_vc_seller_api_wax7v, vendor_code: 'WAX7V', warehouse_code: 'DFEE', # here we are using the code, no hash customer_id: 4_267_467, locales: ['en_US'], marketplace: 'ATVPDKIKX0DER', # match existing Vendor Central Direct Fulfillment invoices exactly vendor_name: CompanyConstants::ADDRESS[:usa][:company_name].upcase, vendor_address_street1: CompanyConstants::ADDRESS[:usa][:street1], vendor_address_street2: CompanyConstants::ADDRESS[:usa][:street2], vendor_address_city: CompanyConstants::ADDRESS[:usa][:city], vendor_address_state: CompanyConstants::ADDRESS[:usa][:state], vendor_address_postal_code: CompanyConstants::ADDRESS[:usa][:postal_code], vendor_address_country: CompanyConstants::ADDRESS[:usa][:country], tax_registration_number: nil, transporter: :http_seller_api, transporter_profile: :amazon_vc_seller_api_wax7v, inventory_message_remote_path: nil, # "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wax7v, :api_host)}/vendor/directFulfillment/inventory/v1/warehouses", # POST to inventory_message_remote_path/warehouse_code/items order_message_remote_path: nil, # "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wax7v, :api_host)}/vendor/directFulfillment/orders/v1/purchaseOrders", # GET from order_message_remote_path?shipFromPartyId=warehouse_code&limit=X&createdAfter=Y&createdBefore=Z&sortOrder=DESC&includeDetails=true HERE WE USE PRODUCTION HOST TO GET REAL DATA TO PROCESS BECAUSE SANDBOX DATA IS USELESS packing_slip_remote_path: nil, # "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wax7v, :api_host)}/vendor/directFulfillment/shipping/v1/packingSlips", # GET from packing_slip_remote_path?shipFromPartyId=warehouse_code&limit=X&createdAfter=Y&createdBefore=Z&sortOrder=DESC HERE WE USE PRODUCTION HOST TO GET REAL DATA TO PROCESS BECAUSE SANDBOX DATA IS USELESS acknowledge_message_remote_path: nil, # "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wax7v, :api_host)}/vendor/directFulfillment/orders/v1/acknowledgements", # POST to acknowledge_message_remote_path shipment_message_remote_path: nil, # "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wax7v, :api_host)}/vendor/directFulfillment/shipping/v1/shipmentConfirmations", # Post to shipment_message_remote_path transaction_message_remote_path: nil, # "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wax7v, :api_host)}/vendor/directFulfillment/transactions/v1/transactions", failure_timeout_in_minutes: 30, catalog_item_information_remote_path: "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wax7v, :api_host)}/catalog/2022-04-01/items/", listing_message_remote_path: "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wax7v, :api_host)}/listings/2021-08-01/items/", listing_message_feed_enabled: false, support_contact: 'https://vendorcentral.amazon.com/hz/vendor/members/contact' }, amazon_vc_seller_api_wat4d: { active: true, partner: :amazon_vc_seller_api_wat4d, vendor_code: 'WAT4D', warehouse_code: 'AMDR', # here we are using the code, no hash customer_id: 2_742_665, locales: %w[en_CA fr_CA], marketplace: 'A2EUQ1WTGCTBG2', # match existing Vendor Central Direct Fulfillment invoices exactly vendor_name: 'WARMLYYOURS -DROPSHIP', vendor_address_street1: CompanyConstants::ADDRESS[:can][:street1], vendor_address_street2: CompanyConstants::ADDRESS[:can][:street2], vendor_address_city: CompanyConstants::ADDRESS[:can][:city], vendor_address_state: CompanyConstants::ADDRESS[:can][:state], vendor_address_postal_code: CompanyConstants::ADDRESS[:can][:postal_code], vendor_address_country: CompanyConstants::ADDRESS[:can][:country], tax_registration_type: 'VAT', tax_registration_number: '861387777RT0001', transporter: :http_seller_api, transporter_profile: :amazon_vc_seller_api_wat4d, inventory_message_remote_path: nil, # "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wat4d, :api_host)}/vendor/directFulfillment/inventory/v1/warehouses", # POST to inventory_message_remote_path/warehouse_code/items order_message_remote_path: nil, # "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wat4d, :api_host)}/vendor/directFulfillment/orders/v1/purchaseOrders", # GET from order_message_remote_path?shipFromPartyId=warehouse_code&limit=X&createdAfter=Y&createdBefore=Z&sortOrder=DESC&includeDetails=true packing_slip_remote_path: nil, # "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wat4d, :api_host)}/vendor/directFulfillment/shipping/v1/packingSlips", # GET from packing_slip_remote_path/po_number acknowledge_message_remote_path: nil, # "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wat4d, :api_host)}/vendor/directFulfillment/orders/v1/acknowledgements", # POST to acknowledge_message_remote_path shipment_message_remote_path: nil, # "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wat4d, :api_host)}/vendor/directFulfillment/shipping/v1/shipmentConfirmations", # Post to shipment_message_remote_path transaction_message_remote_path: nil, # "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wat4d, :api_host)}/vendor/directFulfillment/transactions/v1/transactions", failure_timeout_in_minutes: 30, catalog_item_information_remote_path: "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wat4d, :api_host)}/catalog/2022-04-01/items/", listing_message_remote_path: "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wat4d, :api_host)}/listings/2021-08-01/items/", listing_message_feed_enabled: false, support_contact: 'https://vendorcentral.amazon.com/hz/vendor/members/contact' }, amazon_vc_seller_api_wasn4: { active: true, partner: :amazon_vc_seller_api_wasn4, vendor_code: 'WASN4', warehouse_code: 'DFEE', # here we are using the code, no hash customer_id: 2_385_944, locales: ['en_US'], marketplace: 'ATVPDKIKX0DER', transporter: :http_seller_api, transporter_profile: :amazon_vc_seller_api_wax7v, # here we are sharing the API application and credentials that we have for amazon_vc_seller_api_wax7v failure_timeout_in_minutes: 30, catalog_item_information_remote_path: "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wax7v, :api_host)}/catalog/2022-04-01/items/", listing_message_remote_path: "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wax7v, :api_host)}/listings/2021-08-01/items/", listing_message_feed_enabled: false, support_contact: 'https://vendorcentral.amazon.com/hz/vendor/members/contact' }, amazon_vc_seller_api_watof: { active: true, partner: :amazon_vc_seller_api_watof, vendor_code: 'WAT0F', customer_id: 2_741_053, locales: %w[en_CA fr_CA], marketplace: 'A2EUQ1WTGCTBG2', transporter: :http_seller_api, transporter_profile: :amazon_vc_seller_api_wat4d, # here we are sharing the same API application and credentials that we have for amazon_vc_seller_api_wat4d failure_timeout_in_minutes: 30, catalog_item_information_remote_path: "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wat4d, :api_host)}/catalog/2022-04-01/items/", listing_message_remote_path: "https://#{Heatwave::Configuration.fetch(:amazon_vc_seller_api_wat4d, :api_host)}/listings/2021-08-01/items/", listing_message_feed_enabled: false, support_contact: 'https://vendorcentral.amazon.com/hz/vendor/members/contact' } } end |
.populate_items_from_all_partners(limit: nil, skus: nil, force: false) ⇒ Object
550 551 552 553 554 555 556 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 550 def self.populate_items_from_all_partners(limit: nil, skus: nil, force: false) res = {} orchestrators.each do |orchestrator| res[orchestrator.partner] = orchestrator.populate_items_from_catalog(limit:, skus:, force:) end res end |
Instance Method Details
#acknowledge_message_enabled? ⇒ Boolean
191 192 193 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 191 def try(:acknowledge_message_remote_path).present? end |
#acknowledge_message_sender ⇒ Object
195 196 197 198 199 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 195 def return Edi::NullProcessor.new(self, :acknowledge_message_sender, ) unless AcknowledgeMessageSender.new(self, ) end |
#catalog_item_information_enabled? ⇒ Boolean
247 248 249 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 247 def catalog_item_information_enabled? try(:catalog_item_information_remote_path).present? end |
#catalog_item_information_processor ⇒ Object
269 270 271 272 273 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 269 def catalog_item_information_processor return Edi::NullProcessor.new(self, :catalog_item_information_processor, ) unless catalog_item_information_enabled? CatalogItemInformationProcessor.new(self, ) end |
#catalog_item_information_retriever ⇒ Object
251 252 253 254 255 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 251 def catalog_item_information_retriever return Edi::NullProcessor.new(self, :catalog_item_information_retriever, ) unless catalog_item_information_enabled? CatalogItemInformationRetriever.new(self, ) end |
#confirm_message_enabled? ⇒ Boolean
174 175 176 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 174 def try(:shipment_message_remote_path).present? end |
#confirm_message_processor ⇒ Object
178 179 180 181 182 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 178 def return Edi::NullProcessor.new(self, :confirm_message_processor, ) unless ConfirmMessageProcessor.new(self, ) end |
#confirm_message_sender ⇒ Object Also known as: shipment_message_sender
184 185 186 187 188 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 184 def return Edi::NullProcessor.new(self, :confirm_message_sender, ) unless ConfirmMessageSender.new(self, ) end |
#confirm_outbound_processing? ⇒ Boolean
Amazon VC is a two stage process on , processing
333 334 335 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 333 def confirm_outbound_processing? true end |
#delete_listing_from_catalog_item(catalog_item: nil, amazon_variation: nil, http_method: 'DELETE', attribute_actions: nil, use_fba_sku: false) ⇒ Object
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 501 def delete_listing_from_catalog_item(catalog_item: nil, amazon_variation: nil, http_method: 'DELETE', attribute_actions: nil, use_fba_sku: false) raise 'Must provide either a catalog_item or an amazon_variation' unless catalog_item || amazon_variation raise 'Catalog Item not an amazon item or not in the right state' if catalog_item && !catalog_item.amazon_catalog_item? listing = catalog_item || amazon_variation res = [] result = .process(listing, http_method:, attribute_actions:, use_fba_sku:) if result.success? Rails.logger.debug { "orchestrator#delete_listing_from_catalog_item for #{listing}, ecl: #{result.data}" } res << .process(result.data, catalog_item_or_variation: listing, http_method:, use_fba_sku:) else Rails.logger.error "orchestrator#delete_listing_from_catalog_item for #{listing} failed: #{result.error}" res << false end res end |
#delete_listing_message_processor ⇒ Object
291 292 293 294 295 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 291 def return Edi::NullProcessor.new(self, :delete_listing_message_processor, ) unless DeleteListingMessageProcessor.new(self, ) end |
#execute_inventory_flow ⇒ Object
317 318 319 320 321 322 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 317 def execute_inventory_flow return unless active .process .process end |
#execute_order_flow ⇒ Object
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 297 def execute_order_flow return unless active .process sleep(1) .process sleep(1) packing_slip_retriever.process sleep(1) packing_slip_processor.process sleep(1) .process sleep(1) .process sleep(1) .process sleep(1) .process end |
#ignore_back_orders ⇒ Object
328 329 330 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 328 def ignore_back_orders true end |
#inventory_message_enabled? ⇒ Boolean
110 111 112 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 110 def try(:inventory_message_remote_path).present? end |
#inventory_message_processor ⇒ Object
114 115 116 117 118 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 114 def return Edi::NullProcessor.new(self, :inventory_message_processor, ) unless InventoryMessageProcessor.new(self, ) end |
#inventory_message_sender ⇒ Object
120 121 122 123 124 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 120 def return Edi::NullProcessor.new(self, :inventory_message_sender, ) unless InventoryMessageSender.new(self, ) end |
#invoice_message_enabled? ⇒ Boolean
142 143 144 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 142 def try(:invoice_message_remote_path).present? end |
#invoice_message_processor ⇒ Object
146 147 148 149 150 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 146 def return Edi::NullProcessor.new(self, :invoice_message_processor, ) unless InvoiceMessageProcessor.new(self, ) end |
#invoice_message_sender ⇒ Object
152 153 154 155 156 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 152 def return Edi::NullProcessor.new(self, :invoice_message_sender, ) unless InvoiceMessageSender.new(self, ) end |
#listing_item_information_processor ⇒ Object
263 264 265 266 267 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 263 def listing_item_information_processor return Edi::NullProcessor.new(self, :listing_item_information_processor, ) unless ListingItemInformationProcessor.new(self, ) end |
#listing_item_information_retriever ⇒ Object
257 258 259 260 261 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 257 def listing_item_information_retriever return Edi::NullProcessor.new(self, :listing_item_information_retriever, ) unless ListingItemInformationRetriever.new(self, ) end |
#listing_message_enabled? ⇒ Boolean
275 276 277 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 275 def try(:listing_message_remote_path).present? end |
#listing_message_feed_enabled? ⇒ Boolean
231 232 233 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 231 def end |
#listing_message_feed_processor ⇒ Object
241 242 243 244 245 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 241 def return Edi::NullProcessor.new(self, :listing_message_feed_processor, ) unless ListingMessageFeedProcessor.new(self, ) end |
#listing_message_feed_sender ⇒ Object
235 236 237 238 239 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 235 def return Edi::NullProcessor.new(self, :listing_message_feed_sender, ) unless ListingMessageFeedSender.new(self, ) end |
#listing_message_processor ⇒ Object
285 286 287 288 289 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 285 def return Edi::NullProcessor.new(self, :listing_message_processor, ) unless ListingMessageProcessor.new(self, ) end |
#listing_message_sender ⇒ Object
279 280 281 282 283 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 279 def return Edi::NullProcessor.new(self, :listing_message_sender, ) unless ListingMessageSender.new(self, ) end |
#merchant_id ⇒ Object
106 107 108 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 106 def merchant_id vendor_code end |
#old_catalog_item_information_enabled? ⇒ Boolean
337 338 339 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 337 def old_catalog_item_information_enabled? try(:catalog_item_information_remote_path).present? end |
#old_catalog_item_information_processor ⇒ Object
357 358 359 360 361 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 357 def old_catalog_item_information_processor return Edi::NullProcessor.new(self, :catalog_item_information_processor, ) unless catalog_item_information_enabled? CatalogItemInformationProcessor.new(self, ) end |
#old_catalog_item_information_retriever ⇒ Object
341 342 343 344 345 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 341 def old_catalog_item_information_retriever return Edi::NullProcessor.new(self, :catalog_item_information_retriever, ) unless catalog_item_information_enabled? CatalogItemInformationRetriever.new(self, ) end |
#old_listing_item_validation_errors_retriever ⇒ Object
351 352 353 354 355 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 351 def old_listing_item_validation_errors_retriever return Edi::NullProcessor.new(self, :catalog_item_information_retriever, ) unless catalog_item_information_enabled? ListingItemValidationErrorsRetriever.new(self, ) end |
#old_listing_item_validation_errors_retriever? ⇒ Boolean
347 348 349 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 347 def old_listing_item_validation_errors_retriever? try(:catalog_item_information_remote_path).present? end |
#old_pull_catalog_information(catalog_item) ⇒ Object
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 363 def old_pull_catalog_information(catalog_item) item = catalog_item.item asin = catalog_item.amazon_asin raise "No ASIN for catalog_item #{catalog_item.id}" unless asin.present? res = [] ecl_cii = nil ecl_ve = nil locales.each do |locale| # en_US en_CA fr_CA ecl_cii = catalog_item_information_retriever.process( sku: item.sku, # here we use SKU because we are using the listing item endpoint which needs SKU vs the catalog item endpoint which needs ASIN locale:, file_info: { asin: asin, item_id: item.id, locale: } ) if ecl_cii ecl_ve = listing_item_validation_errors_retriever.process( sku: item.sku, # here we use SKU because we are using the listing item endpoint which needs SKU vs the catalog item endpoint which needs ASIN product_type: catalog_item.amazon_reported_product_type || catalog_item.amazon_desired_product_type, locale:, file_info: { asin: asin, item_id: item.id, locale: } ) end if ecl_cii && ecl_ve Rails.logger.debug { "orchestrator#pull_catalog_information, ecl_cii: #{ecl_cii}" } Rails.logger.debug { "orchestrator#pull_catalog_information, ecl_ve: #{ecl_ve}" } res << { locale => catalog_item_information_processor.process(ecl_cii, catalog_item:, locale:, ecl_ve:) } else Rails.logger.error "orchestrator#pull_catalog_information for catalog item #{catalog_item.id} yielded no ecl_cii or ecl_ve (asin #{asin} not found?)" res << { locale => false } end end res end |
#order_message_enabled? ⇒ Boolean
126 127 128 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 126 def try(:order_message_remote_path).present? end |
#order_message_processor ⇒ Object
136 137 138 139 140 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 136 def return Edi::NullProcessor.new(self, :order_message_processor, ) unless OrderMessageProcessor.new(self, ) end |
#order_message_retriever ⇒ Object
130 131 132 133 134 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 130 def return Edi::NullProcessor.new(self, :order_message_processor, ) unless OrderMessageRetriever.new(self, ) end |
#packing_slip_enabled? ⇒ Boolean
158 159 160 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 158 def packing_slip_enabled? try(:packing_slip_remote_path).present? end |
#packing_slip_processor ⇒ Object
168 169 170 171 172 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 168 def packing_slip_processor return Edi::NullProcessor.new(self, :packing_slip_processor, ) unless packing_slip_enabled? PackingSlipProcessor.new(self, ) end |
#packing_slip_retriever ⇒ Object
162 163 164 165 166 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 162 def packing_slip_retriever return Edi::NullProcessor.new(self, :packing_slip_retriever, ) unless packing_slip_enabled? PackingSlipRetriever.new(self, ) end |
#populate_items_from_catalog(limit: nil, skus: nil, force: false) ⇒ Object
A method to populate our item data with amazon's catalog data
limit: how many records to process
skus: specific skus to process
force: normally we only will pull if the information is not present, use this to force a reset
536 537 538 539 540 541 542 543 544 545 546 547 548 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 536 def populate_items_from_catalog(limit: nil, skus: nil, force: false) res = [] catalog = customer_catalog catalog_items = catalog.catalog_items.amazons_with_asins.available_for_edi_feeds # Note that this should probably be specific to the locale so leverage mobility TODO catalog_items = catalog_items.where(items: { amazon_title: [nil, ''] }) unless force catalog_items = catalog_items.limit(limit) if limit catalog_items = catalog_items.where(items: { sku: skus }) if skus.present? catalog_items.each do |catalog_item| res << { name: catalog_item.to_s, catalog_item_id: catalog_item.id, res: pull_catalog_information(catalog_item) } end res end |
#pull_amazon_variation_listing_information(amazon_variation) ⇒ Object
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 460 def pull_amazon_variation_listing_information(amazon_variation) sku = amazon_variation.reported_vendor_sku(partner) # Listing info is marketplace-specific, not locale-specific. # The API call doesn't use the locale parameter, so we only need one call per marketplace. primary_locale = locales.first ecl = listing_item_information_retriever.process( sku: sku, locale: primary_locale, file_info: { sku: sku, locale: primary_locale } ) if ecl Rails.logger.debug { "orchestrator#pull_amazon_variation_listing_information, ecl: #{ecl}" } [{ primary_locale => listing_item_information_processor.process(ecl, catalog_item_or_amazon_variation: amazon_variation, locale: primary_locale) }] else Rails.logger.error "orchestrator#pull_amazon_variation_listing_information for amazon variation #{amazon_variation.id} yielded no ecl (sku #{sku} not found?)" [{ primary_locale => false }] end end |
#pull_catalog_information(catalog_item) ⇒ Object
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 406 def pull_catalog_information(catalog_item) item = catalog_item.item asin = catalog_item.amazon_asin raise "No ASIN for catalog_item #{catalog_item.id}" unless asin.present? res = [] locales.each do |locale| # en_US en_CA fr_CA ecl = catalog_item_information_retriever.process( asin: asin, locale:, file_info: { asin: asin, item_id: item.id, locale: } ) if ecl Rails.logger.debug { "orchestrator#pull_catalog_information, ecl: #{ecl}" } res << { locale => catalog_item_information_processor.process(ecl, catalog_item:, locale:) } else Rails.logger.error "orchestrator#pull_catalog_information for catalog item #{catalog_item.id} yielded no ecl (asin #{asin} not found?)" res << { locale => false } end end res end |
#pull_listing_information(catalog_item) ⇒ Object
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 434 def pull_listing_information(catalog_item) item = catalog_item.item sku = catalog_item.reported_vendor_sku # Listing info is marketplace-specific, not locale-specific. # The API call doesn't use the locale parameter, so we only need one call per marketplace. primary_locale = locales.first ecl = listing_item_information_retriever.process( sku: sku, locale: primary_locale, file_info: { sku: sku, item_id: item.id, catalog_item_id: catalog_item.id, locale: primary_locale } ) if ecl Rails.logger.debug { "orchestrator#pull_listing_information, ecl: #{ecl}" } [{ primary_locale => listing_item_information_processor.process(ecl, catalog_item_or_amazon_variation: catalog_item, locale: primary_locale) }] else Rails.logger.error "orchestrator#pull_listing_information for catalog item #{catalog_item.id} yielded no ecl (sku #{sku} not found?)" [{ primary_locale => false }] end end |
#push_listing_from_amazon_variation(amazon_variation) ⇒ Object
518 519 520 521 522 523 524 525 526 527 528 529 530 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 518 def push_listing_from_amazon_variation(amazon_variation) res = [] http_method = 'PUT' result = .process(amazon_variation, http_method:) if result.success? Rails.logger.debug { "orchestrator#push_listing_from_amazon_variation for amazon variation #{amazon_variation.id}, ecl: #{result.data}" } res << .process(result.data, catalog_item_or_variation: amazon_variation, http_method:) else Rails.logger.error "orchestrator#push_listing_from_amazon_variation for amazon variation #{amazon_variation.id} failed: #{result.error}" res << false end res end |
#push_listing_from_catalog_item(catalog_item, http_method: 'PATCH', attribute_actions: nil, use_fba_sku: false) ⇒ Object
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 483 def push_listing_from_catalog_item(catalog_item, http_method: 'PATCH', attribute_actions: nil, use_fba_sku: false) item = catalog_item.item raise 'Catalog item not an amazon item or not in the right state' unless catalog_item.amazon_catalog_item? && catalog_item.api_ready_state? res = [] result = .process(catalog_item, http_method:, attribute_actions:, use_fba_sku:) if result.success? Rails.logger.debug { "orchestrator#push_listing_from_catalog_item for catalog item #{catalog_item.id}, ecl: #{result.data}" } res << .process(result.data, catalog_item_or_variation: catalog_item, http_method:, use_fba_sku:) else Rails.logger.error "orchestrator#push_listing_from_catalog_item for catalog item #{catalog_item.id} failed: #{result.error}. " \ "ASIN: #{item.amazon_asin}, SKU: #{catalog_item.sku}, Partner: #{partner}." res << false end res end |
#return_notification_message_enabled? ⇒ Boolean
215 216 217 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 215 def try(:return_notification_message_remote_path).present? end |
#return_notification_message_processor ⇒ Object
219 220 221 222 223 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 219 def return Edi::NullProcessor.new(self, :return_notification_message_processor, ) unless ReturnNotificationMessageProcessor.new(self, ) end |
#return_notification_message_sender ⇒ Object
225 226 227 228 229 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 225 def return Edi::NullProcessor.new(self, :return_notification_message_sender, ) unless ReturnNotificationMessageSender.new(self, ) end |
#ship_code_mapper ⇒ Object
324 325 326 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 324 def ship_code_mapper ShipCodeMapper.new(self) end |
#transaction_message_enabled? ⇒ Boolean
201 202 203 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 201 def try(:transaction_message_remote_path).present? end |
#transaction_message_processor ⇒ Object
205 206 207 208 209 |
# File 'app/services/edi/amazon_vc/orchestrator.rb', line 205 def return Edi::NullProcessor.new(self, :transaction_message_processor, ) unless TransactionMessageProcessor.new(self, ) end |