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

Constructor Details

This class inherits a constructor from ModernTreasury::BaseController

Instance Method Details

#ping_apiPingResponse

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

Returns:



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 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))
                .local_error('401',
                             'unsuccessful',
                             ErrorMessageException)
                .local_error('429',
                             'unsuccessful',
                             APIException)
                .local_error('500',
                             'internal server error',
                             APIException))
    .execute
end