fdic 0.7.0 → 0.8.1

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: cee1a56fd56f55082091a024d75ec72263b09c60
4
- data.tar.gz: 4570eae536801fcb622f1f87c9c9179d51f57f01
3
+ metadata.gz: 0da8c35859bb601c56594efb7f76b1c9bb951de8
4
+ data.tar.gz: caa934f77248364886ed7a55bb98feeed0fc525c
5
5
  SHA512:
6
- metadata.gz: 4623e70986d313cc9082e912061952aef2c48f257e9fadfd5366d66c5e3cf34df507acaf24c7efea5fd94729704457abcf71a376ad2f0943ca573820deba485a
7
- data.tar.gz: 10f6266ef022c187fefd569a2432e674cc00eb1451df0bf2ccf018baf6c7e8341f7a774678ec376095596f19411883706dc9a529e9ab1e27408dff683dcbeccc
6
+ metadata.gz: ece71402158e9ad77d0fc14ca05250de7852f6f3780dc541934ec5ebe43c3a9ed5ce860094f86b628d390cb5e10bcc0b7adb8ce0e6d31348e2d3aa5ee83f34f1
7
+ data.tar.gz: d70b9b37bfda5494f205019e68142123ff8b4abac703122baf2774a4e42de082bf2b79f34513865cfc629c4685dcaf675ebfdc07f34ef8c697d9767775836c13
@@ -1,35 +1,35 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fdic (0.6.0)
4
+ fdic (0.8.0)
5
5
  httparty (~> 0.13)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- codeclimate-test-reporter (0.4.7)
10
+ codeclimate-test-reporter (0.4.8)
11
11
  simplecov (>= 0.7.1, < 1.0.0)
12
12
  diff-lcs (1.2.5)
13
13
  docile (1.1.5)
14
- httparty (0.13.5)
14
+ httparty (0.13.7)
15
15
  json (~> 1.8)
16
16
  multi_xml (>= 0.5.2)
17
17
  json (1.8.3)
18
18
  multi_xml (0.5.5)
19
19
  rake (10.4.2)
20
- rspec (3.3.0)
21
- rspec-core (~> 3.3.0)
22
- rspec-expectations (~> 3.3.0)
23
- rspec-mocks (~> 3.3.0)
24
- rspec-core (3.3.2)
25
- rspec-support (~> 3.3.0)
26
- rspec-expectations (3.3.1)
20
+ rspec (3.4.0)
21
+ rspec-core (~> 3.4.0)
22
+ rspec-expectations (~> 3.4.0)
23
+ rspec-mocks (~> 3.4.0)
24
+ rspec-core (3.4.0)
25
+ rspec-support (~> 3.4.0)
26
+ rspec-expectations (3.4.0)
27
27
  diff-lcs (>= 1.2.0, < 2.0)
28
- rspec-support (~> 3.3.0)
29
- rspec-mocks (3.3.2)
28
+ rspec-support (~> 3.4.0)
29
+ rspec-mocks (3.4.0)
30
30
  diff-lcs (>= 1.2.0, < 2.0)
31
- rspec-support (~> 3.3.0)
32
- rspec-support (3.3.0)
31
+ rspec-support (~> 3.4.0)
32
+ rspec-support (3.4.0)
33
33
  simplecov (0.10.0)
34
34
  docile (~> 1.1.0)
35
35
  json (~> 1.8)
@@ -47,4 +47,4 @@ DEPENDENCIES
47
47
  rspec (~> 3.0)
48
48
 
49
49
  BUNDLED WITH
