Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

move data feeds api to seperate controller

wjwitek14d416104297
diff --git a/api/app/controllers/spree/api/v2/data_feeds/google_controller.rb b/api/app/controllers/spree/api/v2/data_feeds/google_controller.rb
new file mode 100644
index 0000000000..0ddb072c02
--- /dev/null
+++ b/api/app/controllers/spree/api/v2/data_feeds/google_controller.rb
@@ -0,0 +1,24 @@
+module Spree
+ module Api
+ module V2
+ module DataFeeds
+ class GoogleController < ::Spree::Api::V2::BaseController
+ def rss_feed
+ send_data data_feeds_google_rss_service.value[:file], filename: 'products.rss', type: 'text/xml'
+ end
+
+ private
+
+ def settings
+ @settings ||= Spree::DataFeedSetting.find_by!(spree_store_id: current_store, uuid: params[:unique_url], enabled: true)
+ end
+
+ def data_feeds_google_rss_service
+ Spree::Dependencies.data_feeds_google_rss_service.constantize.new.call(settings)
+ end
+ end
+ end
+ end
+ end
+end
+
diff --git a/api/app/controllers/spree/api/v2/storefront/stores_controller.rb b/api/app/controllers/spree/api/v2/storefront/stores_controller.rb
index a6a0eac397..6699fee62e 100644
--- a/api/app/controllers/spree/api/v2/storefront/stores_controller.rb
+++ b/api/app/controllers/spree/api/v2/storefront/stores_controller.rb
@@ -7,20 +7,8 @@ module Spree
render_serialized_payload { serialize_resource(current_store) }
end
- def data_feeds_google_rss_feed
- send_data data_feeds_google_rss_service.value[:file], filename: 'products.rss', type: 'text/xml'
- end
-
private
- def settings
- @settings ||= Spree::DataFeedSetting.find_by!(spree_store_id: current_store, uuid: params[:unique_url], enabled: true)
- end
-
- def data_feeds_google_rss_service
- Spree::Dependencies.data_feeds_google_rss_service.constantize.new.call(settings)
- end
-
def model_class
Spree::Store
end
diff --git a/api/config/routes.rb b/api/config/routes.rb
index df9a9a0800..dc8e070ec2 100644
--- a/api/config/routes.rb
+++ b/api/config/routes.rb
@@ -63,9 +63,6 @@ Spree::Core::Engine.add_routes do
end
get '/digitals/:token', to: 'digitals#download', as: 'digital'
-
- # export API
- get '/data_feeds/google/:unique_url', to: 'stores#data_feeds_google_rss_feed'
end
namespace :platform do
@@ -213,6 +210,11 @@ Spree::Core::Engine.add_routes do
resources :subscribers
end
end
+
+ namespace :data_feeds do
+ # google data feed API
+ get '/google/:unique_url', to: 'google#rss_feed'
+ end
end
end
end