Class: ModernTreasury::PingController

Inherits:
BaseController show all
Defined in:
lib/modern_treasury/controllers/ping_controller.rb

Overview

PingController

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 ModernTreasury::BaseController

Instance Method Details

#ping_apiApiResponse

A test endpoint often used to confirm credentials and headers are being passed in correctly.

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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

def ping_api
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/ping',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(PingResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('401',
                             'unsuccessful',
                             ErrorMessageException)
                .local_error('429',
                             'unsuccessful',
                             APIException)
                .local_error('500',
                             'internal server error',
                             APIException))
    .execute
end