Sha256: 6aff49e9b5251cfd675e0cc15ef8b9bec786866ccb7f40781c129eb0cae65460

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

module Scrivito

  class WorkspacesController < WebserviceController
    def index
      render json: CmsRestApi.task_unaware_request(:get, 'workspaces')
    end

    def create
      render json: CmsRestApi.task_unaware_request(:post, 'workspaces', {
        workspace: workspace_params,
      })
    end

    def update
      render json: CmsRestApi.task_unaware_request(:put, "workspaces/#{params[:id]}", {
        workspace: workspace_params,
      })
    end

    def destroy
      render json: CmsRestApi.task_unaware_request(:delete, "workspaces/#{params[:id]}")
    end

    def publish
      if able_to?(:publish_workspace)
        render json: CmsRestApi.task_unaware_request(:put, "workspaces/#{params[:id]}/publish", {})
      else
        render text: 'Forbidden', status: 403
      end
    end

    def rebase
      render json: CmsRestApi.task_unaware_request(:put, "workspaces/#{params[:id]}/rebase", {})
    end

    private

    def workspace_params
      raise "Required parameter 'workspace' is missing." unless params[:workspace].present?
      raise "Parameter 'workspace' is not a hash." unless params[:workspace].is_a?(Hash)
      params[:workspace]
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scrivito_sdk-0.17.0 app/controllers/scrivito/workspaces_controller.rb