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