Class: Api::V1::Reviews::ProductsController
- Inherits:
-
ActionController::API
- Object
- ActionController::API
- Api::V1::Reviews::ProductsController
- Defined in:
- app/controllers/api/v1/reviews/products_controller.rb
Overview
Product feed for ReviewsIo product setup: SKU, product name, image URL,
and page URL. https://dash.reviews.io/products/setup
Instance Method Summary collapse
-
#groupings ⇒ void
GET /v1/reviews/products/groupings — CSV of SKU-to-group-name mappings for ReviewsIo product grouping.
-
#index ⇒ void
GET /v1/reviews/products — redirects to the latest pre-generated product feed on S3, generating one on demand (and queuing a background regeneration) if none exists yet.
Instance Method Details
#groupings ⇒ void
This method returns an undefined value.
GET /v1/reviews/products/groupings — CSV of SKU-to-group-name
mappings for ReviewsIo product grouping.
36 37 38 39 40 41 42 43 |
# File 'app/controllers/api/v1/reviews/products_controller.rb', line 36 def groupings data = Api::ReviewsIo::ProductGroupingGenerator.new.process csv_string = CSV.generate do |csv| csv << ["SKU", "Group Name"] data.each { |row| csv << row } end render plain: csv_string end |
#index ⇒ void
This method returns an undefined value.
GET /v1/reviews/products — redirects to the latest pre-generated
product feed on S3, generating one on demand (and queuing a
background regeneration) if none exists yet.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/api/v1/reviews/products_controller.rb', line 14 def index # Find the most recent pre-generated feed from S3 upload = ReviewsIoFeedGeneratorWorker.latest_upload if upload.present? # Redirect to presigned S3 URL (valid for 1 hour) redirect_to upload.presigned_url(expires_in: 1.hour), allow_other_host: true else # No pre-generated feed exists - generate on demand and queue background job # This should only happen on first request or after all uploads were deleted ReviewsIoFeedGeneratorWorker.perform_async response_xml = Feed::ReviewsIo::ProductCatalogGenerator.new.process[:xml] self.content_type = 'text/xml' render xml: response_xml end end |