Module: Scimaenaga::Response

Included in:
ApplicationController
Defined in:
app/controllers/concerns/scimaenaga/response.rb

Constant Summary collapse

CONTENT_TYPE =
'application/scim+json'

Instance Method Summary collapse

Instance Method Details

#json_response(object, status = :ok) ⇒ Object



7
8
9
10
11
12
# File 'app/controllers/concerns/scimaenaga/response.rb', line 7

def json_response(object, status = :ok)
  render \
    json: object,
    status: status,
    content_type: CONTENT_TYPE
end

#json_scim_response(object:, status: :ok, counts: nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/concerns/scimaenaga/response.rb', line 14

def json_scim_response(object:, status: :ok, counts: nil)
  case params[:action]
  when 'index'
    render \
      json: list_response(object, counts),
      status: status,
      content_type: CONTENT_TYPE
  when 'show', 'create', 'put_update', 'patch_update'
    render \
      json: object_response(object),
      status: status,
      content_type: CONTENT_TYPE
  end
end