fdic 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -7
- data/lib/fdic/bank.rb +21 -19
- data/lib/fdic/branch.rb +14 -12
- data/lib/fdic/client.rb +43 -41
- data/lib/fdic/history_event.rb +16 -14
- data/lib/fdic/institution.rb +32 -30
- data/lib/fdic/record.rb +30 -28
- data/lib/fdic/version.rb +1 -1
- data/lib/fdic.rb +26 -24
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcf10e68f158d536e5fa76857a547c5a186a8198
|
4
|
+
data.tar.gz: 5edb0f2ac6558e1a9352bdf6ca79a1da6b4d1c15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def find_institution!
|
16
|
+
@institution ||= BankFind.find_institution(certificate_number)
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
def find_history_events!
|
20
|
+
@history_events ||= BankFind.find_history_events(legal_name, certificate_number)
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
field :address
|
31
|
+
field :city
|
32
|
+
field :county
|
33
|
+
field :state
|
34
|
+
field :zip
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
8
|
-
|
8
|
+
#logger ::Logger.new 'httparty.log', :debug, :curl
|
9
|
+
#debug_output
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
44
|
+
private
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
data/lib/fdic/history_event.rb
CHANGED
@@ -1,22 +1,24 @@
|
|
1
1
|
module FDIC
|
2
|
-
|
2
|
+
module BankFind
|
3
|
+
class HistoryEvent < Record
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
field :fdic_id, :id
|
6
|
+
field(:legal_name, :legalName, &:strip)
|
7
|
+
field :certificate_number, :certNumber
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
date_field :effective_date, :orgEffDate
|
10
|
+
field :event_description, :eventDescription
|
11
|
+
field :change_code, :changeCode
|
12
|
+
field :change_description, :changeDesc
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
field :trust_power, :trustPower
|
15
|
+
field :trust_power_check, :trustPowerCheck
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
field :city
|
18
|
+
field :state
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
field :primary_regulatory_agency_check, :primaryRegulatoryAgencyCheck
|
21
|
+
field :primary_regulatory_agency, :primaryRegulatoryAgency
|
22
|
+
end
|
21
23
|
end
|
22
24
|
end
|
data/lib/fdic/institution.rb
CHANGED
@@ -1,41 +1,43 @@
|
|
1
1
|
module FDIC
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
8
|
-
|
8
|
+
field :supervising_authority, :FACodeText
|
9
|
+
field :supervising_authority_code, :FACode
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
26
|
+
date_field :report_date, "reportDate" # This is NOT the date the query was made.
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
34
|
+
def find_history_events!
|
35
|
+
@history_events ||= BankFind.find_history_events(legal_name, certificate_number)
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
module BankFind
|
3
|
+
class Record
|
4
|
+
def initialize(attributes)
|
5
|
+
@attributes = attributes
|
6
|
+
@attributes.freeze
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
+
attr_reader :attributes
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
19
|
+
def self.int_field(method_name, response_key=method_name)
|
20
|
+
field(method_name, response_key, &:to_i)
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
35
|
-
|
35
|
+
def uri
|
36
|
+
attributes['__metadata']['uri']
|
37
|
+
end
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
data/lib/fdic/version.rb
CHANGED
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
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.
|
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-
|
12
|
+
date: 2015-08-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|