Class: CtdDocumentation::UsersController

Inherits:
BaseController show all
Defined in:
lib/ctd_documentation/controllers/users_controller.rb

Overview

UsersController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent

Constructor Details

This class inherits a constructor from CtdDocumentation::BaseController

Instance Method Details

#create_user(body) ⇒ CreateUserResponse

This can only be done by the logged in user.

Parameters:

  • body (User)

    Required parameter: Created user object

Returns:



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ctd_documentation/controllers/users_controller.rb', line 12

def create_user(body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/auth/users',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(CreateUserResponse.method(:from_hash)))
    .execute
end