Class: ModernTreasury::ValidationController

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

Overview

ValidationController

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

#validate_routing_number(routing_number, routing_number_type) ⇒ RoutingNumberLookupRequest

Validates the routing number information supplied without creating a routing detail is being validated. One of ‘aba`, `au_bsb`, `br_codigo`, `ca_cpa`, `cnaps`, `gb_sort_code`, `in_ifsc`, `my_branch_code`, or `swift`. In sandbox mode we currently only support `aba` and `swift` with routing numbers ’123456789’ and ‘GRINUST0XXX’ respectively.

Parameters:

  • routing_number (String)

    Required parameter: The routing number that

  • routing_number_type (RoutingNumberType8Enum)

    Required parameter:

Returns:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/modern_treasury/controllers/validation_controller.rb', line 19

def validate_routing_number(routing_number,
                            routing_number_type)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/validations/routing_numbers',
                                 Server::DEFAULT)
               .query_param(new_parameter(routing_number, key: 'routing_number'))
               .query_param(new_parameter(routing_number_type, key: 'routing_number_type'))
               .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(RoutingNumberLookupRequest.method(:from_hash))
                .local_error('404',
                             'not found',
                             ErrorMessageException)
                .local_error('422',
                             'unsuccessful with invalid parameter',
                             ErrorMessageException))
    .execute
end