Class: SlackWebApi::ApiController

Inherits:
BaseController show all
Defined in:
lib/slack_web_api/controllers/api_controller.rb

Overview

ApiController

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_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from SlackWebApi::BaseController

Instance Method Details

#api_test(error: nil, foo: nil) ⇒ ApiResponse

Checks API calling code.

Parameters:

  • error (String) (defaults to: nil)

    Optional parameter: Error response to return

  • foo (String) (defaults to: nil)

    Optional parameter: example property to return

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/slack_web_api/controllers/api_controller.rb', line 13

def api_test(error: nil,
             foo: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api.test',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'Content-Type'))
               .query_param(new_parameter(error, key: 'error'))
               .query_param(new_parameter(foo, key: 'foo'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ApiTestSuccessSchema.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Artificial error response',
                             ApiTestErrorSchemaException))
    .execute
end