fdic 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a960c1ecf07c6e286b5b543633c34e18379d1841
4
- data.tar.gz: 10ec5ce24ce877441df8be9e9f19c31bfc6e32d9
3
+ metadata.gz: bcf10e68f158d536e5fa76857a547c5a186a8198
4
+ data.tar.gz: 5edb0f2ac6558e1a9352bdf6ca79a1da6b4d1c15
5
5
  SHA512:
6
- metadata.gz: cd5aa39e4d85247ff17ff60dbe124aa6395e60907fe0739d126416d769cd32c67d8d26d87d2ff0717ee15684cab6f88d63416fddbfdbd1d55ebb0baa69022406
7
- data.tar.gz: 64eddddf554c07038d6cefb7f62e70a1f9dbf470c2d9c10f5085ced999e10fed4c5f5de49d147f854cc95685c57d3037b24d91e505fdd6247a60c06d2998cba8
6
+ metadata.gz: 8bbd0f3c0587947f9708955b89096a6feb499c2a5bdd658f1587315ffa0890240c75d212a5621191c6077891c9e711e3cc0f5c8dd30dc19338b5672d8c3af34b
7
+ data.tar.gz: 6a0c8d31cc6ccd604e0497cd9dff38752007ff050140e1c0f8e97a8e4a46f3f4711004941367059ff510150443c7f36d2ab2fb4fa1cbf5c8361d8b2f1b0f6ea5
data/README.md CHANGED
@@ -40,14 +40,16 @@ Or install it yourself as:
40
40
 
41
41
  The FDIC API lets you find an Institution if you have its FDIC Certificate Number:
42
42
 
43
+ Currently all of our features are namespaced under the `FDIC::BankFind` module
44
+
43
45
  ```
44
- institution = FDIC.find_institution(26588) #=> FDIC::Institution
46
+ institution = FDIC::BankFind.find_institution(26588) #=> FDIC::BankFind::Institution
45
47
  ```
46
48
 
47
49
  If you don't have the certificate number, you can search for a Bank by name, and get back all matching Banks:
48
50
 
49
51
  ```
50
- banks = FDIC.find_bank('Dedicated Community Bank') #=> [FDIC::Bank, FDIC::Bank, ...]
52
+ banks = FDIC::BankFind.find_bank('Dedicated Community Bank') #=> [FDIC::BankFind::Bank, FDIC::BankFind::Bank, ...]
51
53
  ```
52
54
 
53
55
  Once you have a Bank, you can get its Institution, which has much more data available:
@@ -56,14 +58,14 @@ Once you have a Bank, you can get its Institution, which has much more data avai
56
58
  institution = banks.first.find_institution! # Bang, because it's another network request
57
59
  ```
58
60
 
59
- The API also exposes information about an Institution's branches, and its history. You can query both of these on the FDIC module directly, or on the Institution:
61
+ The API also exposes information about an Institution's branches, and its history. You can query both of these on the FDIC::BankFind module directly, or on the Institution:
60
62
 
61
63
  ```
62
- institution.find_branches! #=> [FDIC::Branch, FDIC::Branch, ...]
63
- FDIC.find_branches(25688) #=> [FDIC::Branch, FDIC::Branch, ...]
64
+ institution.find_branches! #=> [FDIC::BankFind::Branch, FDIC::BankFind::Branch, ...]
65
+ FDIC::BankFind.find_branches(25688) #=> [FDIC::BankFind::Branch, FDIC::BankFind::Branch, ...]
64
66
 
