BankDetails-India

 view release on metacpan or  search on metacpan

lib/BankDetails/India.pm  view on Meta::CPAN

    my $response_data = decode_json($response->decoded_content);
    $self->_convert_json_boolean($response_data);
    my $xml = XMLout($response_data, RootName => 'data', NoAttr => 1);
    $file_name ||= "bankdetails_$ifsc_code.xml";
    open(my $fh, '>', $file_name) or die $!;
    print $fh $xml;
    close($fh);
}

sub get_response {
    my ($self, $endpoint, $ifsc) = @_;
    return if ( !$self->ping_api || !defined $endpoint || length $endpoint <= 0);

    $ifsc = uc($ifsc);
    my $request_url = $endpoint.$ifsc;
    my $cache_key = md5_hex(encode_sereal($ifsc));
    my $response_data;
    my $cache_response_data = $self->cache_data->get($cache_key);
    if (defined $cache_response_data) {
        $response_data = decode_sereal($cache_response_data);
    } else {
        my $response = $self->user_agent->get($request_url);
        my $response_content;

        if ($response->is_success) {

lib/BankDetails/India.pm  view on Meta::CPAN


Construct a new BankDetails::India instance. Optionally takes a hash or hash reference.

    # Instantiate the class.
    my $api = BankDetails::India->new();

=head3 api_url

The URL of the API resource is read only attribute.

    # get the API endpoint.
    $api->api_url;

=head3 cache_data

The cache engine used to cache the web service API calls. By default, it uses
file-based caching.

    # Instantiate the class by setting the cache engine.
    my $api = BankDetails::India->new(
        CHI->new(

lib/BankDetails/India.pm  view on Meta::CPAN

        driver => 'File',
        namespace => 'bankdetails',
        root_dir => '/tmp/cache/'
    ));

    # get cache engine.
    $api->cache_data

=head2 ping_api()

Checks whether the API endpoint is currently up.

    # Returns 1 if up or 0 if not.
    $api->ping_api();

=head2 get_all_data_by_ifsc

Fetches all the available bank details for the given IFSC code.

    my $data = $bank_details->get_all_data_by_ifsc($ifsc_code);



( run in 1.163 second using v1.01-cache-2.11-cpan-49f99fa48dc )