Sha256: 2d0305ddc2280a57737aea8937baae0c261f3a3350ee670cfa137607f421e11e

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

require 'fdic/bank_find/exceptions'
require 'fdic/bank_find/client'
require 'fdic/bank_find/record'
require 'fdic/bank_find/bank'
require 'fdic/bank_find/institution'
require 'fdic/bank_find/branch'
require 'fdic/bank_find/history_event'

module FDIC
  module BankFind

    def find_bank(bank_name)
      resp = Client.new.find_bank(bank_name)
      resp['d']['results'].map { |result|
        Bank.new(result)
      }
    end

    def find_institution(certificate_number)
      resp = Client.new.find_institution(certificate_number)
      results = resp.fetch('d').fetch('results')
      if results.empty? || results.nil?
        raise FDIC::Exceptions::RecordNotFound, "#{certificate_number} appears to be an invalid certificate number"
      else
        Institution.new(results.first)
      end
    end

    def find_branches(certificate_number)
      resp = Client.new.find_branches(certificate_number)
      resp['d']['results'].map { |result|
        Branch.new(result)
      }
    end

    def find_history_events(bank_name, certificate_number)
      resp = Client.new.find_history_events(bank_name, certificate_number)
      resp['d']['results'].map { |result|
        HistoryEvent.new(result)
      }
    end

    extend self
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fdic-0.8.2 lib/fdic/bank_find.rb
fdic-0.8.1 lib/fdic/bank_find.rb
fdic-0.7.0 lib/fdic/bank_find.rb
fdic-0.6.0 lib/fdic/bank_find.rb
fdic-0.5.0 lib/fdic/bank_find.rb