From e47a57fa3c88ffa022a756e5c92e8667f39fac96 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 12 Dec 2024 15:48:42 +1100 Subject: [PATCH] DRY with offer broker we'll need anyway --- .../admin/dfc_product_imports_controller.rb | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/app/controllers/admin/dfc_product_imports_controller.rb b/app/controllers/admin/dfc_product_imports_controller.rb index c166179ba3..fbb854595d 100644 --- a/app/controllers/admin/dfc_product_imports_controller.rb +++ b/app/controllers/admin/dfc_product_imports_controller.rb @@ -19,13 +19,11 @@ module Admin .find(params.require(:enterprise_id)) catalog_url = params.require(:catalog_url) - - json_catalog = fetch_catalog(catalog_url) - graph = DfcIo.import(json_catalog) + broker = FdcOfferBroker.new(spree_current_user, catalog_url) # * First step: import all products for given enterprise. # * Second step: render table and let user decide which ones to import. - imported = graph.map do |subject| + imported = broker.catalog.map do |subject| next unless subject.is_a? DataFoodConsortium::Connector::SuppliedProduct existing_variant = enterprise.supplied_variants.linked_to(subject.semanticId) @@ -44,11 +42,5 @@ module Admin flash[:error] = e.message redirect_to admin_product_import_path end - - private - - def fetch_catalog(url) - DfcRequest.new(spree_current_user).call(url) - end end end