Class: TestApi::APIController
- Inherits:
-
BaseController
- Object
- BaseController
- TestApi::APIController
- Defined in:
- lib/test_api/controllers/api_controller.rb
Overview
APIController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#createanewuser(body) ⇒ UsersResponse1
Creates a user with default values if not provided.
-
#getusers(search: nil, limit: nil) ⇒ Array[UsersResponse]
Returns a list of users, optionally filtered by search.
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 TestApi::BaseController
Instance Method Details
#createanewuser(body) ⇒ UsersResponse1
Creates a user with default values if not provided. here
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/test_api/controllers/api_controller.rb', line 34 def createanewuser(body) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/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)) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(UsersResponse1.method(:from_hash))) .execute end |
#getusers(search: nil, limit: nil) ⇒ Array[UsersResponse]
Returns a list of users, optionally filtered by search. returned
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/test_api/controllers/api_controller.rb', line 14 def getusers(search: nil, limit: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/users', Server::DEFAULT) .query_param(new_parameter(search, key: 'search')) .query_param(new_parameter(limit, key: 'limit')) .header_param(new_parameter('application/json', key: 'accept'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(UsersResponse.method(:from_hash)) .is_response_array(true)) .execute end |