ibanchecker 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 703ae63dc085318f0be9dbea66816f2b2798fef508d2a3f3f6fe16d158c3834a
4
- data.tar.gz: 8f11660e9baa9c337dea6e73ad88e014199a4e3abe5c25b63f3ec15aab6e127e
3
+ metadata.gz: bf9e74cb7e1a343e35c3bdd80928cbbf38872341b2c3b0f51959fde4bec0d96a
4
+ data.tar.gz: f83727602f144aa5e9da5f6e33b96e25ae6dda5b45e01bdc0c3af90222f716b4
5
5
  SHA512:
6
- metadata.gz: 6ffeb4593b42dc8d1b25aeb889c529046490d33779681816feca20dd3ff636337f25f805cb2e2e521b444a202517e4ac5d2c149a5d5281d560d5c7cc41697e8b
7
- data.tar.gz: '08d302dbe4737762672566fbc543e9bdd88bbcc1e5d63bef974747b772acc190d31e6f92f1083ca1ebd732791f7e24f606f1c5630a4679dc0864a88bf253e2a7'
6
+ metadata.gz: 7eeb15b1513861115327946aabc8825a9c28cc985aca96edc69b9f9e1bb523e23911ed90eb51243f241ec7ca19159435d16c13ab96f9d12512fd196c3edb7ad8
7
+ data.tar.gz: 9f64287aa482efb5ab341ce5416280d17f3469b8d0e1a8136cb223472ca8257e813105e16afa293f67feed2cf719a55b5e485bdb19f29fb5d32ea5293c3fd2d2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.2
4
+
5
+ Documentation only.
6
+
7
+ - The API now requires a key for every call except `country_format`:
8
+ `lookup_bic` without one gets a 401 and the client raises
9
+ `AuthenticationError`. The hourly limit for requests without a key (100 an
10
+ hour per IP) now covers `country_format` only
11
+ - What a key can call follows its plan. The free key covers `validate`, 100
12
+ requests a month; `validate_bulk` and `lookup_bic` need Basic or above;
13
+ `extract` needs Growth or above. A key with a verified account can try the
14
+ calls its plan lacks, with up to 10 IBANs per bulk call and 5,000
15
+ characters per extraction; a trial call over that size gets a 400
16
+ (`TOO_MANY_IBANS` or `TEXT_TOO_LONG`)
17
+ - A call outside the key's plan gets a 403 with `error_code`
18
+ `PLAN_REQUIRED`, which the client raises as `APIError`; `#response` carries
19
+ `required_plan` and `upgrade_url`
20
+ - `validate_bulk` counts one request per IBAN and `extract` one per IBAN
21
+ found, at least one per call. A call that costs more than the requests left
22
+ this month gets a 429 `QUOTA_EXCEEDED`, raised as `RateLimitError`
23
+ - README and doc comments say which plan each call needs
24
+
25
+ The client's behaviour does not change.
26
+
3
27
  ## 0.1.1
4
28
 
5
29
  Documentation only; the client's behaviour is unchanged.
