fdic 0.4.0 → 0.5.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: bcf10e68f158d536e5fa76857a547c5a186a8198
4
- data.tar.gz: 5edb0f2ac6558e1a9352bdf6ca79a1da6b4d1c15
3
+ metadata.gz: a272bf5ef7ba4ae55c152d39e39a8e989d0a2676
4
+ data.tar.gz: ace1b5464a695805a4c120470b6051a786f8a661
5
5
  SHA512:
6
- metadata.gz: 8bbd0f3c0587947f9708955b89096a6feb499c2a5bdd658f1587315ffa0890240c75d212a5621191c6077891c9e711e3cc0f5c8dd30dc19338b5672d8c3af34b
7
- data.tar.gz: 6a0c8d31cc6ccd604e0497cd9dff38752007ff050140e1c0f8e97a8e4a46f3f4711004941367059ff510150443c7f36d2ab2fb4fa1cbf5c8361d8b2f1b0f6ea5
6
+ metadata.gz: b1b6771c3db012e2cc16af79066acf7a16daede58cc375c98b21aff578c6cba9120b7bcbf1b72f5e9ff2bdb194a27bb47ae622a5b4ecc7402f74d8220b8ba69c
7
+ data.tar.gz: 9d65c447c1c37923321e6c44670d7de7c427b0957b08667eca2cc7d6858df0b92428b0c668134eb5405e8cf52f055961bd04a27ca88d4f204f770944f7c1da8f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fdic (0.3.0)
4
+ fdic (0.4.0)
5
5
  httparty (~> 0.13)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -38,29 +38,36 @@ Or install it yourself as:
38
38
 
39
39
  ## Usage
40
40
 
41
- The FDIC API lets you find an Institution if you have its FDIC Certificate Number:
42
-
43
41
  Currently all of our features are namespaced under the `FDIC::BankFind` module
44
42
 
43
+ The FDIC API lets you find an Institution if you have its FDIC Certificate Number:
44
+
45
+ ```ruby
46
+ institution = FDIC::BankFind.find_institution(26588) #=> FDIC::BankFind::Institution
45
47
  ```
48
+
49
+ If your certificate number is incorrect, this will raise an exception:
50
+
51
+ ```ruby
46
52
  institution = FDIC::BankFind.find_institution(26588) #=> FDIC::BankFind::Institution
53
+ # raises FDIC::Exceptions::RecordNotFound
47
54
  ```
48
55
 
49
56
  If you don't have the certificate number, you can search for a Bank by name, and get back all matching Banks:
50
57
 
51
- ```
58
+ ```ruby
52
59
  banks = FDIC::BankFind.find_bank('Dedicated Community Bank') #=> [FDIC::BankFind::Bank, FDIC::BankFind::Bank, ...]
53
60
  ```
54
61
 
55
62
  Once you have a Bank, you can get its Institution, which has much more data available:
56
63
 
57
- ```
64
+ ```ruby
58
65
  institution = banks.first.find_institution! # Bang, because it's another network request
59
66
  ```
60
67
 
61
68
  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:
62
69
 
63
- ```
70
+ ```ruby
64
71
  institution.find_branches! #=> [FDIC::BankFind::Branch, FDIC::BankFind::Branch, ...]
65
72
  FDIC::BankFind.find_branches(25688) #=> [FDIC::BankFind::Branch, FDIC::BankFind::Branch, ...]
66
73
 
@@ -70,7 +77,7 @@ FDIC::BankFind.find_history_events('Dedicated Community Bank', 26588) #=> [FDI
70
77
 
71
78
  Since a `Bank` knows its certificate number, it can look up its branch and history information, too.
72
79
 
73
- ```
80
+ ```ruby
74
81
  # These work just like they do on Institutions:
75
82
  bank.find_branches!
76
83
  bank.find_history_events!
@@ -85,4 +92,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/Contin
85
92
  ## License
86
93
 
87
94
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
88
-
File without changes
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ module FDIC
2
+ module Exceptions
3
+ class RecordNotFound < StandardError; end
4
+ end
5
+ end
File without changes
@@ -0,0 +1,45 @@
1
+ require 'fdic/bank_find/exceptions'
2
+ require 'fdic/bank_find/client'
3
+ require 'fdic/bank_find/record'
4
+ require 'fdic/bank_find/bank'
5
+ require 'fdic/bank_find/institution'
6
+ require 'fdic/bank_find/branch'
7
+ require 'fdic/bank_find/history_event'
8
+
9
+ module FDIC
10
+ module BankFind
11
+
12
+ def find_bank(bank_name)
13
+ resp = Client.new.find_bank(bank_name)
14
+ resp['d']['results'].map { |result|
15
+ Bank.new(result)
16
+ }
17
+ end
18
+
19
+ def find_institution(certificate_number)
20
+ resp = Client.new.find_institution(certificate_number)
21
+ results = resp.fetch('d').fetch('results')
22
+ if results.empty? || results.nil?
23
+ raise FDIC::Exceptions::RecordNotFound, "#{certificate_number} appears to be an invalid certificate number"
24
+ else
25
+ Institution.new(results.first)
26
+ end
27
+ end
28
+
29
+ def find_branches(certificate_number)
30
+ resp = Client.new.find_branches(certificate_number)
31
+ resp['d']['results'].map { |result|
32
+ Branch.new(result)
33
+ }
34
+ end
35
+
36
+ def find_history_events(bank_name, certificate_number)
37
+ resp = Client.new.find_history_events(bank_name, certificate_number)
38
+ resp['d']['results'].map { |result|
39
+ HistoryEvent.new(result)
40
+ }
41
+ end
42
+
43
+ extend self
44
+ end
45
+ end
data/lib/fdic/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module FDIC
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/lib/fdic.rb CHANGED
@@ -1,43 +1,4 @@
1
1
  require 'httparty'
2
2
  require 'logger'
3
3
  require "fdic/version"
4
- require 'fdic/client'
5
- require 'fdic/record'
6
- require 'fdic/bank'
7
- require 'fdic/institution'
8
- require 'fdic/branch'
9
- require 'fdic/history_event'
10
-
11
- module FDIC
12
- module BankFind
13
-
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
20
-
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
26
-
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
33
-
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
40
-
41
- extend self
42
- end
43
- end
4
+ require 'fdic/bank_find'
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.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Reznick
@@ -87,12 +87,14 @@ files:
87
87
  - bin/setup
88
88
  - fdic.gemspec
89
89
  - lib/fdic.rb
90
- - lib/fdic/bank.rb
91
- - lib/fdic/branch.rb
92
- - lib/fdic/client.rb
93
- - lib/fdic/history_event.rb
94
- - lib/fdic/institution.rb
95
- - lib/fdic/record.rb
90
+ - lib/fdic/bank_find.rb
91
+ - lib/fdic/bank_find/bank.rb
92
+ - lib/fdic/bank_find/branch.rb
93
+ - lib/fdic/bank_find/client.rb
94
+ - lib/fdic/bank_find/exceptions.rb
95
+ - lib/fdic/bank_find/history_event.rb
96
+ - lib/fdic/bank_find/institution.rb
97
+ - lib/fdic/bank_find/record.rb
96
98
  - lib/fdic/version.rb
97
99
  homepage: https://github.com/ContinuityControl/fdic
98
100
  licenses: