Sha256: 48949f3f04527928167f80ad99b43c436eadf2a7abf8a59e7b6a97bb555dcd4a

Contents?: true

Size: 771 Bytes

Versions: 8

Compression:

Stored size: 771 Bytes

Contents

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

        def index
          render_collection option_types.includes(:option_values, :products)
        end

        def show
          if params[:option_value_id]
            render_instance Spree::OptionValue.find(params[:option_value_id]).option_type
          else
            render_instance option_types.find(params[:id])
          end
        end

        private

        def option_types
          if params[:product_id]
            Spree::Product.find(params[:product_id]).option_types
          else
            Spree::OptionType
          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/option_types_controller.rb
solidus_json_api-0.3.0 app/controllers/spree/api/v2/option_types_controller.rb
spree_api_v2-0.2.2 app/controllers/spree/api/v2/option_types_controller.rb
solidus_api_v2-0.2.2 app/controllers/spree/api/v2/option_types_controller.rb
solidus_api_v2-0.2.1 app/controllers/spree/api/v2/option_types_controller.rb
spree_api_v2-0.2.1 app/controllers/spree/api/v2/option_types_controller.rb
spree_api_v2-0.2.0 app/controllers/spree/api/v2/option_types_controller.rb
solidus_api_v2-0.2.0 app/controllers/spree/api/v2/option_types_controller.rb