data/README.md CHANGED
@@ -20,7 +20,7 @@ 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).
23
+ Every call except `country_format` needs an API key. A free key covers single IBAN validation, 100 requests a month, and arrives by email in seconds from [ibanchecker.cash/api-docs](https://ibanchecker.cash/api-docs).
24
24
 
25
25
  ```ruby
26
26
  require "ibanchecker"
@@ -41,31 +41,51 @@ end
41
41
 
42
42
  ## Authentication
43
43
 
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).
44
+ `validate`, `validate_bulk`, `extract` and `lookup_bic` need an API key. Without one the API answers HTTP 401 and the client raises `IbanChecker::AuthenticationError`. `lookup_bic` used to work without a key; it no longer does. The free key from [ibanchecker.cash/api-docs](https://ibanchecker.cash/api-docs) covers `validate` only, 100 requests a month; paid plans are at [ibanchecker.cash/pricing](https://ibanchecker.cash/pricing).
45
45
 
46
- `country_format` and `lookup_bic` work without a key, limited to 100 requests an hour per IP.
46
+ `country_format` is the only call that works without a key, limited to 100 requests an hour per IP. Beyond that the API answers HTTP 429 with `error_code` `"RATE_LIMIT_EXCEEDED"`. This hourly limit applies to `country_format` only.
47
47
 
48
48
  ```ruby
49
49
  client = IbanChecker::Client.new("iban_your_api_key")
50
50
  client = IbanChecker::Client.new(ENV["IBANCHECKER_API_KEY"])
51
51
 
52
- lookups = IbanChecker::Client.new # country_format and lookup_bic only
52
+ formats = IbanChecker::Client.new # country_format only
53
53
  ```
54
54
 
55
+ ### What each plan can call
56
+
57
+ | Method | Plan | Largest call |
58
+ | --- | --- | --- |
59
+ | `validate` | any key, including the free key | one IBAN |
60
+ | `validate_bulk` | Basic or above (Basic, Starter, Growth, Enterprise) | 100 IBANs |
61
+ | `lookup_bic` | Basic or above (Basic, Starter, Growth, Enterprise) | one BIC |
62
+ | `extract` | Growth or above (Growth, Enterprise) | 50,000 characters |
63
+ | `country_format` | no key needed | one country |
64
+
65
+ A key whose email address has a verified account at [ibanchecker.cash/dashboard](https://ibanchecker.cash/dashboard) can try the calls its plan lacks: `validate_bulk` with up to 10 IBANs per call, `lookup_bic`, and `extract` with up to 5,000 characters per call. This applies to any plan that lacks the call, so a Basic key with a verified account can try `extract` as well. A trial call over that size gets HTTP 400 with `error_code` `"TOO_MANY_IBANS"` (bulk) or `"TEXT_TOO_LONG"` (extraction), which the client raises as `IbanChecker::BadRequestError`.
66
+
67
+ A call outside the key's plan gets HTTP 403 with `error_code` `"PLAN_REQUIRED"`. The client has no class of its own for 403, so it raises `IbanChecker::APIError`; the decoded body on `#response` also carries `required_plan` (`"basic"` or `"growth"`) and `upgrade_url`. See [Error handling](#error-handling).
68
+
69
+ ### How requests are counted
70
+
71
+ `validate` and `lookup_bic` count one request each. `validate_bulk` counts one request per IBAN in the call, and `extract` counts one per IBAN found, with at least one per call. A call that costs more than the requests left this month gets HTTP 429 with `error_code` `"QUOTA_EXCEEDED"`, raised as `IbanChecker::RateLimitError`.
72
+
55
73
  ## Methods
56
74
 
57
75
  | Method | API key | Description |
58
76
  | --- | --- | --- |
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`. |
77
+ | `validate(iban)` | required, any plan | Validate a single IBAN. Returns a `ValidationResult`. |
78
+ | `validate_bulk(ibans)` | required, Basic or above | Validate up to 100 IBANs (10 on a trial). Returns a `BatchResult`. |
79
+ | `extract(text)` | required, Growth or above | Find and validate IBANs in free text (up to 50,000 chars, 5,000 on a trial). Returns a `BatchResult`. |
62
80
  | `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`. |
81
+ | `lookup_bic(bic)` | required, Basic or above | Resolve an 8 or 11 character BIC. Returns a `BankRecord`. |
64
82
 
65
83
  `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.
66
84
 
67
85
  ### Bulk validation
68
86
 
87
+ Needs a key on the Basic plan or above, or a trial (see [What each plan can call](#what-each-plan-can-call)). Each IBAN in the call counts as one request.
88
+
69
89
  ```ruby
70
90
  batch = client.validate_bulk([
71
91
  "DE89370400440532013000",
@@ -86,6 +106,8 @@ end
86
106
 
87
107
  ### Extract from text
88
108
 
109
+ Needs a key on the Growth plan or above, or a trial. Each IBAN found counts as one request, with at least one per call.
110
+
89
111
  ```ruby
90
112
  batch = client.extract("Please wire to DE89 3704 0044 0532 0130 00 by Friday.")
91
113
 
@@ -95,6 +117,8 @@ batch.map { |r| [r.iban, r.bank_name] }
95
117
 
96
118
  ### Country format and BIC lookup
97
119
 
120
+ `country_format` works without a key. `lookup_bic` needs a key on the Basic plan or above, or a trial.
121
+
98
122
  ```ruby
99
123
  format = client.country_format("DE")
100
124
  format.length # => 22
@@ -136,16 +160,20 @@ rescue IbanChecker::RateLimitError => e
136
160
  puts "Slow down: #{e.message}"
137
161
  rescue IbanChecker::AuthenticationError
138
162
  puts "Check your API key"
163
+ rescue IbanChecker::APIError => e
164
+ raise unless e.error_code == "PLAN_REQUIRED"
165
+
166
+ puts "Needs the #{e.response["required_plan"]} plan: #{e.response["upgrade_url"]}"
139
167
  end
140
168
  ```
141
169
 
142
170
  | Class | Raised when |
143
171
  | --- | --- |
144
- | `IbanChecker::BadRequestError` | HTTP 400, the request was malformed |
145
- | `IbanChecker::AuthenticationError` | HTTP 401, the API key is missing, invalid or inactive |
172
+ | `IbanChecker::BadRequestError` | HTTP 400, the request was malformed, or a trial call was over the trial size (`error_code` `"TOO_MANY_IBANS"` or `"TEXT_TOO_LONG"`) |
173
+ | `IbanChecker::AuthenticationError` | HTTP 401, the API key is missing, invalid or inactive; every call except `country_format` gets this without a key |
146
174
  | `IbanChecker::NotFoundError` | HTTP 404, no such country code or BIC |
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 |
148
- | `IbanChecker::APIError` | any other error status, or a body that could not be read |
175
+ | `IbanChecker::RateLimitError` | HTTP 429, the key's monthly quota was exceeded or the call costs more than the requests left (`error_code` `"QUOTA_EXCEEDED"`), or `country_format` without a key went over 100 requests an hour (`"RATE_LIMIT_EXCEEDED"`) |
176
+ | `IbanChecker::APIError` | any other error status, including HTTP 403 for a call outside the key's plan (`error_code` `"PLAN_REQUIRED"`), or a body that could not be read |
149
177
  | `IbanChecker::TransportError` | the request never reached the API: DNS, TLS, connection, timeout |
150
178
 
151
179
  All of them inherit from `IbanChecker::Error`, so one `rescue IbanChecker::Error` catches everything this gem raises. Each carries `#status`, `#error_code` and `#response`.
@@ -9,11 +9,20 @@ module IbanChecker
9
9
  # extract IBANs from free text, look up country format specifications and
10
10
  # resolve SWIFT/BIC codes.
11
11
  #
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.
12
+ # Every call except country_format needs an API key; without one the API
13
+ # answers 401 and AuthenticationError is raised. That includes lookup_bic,
14
+ # which used to work without a key. The free key from
15
+ # https://ibanchecker.cash/api-docs covers validate only, 100 requests a
16
+ # month. validate_bulk and lookup_bic need the Basic plan or above, and
17
+ # extract the Growth plan or above. A key whose email address has a verified
18
+ # account at https://ibanchecker.cash/dashboard can try the calls its plan
19
+ # lacks (validate_bulk up to 10 IBANs, extract up to 5,000 characters per
20
+ # call). A call outside the key's plan gets a 403 with error_code
21
+ # "PLAN_REQUIRED", raised as APIError; its #response carries required_plan
22
+ # and upgrade_url.
23
+ #
24
+ # country_format works without a key, limited to 100 requests an hour per
25
+ # IP. That hourly limit applies to country_format only.
17
26
  #
18
27
  # client = IbanChecker::Client.new(ENV["IBANCHECKER_API_KEY"]) # or .new("iban_your_key")
19
28
  # result = client.validate("DE89 3704 0044 0532 0130 00")
@@ -46,7 +55,7 @@ module IbanChecker
46
55
  # A malformed IBAN is not an error: the result comes back with +valid?+
47
56
  # false and an +error+ plus +error_code+ explaining why.
48
57
  #
49
- # Needs an API key.
58
+ # Needs an API key; the free key covers it. Counts one request.
50
59
  def validate(iban)
51
60
  ValidationResult.from_api(request("POST", "/validate", "iban" => iban.to_s))
52
61
  end
@@ -54,7 +63,8 @@ module IbanChecker
54
63
  # Validate up to 100 IBANs in one request. Results come back in the same
55
64
  # order as the input.
56
65
  #
57
- # Needs an API key.
66
+ # Needs an API key on the Basic plan or above, or a trial of up to 10 IBANs
67
+ # per call for a key with a verified account. Counts one request per IBAN.
58
68
  def validate_bulk(ibans)
59
69
  BatchResult.from_api(
60
70
  request("POST", "/validate/bulk", "ibans" => Array(ibans).map(&:to_s))
@@ -64,7 +74,9 @@ module IbanChecker
64
74
  # Scan free text (emails, invoices) for IBAN-shaped strings and validate
65
75
  # each candidate. Up to 50,000 characters per request.
66
76
  #
67
- # Needs an API key.
77
+ # Needs an API key on the Growth plan or above, or a trial of up to 5,000
78
+ # characters per call for a key with a verified account. Counts one request
79
+ # per IBAN found, with at least one per call.
68
80
  def extract(text)
69
81
  BatchResult.from_api(request("POST", "/extract", "text" => text.to_s))
70
82
  end
@@ -74,11 +86,19 @@ module IbanChecker
74
86
  #
75
87
  # Named country_format rather than format because Kernel#format is
76
88
  # sprintf, and shadowing it inside this class would be a trap.
89
+ #
90
+ # The only call that works without a key, limited to 100 requests an hour
91
+ # per IP.
77
92
  def country_format(country)
78
93
  FormatSpec.from_api(request("GET", "/formats/#{escape(country.to_s.downcase)}"))
79
94
  end
80
95
 
81
96
  # Resolve an 8 or 11 character ISO 9362 BIC to a bank record.
97
+ #
98
+ # Needs an API key on the Basic plan or above, or a trial for a key with a
99
+ # verified account. Without a key the API answers 401 and
100
+ # AuthenticationError is raised; it no longer works keyless. Counts one
101
+ # request.
82
102
  def lookup_bic(bic)
83
103
  BankRecord.from_api(request("GET", "/swift/#{escape(bic.to_s.upcase)}"))
84
104
  end
@@ -24,20 +24,32 @@ module IbanChecker
24
24
  end
25
25
  end
26
26
 
27
- # The request was malformed (HTTP 400).
27
+ # The request was malformed, or a trial call was over the trial size
28
+ # ("TOO_MANY_IBANS" for bulk, "TEXT_TOO_LONG" for extraction) (HTTP 400).
28
29
  class BadRequestError < Error; end
29
30
 
30
31
  # The API key is missing, invalid or inactive (HTTP 401).
32
+ #
33
+ # Every call except Client#country_format needs a key, so a call without
34
+ # one, a Client#lookup_bic included, gets this from the API's 401.
31
35
  class AuthenticationError < Error; end
32
36
 
33
37
  # The requested country code or BIC was not found (HTTP 404).
34
38
  class NotFoundError < Error; end
35
39
 
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).
40
+ # The key's monthly quota was exceeded, or the call costs more than the
41
+ # requests left this month ("QUOTA_EXCEEDED"), or Client#country_format
42
+ # without a key went over 100 requests an hour ("RATE_LIMIT_EXCEEDED")
43
+ # (HTTP 429). Bulk validation counts one request per IBAN and extraction one
44
+ # per IBAN found.
38
45
  class RateLimitError < Error; end
39
46
 
40
- # An unexpected server-side error, or a body that could not be read.
47
+ # Any error status without a class of its own, or a body that could not be
48
+ # read.
49
+ #
50
+ # This includes HTTP 403 for a call outside the key's plan: error_code is
51
+ # "PLAN_REQUIRED" and #response carries "required_plan" ("basic" or
52
+ # "growth") and "upgrade_url".
41
53
  class APIError < Error; end
42
54
 
43
55
  # The request never reached the API: DNS, TLS, connection or timeout.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IbanChecker
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ibanchecker.cash