65
- institution.find_history_events! #=> [FDIC::HistoryEvent, ...]
66
- FDIC.find_history_events('Dedicated Community Bank', 26588) #=> [FDIC::HistoryEvent, ...]
67
+ institution.find_history_events! #=> [FDIC::BankFind::HistoryEvent, ...]
68
+ FDIC::BankFind.find_history_events('Dedicated Community Bank', 26588) #=> [FDIC::BankFind::HistoryEvent, ...]
67
69
  ```
68
70
 
69
71
  Since a `Bank` knows its certificate number, it can look up its branch and history information, too.
data/lib/fdic/bank.rb CHANGED
@@ -1,26 +1,28 @@
1
1
  module FDIC
2
- class Bank < Record
3
- field :fdic_id, 'id'
4
- field(:legal_name, 'legalName', &:strip)
5
- field :certificate_number, :certNumber
6
- field(:active?, 'activeFlag') { |value| value == 'Y' }
7
- field :address
8
- field :city
9
- field :state
10
- field :zip
11
- field :office_count, :officeCount
12
- date_field :effective_date, :effectiveDate
2
+ module BankFind
3
+ class Bank < Record
4
+ field :fdic_id, 'id'
5
+ field(:legal_name, 'legalName', &:strip)
6
+ field :certificate_number, :certNumber
7
+ field(:active?, 'activeFlag') { |value| value == 'Y' }
8
+ field :address
9
+ field :city
10
+ field :state
11
+ field :zip
12
+ field :office_count, :officeCount
13
+ date_field :effective_date, :effectiveDate
13
14
 
14
- def find_institution!
15
- @institution ||= FDIC.find_institution(certificate_number)
16
- end
15
+ def find_institution!
16
+ @institution ||= BankFind.find_institution(certificate_number)
17
+ end
17
18
 
18
- def find_history_events!
19
- @history_events ||= FDIC.find_history_events(legal_name, certificate_number)
20
- end
19
+ def find_history_events!
20
+ @history_events ||= BankFind.find_history_events(legal_name, certificate_number)
21
+ end
21
22
 
22
- def find_branches!
23
- @branches ||= FDIC.find_branches(certificate_number)
23
+ def find_branches!
24
+ @branches ||= BankFind.find_branches(certificate_number)
25
+ end
24
26
  end
25
27
  end
26
28
  end
data/lib/fdic/branch.rb CHANGED
@@ -21,19 +21,21 @@
21
21
  =end
22
22
 
23
23
  module FDIC
24
- class Branch < Record
25
- field :fdic_id, 'id'
26
- field(:branch_name, 'branchName', &:strip)
27
- field :certificate_number, :certNumber
24
+ module BankFind
25
+ class Branch < Record
26
+ field :fdic_id, 'id'
27
+ field(:branch_name, 'branchName', &:strip)
28
+ field :certificate_number, :certNumber
28
29
 
29
- field :address
30
- field :city
31
- field :county
32
- field :state
33
- field :zip
30
+ field :address
31
+ field :city
32
+ field :county
33
+ field :state
34
+ field :zip
34
35
 
35
- field :branch_number, :branchNum
36
- date_field :established_date, :establishedDate
37
- date_field :acquired_date, :acquiredDate
36
+ field :branch_number, :branchNum
37
+ date_field :established_date, :establishedDate
38
+ date_field :acquired_date, :acquiredDate
39
+ end
38
40
  end
39
41
  end
data/lib/fdic/client.rb CHANGED
@@ -1,52 +1,54 @@
1
1
  module FDIC
2
- class Client
3
- include HTTParty
4
- base_uri 'https://odata.fdic.gov/v1/financial-institution/'
5
- format :json
2
+ module BankFind
3
+ class Client
4
+ include HTTParty
5
+ base_uri 'https://odata.fdic.gov/v1/financial-institution/'
6
+ format :json
6
7
 
7
- #logger ::Logger.new 'httparty.log', :debug, :curl
8
- #debug_output
8
+ #logger ::Logger.new 'httparty.log', :debug, :curl
9
+ #debug_output
9
10
 
10
- def find_bank(bank_name)
11
- self.class.get('/Bank',
12
- query:
13
- { '$inlinecount' => 'all',
14
- '$format' => 'json',
15
- '$filter' => "(substringof('#{escape_single_quotes(bank_name.upcase)}',name))"})
16
- end
11
+ def find_bank(bank_name)
12
+ self.class.get('/Bank',
13
+ query:
14
+ { '$inlinecount' => 'all',
15
+ '$format' => 'json',
16
+ '$filter' => "(substringof('#{escape_single_quotes(bank_name.upcase)}',name))"})
17
+ end
17
18
 
18
- def find_institution(certificate_number)
19
- self.class.get('/Institution',
20
- query:
21
- { '$inlinecount' => 'all',
22
- '$format' => 'json',
23
- '$filter' => "certNumber eq #{certificate_number}"})
24
- end
19
+ def find_institution(certificate_number)
20
+ self.class.get('/Institution',
21
+ query:
22
+ { '$inlinecount' => 'all',
23
+ '$format' => 'json',
24
+ '$filter' => "certNumber eq #{certificate_number}"})
25
+ end
25
26
 
26
- def find_branches(certificate_number)
27
- self.class.get('/Branch',
28
- query:
29
- { '$inlinecount' => 'allpages',
30
- '$format' => 'json',
31
- '$filter' => "certNumber eq #{certificate_number}"})
32
- end
27
+ def find_branches(certificate_number)
28
+ self.class.get('/Branch',
29
+ query:
30
+ { '$inlinecount' => 'allpages',
31
+ '$format' => 'json',
32
+ '$filter' => "certNumber eq #{certificate_number}"})
33
+ end
33
34
 
34
- def find_history_events(bank_name, certificate_number)
35
- filter = "legalName eq '#{escape_single_quotes(bank_name.upcase)}' and certNumber eq #{certificate_number}"
36
- self.class.get('/History',
37
- query:
38
- { '$inlinecount' => 'all',
39
- '$format' => 'json',
40
- '$filter' => filter})
41
- end
35
+ def find_history_events(bank_name, certificate_number)
36
+ filter = "legalName eq '#{escape_single_quotes(bank_name.upcase)}' and certNumber eq #{certificate_number}"
37
+ self.class.get('/History',
38
+ query:
39
+ { '$inlinecount' => 'all',
40
+ '$format' => 'json',
41
+ '$filter' => filter})
42
+ end
42
43
 
43
- private
44
+ private
44
45
 
45
- def escape_single_quotes(string)
46
- # Urm? The API 500's if you have a single-quote in name: "People's United Bank."
47
- # Their web forms double-up the single-quotes to escape them.
48
- # NB: let's keep an eye on this flim-flam, and be sure it doesn't get out of hand.
49
- string.gsub("'", "''")
46
+ def escape_single_quotes(string)
47
+ # Urm? The API 500's if you have a single-quote in name: "People's United Bank."
48
+ # Their web forms double-up the single-quotes to escape them.
49
+ # NB: let's keep an eye on this flim-flam, and be sure it doesn't get out of hand.
50
+ string.gsub("'", "''")
51
+ end
50
52
  end
51
53
  end
52
54
  end
@@ -1,22 +1,24 @@
1
1
  module FDIC
2
- class HistoryEvent < Record
2
+ module BankFind
3
+ class HistoryEvent < Record
3
4
 
4
- field :fdic_id, :id
5
- field(:legal_name, :legalName, &:strip)
6
- field :certificate_number, :certNumber
5
+ field :fdic_id, :id
6
+ field(:legal_name, :legalName, &:strip)
7
+ field :certificate_number, :certNumber
7
8
 
8
- date_field :effective_date, :orgEffDate
9
- field :event_description, :eventDescription
10
- field :change_code, :changeCode
11
- field :change_description, :changeDesc
9
+ date_field :effective_date, :orgEffDate
10
+ field :event_description, :eventDescription
11
+ field :change_code, :changeCode
12
+ field :change_description, :changeDesc
12
13
 
13
- field :trust_power, :trustPower
14
- field :trust_power_check, :trustPowerCheck
14
+ field :trust_power, :trustPower
15
+ field :trust_power_check, :trustPowerCheck
15
16
 
16
- field :city
17
- field :state
17
+ field :city
18
+ field :state
18
19
 
19
- field :primary_regulatory_agency_check, :primaryRegulatoryAgencyCheck
20
- field :primary_regulatory_agency, :primaryRegulatoryAgency
20
+ field :primary_regulatory_agency_check, :primaryRegulatoryAgencyCheck
21
+ field :primary_regulatory_agency, :primaryRegulatoryAgency
22
+ end
21
23
  end
22
24
  end
@@ -1,41 +1,43 @@
1
1
  module FDIC
2
- class Institution < Record
3
- field :fdic_id, :id
4
- field(:legal_name, :legalName, &:strip)
5
- field :certificate_number, :certNumber
2
+ module BankFind
3
+ class Institution < Record
4
+ field :fdic_id, :id
5
+ field(:legal_name, :legalName, &:strip)
6
+ field :certificate_number, :certNumber
6
7
 
7
- field :supervising_authority, :FACodeText
8
- field :supervising_authority_code, :FACode
8
+ field :supervising_authority, :FACodeText
9
+ field :supervising_authority_code, :FACode
9
10
 
10
- field(:active?, 'activeFlag') { |value| value == 'Y' }
11
- date_field :inactive_as_of_date, "inActiveAsofDt"
12
- field :address
13
- field :city
14
- field :county
15
- field :state
16
- field :zip
17
- field :web_site, "webSite"
11
+ field(:active?, 'activeFlag') { |value| value == 'Y' }
12
+ date_field :inactive_as_of_date, "inActiveAsofDt"
13
+ field :address
14
+ field :city
15
+ field :county
16
+ field :state
17
+ field :zip
18
+ field :web_site, "webSite"
18
19
 
19
- date_field :insured_date, 'insuredDate'
20
- date_field :insured_from_date, "insuredFrmDt"
21
- date_field :insured_to_date, "insuredToDt"
22
- date_field :established_date, 'establishedDate'
23
- date_field :as_of_date, 'asOfDate'
20
+ date_field :insured_date, 'insuredDate'
21
+ date_field :insured_from_date, "insuredFrmDt"
22
+ date_field :insured_to_date, "insuredToDt"
23
+ date_field :established_date, 'establishedDate'
24
+ date_field :as_of_date, 'asOfDate'
24
25
 
25
- date_field :report_date, "reportDate" # This is NOT the date the query was made.
26
+ date_field :report_date, "reportDate" # This is NOT the date the query was made.
26
27
 
27
- int_field :office_count, "officeCount"
28
- currency_field :total_assets, 'totalAssets'
29
- currency_field :total_deposits, "totalDeposits"
30
- currency_field :domestic_deposits, "domesticDeposits"
31
- currency_field :bank_equity_capital, "bankEquityCapital"
28
+ int_field :office_count, "officeCount"
29
+ currency_field :total_assets, 'totalAssets'
30
+ currency_field :total_deposits, "totalDeposits"
31
+ currency_field :domestic_deposits, "domesticDeposits"
32
+ currency_field :bank_equity_capital, "bankEquityCapital"
32
33
 
33
- def find_history_events!
34
- @history_events ||= FDIC.find_history_events(legal_name, certificate_number)
35
- end
34
+ def find_history_events!
35
+ @history_events ||= BankFind.find_history_events(legal_name, certificate_number)
36
+ end
36
37
 
37
- def find_branches!
38
- @branches ||= FDIC.find_branches(certificate_number)
38
+ def find_branches!
39
+ @branches ||= BankFind.find_branches(certificate_number)
40
+ end
39
41
  end
40
42
  end
41
43
  end
data/lib/fdic/record.rb CHANGED
@@ -1,38 +1,40 @@
1
1
  module FDIC
2
- class Record
3
- def initialize(attributes)
4
- @attributes = attributes
5
- @attributes.freeze
6
- end
2
+ module BankFind
3
+ class Record
4
+ def initialize(attributes)
5
+ @attributes = attributes
6
+ @attributes.freeze
7
+ end
7
8
 
8
- attr_reader :attributes
9
+ attr_reader :attributes
9
10
 
10
- def self.field(method_name, response_key=method_name, &munger)
11
- munger ||= lambda { |x| x }
12
- define_method(method_name) {
13
- value = attributes[response_key.to_s]
14
- value && munger.call(value)
15
- }
16
- end
11
+ def self.field(method_name, response_key=method_name, &munger)
12
+ munger ||= lambda { |x| x }
13
+ define_method(method_name) {
14
+ value = attributes[response_key.to_s]
15
+ value && munger.call(value)
16
+ }
17
+ end
17
18
 
18
- def self.int_field(method_name, response_key=method_name)
19
- field(method_name, response_key, &:to_i)
20
- end
19
+ def self.int_field(method_name, response_key=method_name)
20
+ field(method_name, response_key, &:to_i)
21
+ end
21
22
 
22
- def self.currency_field(method_name, response_key=method_name)
23
- field(method_name, response_key) { |value|
24
- value.to_f * 1000
25
- }
26
- end
23
+ def self.currency_field(method_name, response_key=method_name)
24
+ field(method_name, response_key) { |value|
25
+ value.to_f * 1000
26
+ }
27
+ end
27
28
 
28
- def self.date_field(method_name, response_key=method_name)
29
- field(method_name, response_key) { |value|
30
- Date.parse(value)
31
- }
32
- end
29
+ def self.date_field(method_name, response_key=method_name)
30
+ field(method_name, response_key) { |value|
31
+ Date.parse(value)
32
+ }
33
+ end
33
34
 
34
- def uri
35
- attributes['__metadata']['uri']
35
+ def uri
36
+ attributes['__metadata']['uri']
37
+ end
36
38
  end
37
39
  end
38
40
  end
data/lib/fdic/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module FDIC
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/fdic.rb CHANGED
@@ -9,33 +9,35 @@ require 'fdic/branch'
9
9
  require 'fdic/history_event'
10
10
 
11
11
  module FDIC
12
+ module BankFind
12
13
 
13
- def find_bank(bank_name)
14
- resp = Client.new.find_bank(bank_name)
15
- resp['d']['results'].map { |result|
16
- FDIC::Bank.new(result)
17
- }
18
- end
14
+ def find_bank(bank_name)
15
+ resp = Client.new.find_bank(bank_name)
16
+ resp['d']['results'].map { |result|
17
+ Bank.new(result)
18
+ }
19
+ end
19
20
 
20
- def find_institution(certificate_number)
21
- resp = Client.new.find_institution(certificate_number)
22
- result = resp['d']['results'].first
23
- FDIC::Institution.new(result)
24
- end
21
+ def find_institution(certificate_number)
22
+ resp = Client.new.find_institution(certificate_number)
23
+ result = resp['d']['results'].first
24
+ Institution.new(result)
25
+ end
25
26
 
26
- def find_branches(certificate_number)
27
- resp = Client.new.find_branches(certificate_number)
28
- resp['d']['results'].map { |result|
29
- FDIC::Branch.new(result)
30
- }
31
- end
27
+ def find_branches(certificate_number)
28
+ resp = Client.new.find_branches(certificate_number)
29
+ resp['d']['results'].map { |result|
30
+ Branch.new(result)
31
+ }
32
+ end
32
33
 
33
- def find_history_events(bank_name, certificate_number)
34
- resp = Client.new.find_history_events(bank_name, certificate_number)
35
- resp['d']['results'].map { |result|
36
- FDIC::HistoryEvent.new(result)
37
- }
38
- end
34
+ def find_history_events(bank_name, certificate_number)
35
+ resp = Client.new.find_history_events(bank_name, certificate_number)
36
+ resp['d']['results'].map { |result|
37
+ HistoryEvent.new(result)
38
+ }
39
+ end
39
40
 
40
- extend self
41
+ extend self
42
+ end
41
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fdic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Reznick
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2015-08-06 00:00:00.000000000 Z
12
+ date: 2015-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty