ibanchecker 0.1.2 → 0.2.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/CHANGELOG.md +4 -0
- data/README.md +10 -0
- data/lib/ibanchecker/models.rb +39 -2
- data/lib/ibanchecker/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d00ef9634e78ac5fc15e6b8ecebd062ff3895aaf42bac32f25d5e22ba386dba0
|
|
4
|
+
data.tar.gz: a3ec40a1a31fd4ed438c866165efa6694fdada54d6a70daeb3f0117e7a9b6db2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 92f3b4913894448f8bdcd31d63719f00b88d6ba43ea95b99ea7f66df0d4aa9ea39bf714bb587449259f63125c842aef8bad242f2b90ab044001c2209158e3d7f
|
|
7
|
+
data.tar.gz: 6e2e326f13f1abf1bcbff9e1ec47ae8ae4f1a1626cb0ef98d26f4d459d35006ae20c9551e272a614ee61bb0dda68655b8b72d83ece47e751757b08c6b914ea9d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
- `bank_logo` on `ValidationResult` and `BankRecord`, as a new `IbanChecker::BankLogo`: the bank's logo, from the API's new `bank_logo` field on validation, bulk validation, extraction and BIC lookup. It holds a file for light and for dark backgrounds, whether the dark file needs a light backing, and the format; it is empty when no verified logo is held for the bank
|
|
6
|
+
|
|
3
7
|
## 0.1.2
|
|
4
8
|
|
|
5
9
|
Documentation only.
|
data/README.md
CHANGED
|
@@ -147,6 +147,16 @@ end
|
|
|
147
147
|
|
|
148
148
|
`valid?` is the only predicate method on the models, because it is the only field that is always a boolean. `national_check_valid` and `sepa` can each be `nil`, and `nil` there means "not known for this IBAN" rather than "no", so they are plain readers and you compare them explicitly.
|
|
149
149
|
|
|
150
|
+
### Bank logo
|
|
151
|
+
|
|
152
|
+
`result.bank_logo` and `bank.bank_logo` are an `IbanChecker::BankLogo`, or `nil` when no verified logo is held for the bank. It carries the mark the ibanchecker.cash result card shows: a file for light backgrounds, a file for dark backgrounds (the same URL when one file reads on both), whether the dark file needs a light chip behind it, and the format (`svg`, `png` or `webp`). Every logo is checked by hand against the bank's current mark, so not every bank has one yet; the field is empty then. The logos are the banks' trademarks, provided to identify the bank.
|
|
153
|
+
|
|
154
|
+
```ruby
|
|
155
|
+
if (logo = result.bank_logo)
|
|
156
|
+
[logo.on_light, logo.on_dark, logo.dark_needs_light_backing, logo.format]
|
|
157
|
+
end
|
|
158
|
+
```
|
|
159
|
+
|
|
150
160
|
## Error handling
|
|
151
161
|
|
|
152
162
|
A malformed IBAN is **not** an error: `validate` returns a `ValidationResult` with `valid?` false. Errors are raised only for transport, authentication, quota and server-side problems.
|
data/lib/ibanchecker/models.rb
CHANGED
|
@@ -27,6 +27,41 @@ module IbanChecker
|
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
# The bank's logo as the ibanchecker.cash result card shows it. The logos are
|
|
31
|
+
# the banks' trademarks, provided to identify the bank.
|
|
32
|
+
#
|
|
33
|
+
# +on_light+ is drawn on a light background and +on_dark+ on a dark one (the
|
|
34
|
+
# same URL when one file reads on both). When +dark_needs_light_backing+ is
|
|
35
|
+
# true, +on_dark+ has no dark variant and should sit on a light chip.
|
|
36
|
+
# +format+ is "svg", "png" or "webp".
|
|
37
|
+
class BankLogo
|
|
38
|
+
attr_reader :on_light, :on_dark, :dark_needs_light_backing, :format
|
|
39
|
+
|
|
40
|
+
# The untouched logo object from the API response.
|
|
41
|
+
attr_reader :raw
|
|
42
|
+
|
|
43
|
+
def initialize(on_light:, on_dark:, dark_needs_light_backing:, format:, raw: {})
|
|
44
|
+
@on_light = on_light
|
|
45
|
+
@on_dark = on_dark
|
|
46
|
+
@dark_needs_light_backing = dark_needs_light_backing
|
|
47
|
+
@format = format
|
|
48
|
+
@raw = raw
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# nil when the API holds no verified logo for the bank.
|
|
52
|
+
def self.from_api(data)
|
|
53
|
+
return nil unless data.is_a?(Hash) && !data.empty?
|
|
54
|
+
|
|
55
|
+
new(
|
|
56
|
+
on_light: data["on_light"],
|
|
57
|
+
on_dark: data["on_dark"],
|
|
58
|
+
dark_needs_light_backing: data["dark_needs_light_backing"] == true,
|
|
59
|
+
format: data["format"],
|
|
60
|
+
raw: data
|
|
61
|
+
)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
30
65
|
# The result of validating one IBAN.
|
|
31
66
|
#
|
|
32
67
|
# +valid?+ is the primary flag. When it is false only +iban+, +formatted+,
|
|
@@ -38,7 +73,7 @@ module IbanChecker
|
|
|
38
73
|
class ValidationResult
|
|
39
74
|
ATTRIBUTES = %i[
|
|
40
75
|
iban formatted check_digits bban country country_name
|
|
41
|
-
bank_name bank_type bic bank_city bank_code branch_code account_number
|
|
76
|
+
bank_name bank_type bic bank_city bank_logo bank_code branch_code account_number
|
|
42
77
|
national_check_valid currency currency_name transfer_type sepa flag
|
|
43
78
|
error error_code
|
|
44
79
|
].freeze
|
|
@@ -78,6 +113,7 @@ module IbanChecker
|
|
|
78
113
|
bank_type: data["bank_type"],
|
|
79
114
|
bic: data["bic"],
|
|
80
115
|
bank_city: data["bank_city"],
|
|
116
|
+
bank_logo: BankLogo.from_api(data["bank_logo"]),
|
|
81
117
|
bank_code: data["bank_code"],
|
|
82
118
|
branch_code: data["branch_code"],
|
|
83
119
|
account_number: data["account_number"],
|
|
@@ -185,7 +221,7 @@ module IbanChecker
|
|
|
185
221
|
class BankRecord
|
|
186
222
|
ATTRIBUTES = %i[
|
|
187
223
|
bic bic8 bank_code country_code location_code branch_code
|
|
188
|
-
bank_name city country_name sepa type status
|
|
224
|
+
bank_name bank_logo city country_name sepa type status
|
|
189
225
|
].freeze
|
|
190
226
|
|
|
191
227
|
attr_reader(*ATTRIBUTES)
|
|
@@ -207,6 +243,7 @@ module IbanChecker
|
|
|
207
243
|
location_code: data["location_code"],
|
|
208
244
|
branch_code: data["branch_code"],
|
|
209
245
|
bank_name: data["bank_name"],
|
|
246
|
+
bank_logo: BankLogo.from_api(data["bank_logo"]),
|
|
210
247
|
city: data["city"],
|
|
211
248
|
country_name: data["country_name"],
|
|
212
249
|
sepa: data["sepa"],
|
data/lib/ibanchecker/version.rb
CHANGED