50
- 1.10.3
50
+ 1.10.6
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  [![Code Climate](https://codeclimate.com/github/ContinuityControl/fdic/badges/gpa.svg)](https://codeclimate.com/github/ContinuityControl/fdic)
2
2
  [![Test Coverage](https://codeclimate.com/github/ContinuityControl/fdic/badges/coverage.svg)](https://codeclimate.com/github/ContinuityControl/fdic/coverage)
3
3
  [![Build Status](https://travis-ci.org/ContinuityControl/fdic.svg?branch=master)](https://travis-ci.org/ContinuityControl/fdic)
4
+ [![Gem Version](https://badge.fury.io/rb/fdic.svg)](https://badge.fury.io/rb/fdic)
4
5
 
5
6
  # FDIC
6
7
 
@@ -53,6 +54,19 @@ institution = FDIC::BankFind.find_institution(26588) #=> FDIC::BankFind::Instit
53
54
  # raises FDIC::Exceptions::RecordNotFound
54
55
  ```
55
56
 
57
+ Note, sometimes seemingly "valid" parameters will cause the FDIC to return a 500 error code.
58
+ ```ruby
59
+ institution = FDIC::BankFIND.find_institution("DOG") # Not a number
60
+ institution = FDIC::BankFIND.find_institution(1234567898798) # a number with more than 10 digits
61
+ # the FDIC returns 500
62
+ ```
63
+
64
+ When this happens, the gem will catch the error and raise an exception:
65
+ ```ruby
66
+ institution = FDIC::BankFIND.find_institution(1234567898798) # a number with more than 10 digits
67
+ # raises FDIC::Exceptions::ServerError
68
+ ```
69
+
56
70
  If you don't have the certificate number, you can search for a Bank by name, and get back all matching Banks:
57
71
 
58
72
  ```ruby
@@ -9,40 +9,49 @@ module FDIC
9
9
  #debug_output
10
10
 
11
11
  def find_bank(bank_name)
12
- self.class.get('/Bank',
12
+ check_response(self.class.get('/Bank',
13
13
  query:
14
14
  { '$inlinecount' => 'all',
15
15
  '$format' => 'json',
16
- '$filter' => "(substringof('#{escape_single_quotes(bank_name.upcase)}',name))"})
16
+ '$filter' => "(substringof('#{escape_single_quotes(bank_name.upcase)}',name))"}))
17
17
  end
18
18
 
19
19
  def find_institution(certificate_number)
20
- self.class.get('/Institution',
20
+ check_response(self.class.get('/Institution',
21
21
  query:
22
22
  { '$inlinecount' => 'all',
23
23
  '$format' => 'json',
24
- '$filter' => "certNumber eq #{certificate_number}"})
24
+ '$filter' => "certNumber eq #{certificate_number}"}))
25
25
  end
26
26
 
27
27
  def find_branches(certificate_number)
28
- self.class.get('/Branch',
28
+ check_response(self.class.get('/Branch',
29
29
  query:
30
30
  { '$inlinecount' => 'allpages',
31
31
  '$format' => 'json',
32
- '$filter' => "certNumber eq #{certificate_number}"})
32
+ '$filter' => "certNumber eq #{certificate_number}"}))
33
33
  end
34
34
 
35
35
  def find_history_events(bank_name, certificate_number)
36
36
  filter = "legalName eq '#{escape_single_quotes(bank_name.upcase)}' and certNumber eq #{certificate_number}"
37
- self.class.get('/History',
37
+ check_response(self.class.get('/History',
38
38
  query:
39
39
  { '$inlinecount' => 'all',
40
40
  '$format' => 'json',
41
- '$filter' => filter})
41
+ '$filter' => filter}))
42
42
  end
43
43
 
44
44
  private
45
45
 
46
+ def check_response(resp)
47
+ case resp.code
48
+ when 200...300
49
+ resp
50
+ when 500...600
51
+ raise FDIC::Exceptions::ServerError
52
+ end
53
+ end
54
+
46
55
  def escape_single_quotes(string)
47
56
  # Urm? The API 500's if you have a single-quote in name: "People's United Bank."
48
57
  # Their web forms double-up the single-quotes to escape them.
@@ -1,5 +1,6 @@
1
1
  module FDIC
2
2
  module Exceptions
3
3
  class RecordNotFound < StandardError; end
4
+ class ServerError < StandardError; end
4
5
  end
5
6
  end
@@ -1,3 +1,3 @@
1
1
  module FDIC
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.1"
3
3
  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.7.0
4
+ version: 0.8.1
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-10-21 00:00:00.000000000 Z
12
+ date: 2015-11-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty