Class: ScimEngine::ResourcesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/scim_engine/resources_controller.rb

Instance Method Summary collapse

Instance Method Details

#create(resource_type, &block) ⇒ Object


13
14
15
16
17
18
19
20
21
# File 'app/controllers/scim_engine/resources_controller.rb', line 13

def create(resource_type, &block)
  if resource_params[:id].present?
    handle_scim_error(ErrorResponse.new(status: 400, detail: 'id is not a valid parameter for create'))
    return
  end
  with_scim_resource(resource_type) do |resource|
    render json: yield(resource, is_create: true), status: :created
  end
end

#destroyObject


29
30
31
32
33
34
35
# File 'app/controllers/scim_engine/resources_controller.rb', line 29

def destroy
  if yield(resource_params[:id]) != false
    head :no_content
  else
    handle_scim_error(ErrorResponse.new(status: 500, detail: "Failed to delete the resource with id '#{params[:id]}'. Please try again later"))
  end
end

#show(&block) ⇒ Object


6
7
8
9
10
11
# File 'app/controllers/scim_engine/resources_controller.rb', line 6

def show(&block)
  scim_user = yield resource_params[:id]
  render json: scim_user
rescue ErrorResponse => error
  handle_scim_error(error)
end

#update(resource_type, &block) ⇒ Object


23
24
25
26
27
# File 'app/controllers/scim_engine/resources_controller.rb', line 23

def update(resource_type, &block)
  with_scim_resource(resource_type) do |resource|
    render json: yield(resource)
  end
end