ibanchecker 0.1.0 → 0.1.1
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/CHANGELOG.md +12 -0
- data/README.md +17 -11
- data/lib/ibanchecker/client.rb +12 -3
- data/lib/ibanchecker/errors.rb +2 -1
- data/lib/ibanchecker/version.rb +1 -1
- data/lib/ibanchecker.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 703ae63dc085318f0be9dbea66816f2b2798fef508d2a3f3f6fe16d158c3834a
|
|
4
|
+
data.tar.gz: 8f11660e9baa9c337dea6e73ad88e014199a4e3abe5c25b63f3ec15aab6e127e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6ffeb4593b42dc8d1b25aeb889c529046490d33779681816feca20dd3ff636337f25f805cb2e2e521b444a202517e4ac5d2c149a5d5281d560d5c7cc41697e8b
|
|
7
|
+
data.tar.gz: '08d302dbe4737762672566fbc543e9bdd88bbcc1e5d63bef974747b772acc190d31e6f92f1083ca1ebd732791f7e24f606f1c5630a4679dc0864a88bf253e2a7'
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
Documentation only; the client's behaviour is unchanged.
|
|
6
|
+
|
|
7
|
+
- The API now requires a key for `validate`, `validate_bulk` and `extract`:
|
|
8
|
+
without one it answers 401 and the client raises `AuthenticationError`. The
|
|
9
|
+
free key covers 100 requests a month
|
|
10
|
+
- `country_format` and `lookup_bic` still work without a key, limited to 100
|
|
11
|
+
requests an hour per IP
|
|
12
|
+
- README, examples and doc comments construct the client with a key and say
|
|
13
|
+
which calls need it
|
|
14
|
+
|
|
3
15
|
## 0.1.0
|
|
4
16
|
|
|
5
17
|
First release.
|
data/README.md
CHANGED
|
@@ -20,10 +20,12 @@ Requires Ruby 2.7 or newer. There are no runtime dependencies: the client is bui
|
|
|
20
20
|
|
|
21
21
|
## Quick start
|
|
22
22
|
|
|
23
|
+
Validation, bulk validation and extraction need an API key. A free key covers 100 requests a month and arrives by email in seconds from [ibanchecker.cash/api-docs](https://ibanchecker.cash/api-docs).
|
|
24
|
+
|
|
23
25
|
```ruby
|
|
24
26
|
require "ibanchecker"
|
|
25
27
|
|
|
26
|
-
client = IbanChecker::Client.new #
|
|
28
|
+
client = IbanChecker::Client.new(ENV["IBANCHECKER_API_KEY"]) # or .new("iban_your_api_key")
|
|
27
29
|
|
|
28
30
|
result = client.validate("DE89 3704 0044 0532 0130 00")
|
|
29
31
|
|
|
@@ -39,22 +41,26 @@ end
|
|
|
39
41
|
|
|
40
42
|
## Authentication
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
`validate`, `validate_bulk` and `extract` need an API key. Without one the API answers HTTP 401 and the client raises `IbanChecker::AuthenticationError`. The free key from [ibanchecker.cash/api-docs](https://ibanchecker.cash/api-docs) covers 100 requests a month; paid plans are at [ibanchecker.cash/pricing](https://ibanchecker.cash/pricing).
|
|
45
|
+
|
|
46
|
+
`country_format` and `lookup_bic` work without a key, limited to 100 requests an hour per IP.
|
|
43
47
|
|
|
44
48
|
```ruby
|
|
45
49
|
client = IbanChecker::Client.new("iban_your_api_key")
|
|
46
50
|
client = IbanChecker::Client.new(ENV["IBANCHECKER_API_KEY"])
|
|
51
|
+
|
|
52
|
+
lookups = IbanChecker::Client.new # country_format and lookup_bic only
|
|
47
53
|
```
|
|
48
54
|
|
|
49
55
|
## Methods
|
|
50
56
|
|
|
51
|
-
| Method | Description |
|
|
52
|
-
| --- | --- |
|
|
53
|
-
| `validate(iban)` | Validate a single IBAN. Returns a `ValidationResult`. |
|
|
54
|
-
| `validate_bulk(ibans)` | Validate up to 100 IBANs. Returns a `BatchResult`. |
|
|
55
|
-
| `extract(text)` | Find and validate IBANs in free text (up to 50,000 chars). Returns a `BatchResult`. |
|
|
56
|
-
| `country_format(country)` | IBAN format spec for an ISO country code. Returns a `FormatSpec`. |
|
|
57
|
-
| `lookup_bic(bic)` | Resolve an 8 or 11 character BIC. Returns a `BankRecord`. |
|
|
57
|
+
| Method | API key | Description |
|
|
58
|
+
| --- | --- | --- |
|
|
59
|
+
| `validate(iban)` | required | Validate a single IBAN. Returns a `ValidationResult`. |
|
|
60
|
+
| `validate_bulk(ibans)` | required | Validate up to 100 IBANs. Returns a `BatchResult`. |
|
|
61
|
+
| `extract(text)` | required | Find and validate IBANs in free text (up to 50,000 chars). Returns a `BatchResult`. |
|
|
62
|
+
| `country_format(country)` | optional | IBAN format spec for an ISO country code. Returns a `FormatSpec`. |
|
|
63
|
+
| `lookup_bic(bic)` | optional | Resolve an 8 or 11 character BIC. Returns a `BankRecord`. |
|
|
58
64
|
|
|
59
65
|
`country_format` is the one name that differs from the other ibanchecker clients, where it is `getFormat`. `format` is `Kernel#format`, Ruby's `sprintf`, so a method by that name on this class would shadow it for every line inside the class.
|
|
60
66
|
|
|
@@ -138,7 +144,7 @@ end
|
|
|
138
144
|
| `IbanChecker::BadRequestError` | HTTP 400, the request was malformed |
|
|
139
145
|
| `IbanChecker::AuthenticationError` | HTTP 401, the API key is missing, invalid or inactive |
|
|
140
146
|
| `IbanChecker::NotFoundError` | HTTP 404, no such country code or BIC |
|
|
141
|
-
| `IbanChecker::RateLimitError` | HTTP 429, hourly limit
|
|
147
|
+
| `IbanChecker::RateLimitError` | HTTP 429, the key's monthly quota (`error_code` `"QUOTA_EXCEEDED"`) or the hourly limit for requests without a key (`"RATE_LIMIT_EXCEEDED"`) was exceeded |
|
|
142
148
|
| `IbanChecker::APIError` | any other error status, or a body that could not be read |
|
|
143
149
|
| `IbanChecker::TransportError` | the request never reached the API: DNS, TLS, connection, timeout |
|
|
144
150
|
|
|
@@ -147,7 +153,7 @@ All of them inherit from `IbanChecker::Error`, so one `rescue IbanChecker::Error
|
|
|
147
153
|
## Timeouts
|
|
148
154
|
|
|
149
155
|
```ruby
|
|
150
|
-
client = IbanChecker::Client.new(timeout: 3.0) # seconds, applied to connect and read
|
|
156
|
+
client = IbanChecker::Client.new(ENV["IBANCHECKER_API_KEY"], timeout: 3.0) # seconds, applied to connect and read
|
|
151
157
|
```
|
|
152
158
|
|
|
153
159
|
## Using your own HTTP stack
|
data/lib/ibanchecker/client.rb
CHANGED
|
@@ -9,10 +9,13 @@ module IbanChecker
|
|
|
9
9
|
# extract IBANs from free text, look up country format specifications and
|
|
10
10
|
# resolve SWIFT/BIC codes.
|
|
11
11
|
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
12
|
+
# validate, validate_bulk and extract need an API key; without one the API
|
|
13
|
+
# answers 401 and AuthenticationError is raised. The free key from
|
|
14
|
+
# https://ibanchecker.cash/api-docs covers 100 requests a month.
|
|
15
|
+
# country_format and lookup_bic work without a key, limited to 100 requests
|
|
16
|
+
# an hour per IP.
|
|
14
17
|
#
|
|
15
|
-
# client = IbanChecker::Client.new
|
|
18
|
+
# client = IbanChecker::Client.new(ENV["IBANCHECKER_API_KEY"]) # or .new("iban_your_key")
|
|
16
19
|
# result = client.validate("DE89 3704 0044 0532 0130 00")
|
|
17
20
|
# puts "#{result.bank_name} #{result.bic}" if result.valid?
|
|
18
21
|
class Client
|
|
@@ -42,12 +45,16 @@ module IbanChecker
|
|
|
42
45
|
#
|
|
43
46
|
# A malformed IBAN is not an error: the result comes back with +valid?+
|
|
44
47
|
# false and an +error+ plus +error_code+ explaining why.
|
|
48
|
+
#
|
|
49
|
+
# Needs an API key.
|
|
45
50
|
def validate(iban)
|
|
46
51
|
ValidationResult.from_api(request("POST", "/validate", "iban" => iban.to_s))
|
|
47
52
|
end
|
|
48
53
|
|
|
49
54
|
# Validate up to 100 IBANs in one request. Results come back in the same
|
|
50
55
|
# order as the input.
|
|
56
|
+
#
|
|
57
|
+
# Needs an API key.
|
|
51
58
|
def validate_bulk(ibans)
|
|
52
59
|
BatchResult.from_api(
|
|
53
60
|
request("POST", "/validate/bulk", "ibans" => Array(ibans).map(&:to_s))
|
|
@@ -56,6 +63,8 @@ module IbanChecker
|
|
|
56
63
|
|
|
57
64
|
# Scan free text (emails, invoices) for IBAN-shaped strings and validate
|
|
58
65
|
# each candidate. Up to 50,000 characters per request.
|
|
66
|
+
#
|
|
67
|
+
# Needs an API key.
|
|
59
68
|
def extract(text)
|
|
60
69
|
BatchResult.from_api(request("POST", "/extract", "text" => text.to_s))
|
|
61
70
|
end
|
data/lib/ibanchecker/errors.rb
CHANGED
|
@@ -33,7 +33,8 @@ module IbanChecker
|
|
|
33
33
|
# The requested country code or BIC was not found (HTTP 404).
|
|
34
34
|
class NotFoundError < Error; end
|
|
35
35
|
|
|
36
|
-
# The
|
|
36
|
+
# The key's monthly quota ("QUOTA_EXCEEDED") or the hourly limit for requests
|
|
37
|
+
# without a key ("RATE_LIMIT_EXCEEDED") was exceeded (HTTP 429).
|
|
37
38
|
class RateLimitError < Error; end
|
|
38
39
|
|
|
39
40
|
# An unexpected server-side error, or a body that could not be read.
|
data/lib/ibanchecker/version.rb
CHANGED
data/lib/ibanchecker.rb
CHANGED
|
@@ -10,7 +10,7 @@ require_relative "ibanchecker/client"
|
|
|
10
10
|
#
|
|
11
11
|
# require "ibanchecker"
|
|
12
12
|
#
|
|
13
|
-
# client = IbanChecker::Client.new
|
|
13
|
+
# client = IbanChecker::Client.new(ENV["IBANCHECKER_API_KEY"])
|
|
14
14
|
# result = client.validate("DE89370400440532013000")
|
|
15
15
|
# result.valid? # => true
|
|
16
16
|
# result.bank_name # => "Commerzbank AG Cologne"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ibanchecker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ibanchecker.cash
|
|
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
53
|
version: '0'
|
|
54
54
|
requirements: []
|
|
55
|
-
rubygems_version: 4.0.
|
|
55
|
+
rubygems_version: 4.0.20
|
|
56
56
|
specification_version: 4
|
|
57
57
|
summary: Official Ruby client for the ibanchecker.cash IBAN validation API
|
|
58
58
|
test_files: []
|