Sha256: 835e582e819b419790944d767189836dce1ede6e5faaa81917e2d3daf99ead6c

Contents?: true

Size: 658 Bytes

Versions: 8

Compression:

Stored size: 658 Bytes

Contents

module Spree
  module Api
    module V2
      class ImagesController < Spree::Api::V2::BaseController
        skip_before_action :authenticate_user, only: [:index, :show]

        def index
          render_collection images.includes(:viewable)
        end

        def show
          render_instance images.find(params[:id])
        end

        private

        def images
          if params[:product_id]
            Spree::Product.find(params[:product_id]).images
          elsif params[:variant_id]
            Spree::Variant.find(params[:variant_id]).images
          else
            Spree::Image
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
solidus_json_api-0.3.1 app/controllers/spree/api/v2/images_controller.rb
solidus_json_api-0.3.0 app/controllers/spree/api/v2/images_controller.rb
spree_api_v2-0.2.2 app/controllers/spree/api/v2/images_controller.rb
solidus_api_v2-0.2.2 app/controllers/spree/api/v2/images_controller.rb
solidus_api_v2-0.2.1 app/controllers/spree/api/v2/images_controller.rb
spree_api_v2-0.2.1 app/controllers/spree/api/v2/images_controller.rb
spree_api_v2-0.2.0 app/controllers/spree/api/v2/images_controller.rb
solidus_api_v2-0.2.0 app/controllers/spree/api/v2/images_controller.rb