Class: ModernTreasury::PingApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/modern_treasury/apis/ping_api.rb

Overview

PingApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from ModernTreasury::BaseApi

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/apis/ping_api.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