Sha256: ff2e3be0897773f2101fe0554478f4dc6cb2abd8ff22d5e1e947a91a76ca3c53

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

module Spree
  module Api
    module V2
      module Platform
        class ClassificationsController < ResourceController
          before_action -> { doorkeeper_authorize! :write, :admin }, only: WRITE_ACTIONS << :reposition

          def reposition
            spree_authorize! :update, resource if spree_current_user.present?

            result = classification_reposition_service.call(
              classification: resource,
              position: permitted_resource_params[:position]
            )

            if result.success?
              render_serialized_payload { serialize_resource(result.value) }
            else
              render_error_payload(result.error)
            end
          end

          private

          def model_class
            Spree::Classification
          end

          def scope_includes
            [
              taxon: [],
              product: [:variants_including_master, :variant_images, :master, variants: [:prices]]
            ]
          end

          def classification_reposition_service
            Spree::Dependencies.classification_reposition_service.constantize
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
spree_api-4.3.3 app/controllers/spree/api/v2/platform/classifications_controller.rb
spree_api-4.3.2 app/controllers/spree/api/v2/platform/classifications_controller.rb
spree_api-4.3.1 app/controllers/spree/api/v2/platform/classifications_controller.rb
spree_api-4.3.0 app/controllers/spree/api/v2/platform/classifications_controller.rb
spree_api-4.3.0.rc3 app/controllers/spree/api/v2/platform/classifications_controller.rb
spree_api-4.3.0.rc2 app/controllers/spree/api/v2/platform/classifications_controller.rb
spree_api-4.3.0.rc1 app/controllers/spree/api/v2/platform/classifications_controller.rb