ibancom 0.0.10 → 0.0.11
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/Gemfile.lock +7 -5
- data/README.md +45 -2
- data/lib/ibancom/api/validation_service.rb +5 -0
- data/lib/ibancom/resources/base.rb +7 -0
- data/lib/ibancom/resources/scan/account.rb +13 -0
- data/lib/ibancom/resources/scan/bank.rb +18 -0
- data/lib/ibancom/resources/scan/check.rb +30 -0
- data/lib/ibancom/resources/scan/checks.rb +20 -0
- data/lib/ibancom/resources/scan/scheme.rb +16 -0
- data/lib/ibancom/resources/scan/schemes.rb +19 -0
- data/lib/ibancom/resources/scan/validation.rb +42 -0
- data/lib/ibancom/version.rb +1 -1
- metadata +10 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e59cb3b331969ed988a60ce1c2df37c0bd572ec76da3516daa8485918ea156b0
|
|
4
|
+
data.tar.gz: 8ae96791cf287f92c589d07c60270cb081908bcf262a707618847eec613f0ec2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 29fb3e3fac6917fbbfe48296884e93e7530cc0dc81962682acf4d52f67ee2e7d651156945f0b9cfcdc9e663fa8c203900b5d9de2bc6d80ba2aa9a16648981306
|
|
7
|
+
data.tar.gz: ec9eac65ef0b236859f30a2404c9c55fd1d434358d57f11c0fa3672201f8477ceb2ef4a3929f9109043b6bc839103f84e985445028fafa2a68ddeadec707b308
|
data/Gemfile.lock
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
ibancom (0.0.
|
|
4
|
+
ibancom (0.0.11)
|
|
5
5
|
faraday (>= 0.15)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
addressable (2.
|
|
11
|
-
public_suffix (>= 2.0.2, <
|
|
10
|
+
addressable (2.9.0)
|
|
11
|
+
public_suffix (>= 2.0.2, < 8.0)
|
|
12
12
|
ast (2.4.2)
|
|
13
13
|
coderay (1.1.3)
|
|
14
14
|
crack (0.4.5)
|
|
@@ -51,14 +51,14 @@ GEM
|
|
|
51
51
|
pry (0.14.2)
|
|
52
52
|
coderay (~> 1.1)
|
|
53
53
|
method_source (~> 1.0)
|
|
54
|
-
public_suffix (5.
|
|
54
|
+
public_suffix (5.1.1)
|
|
55
55
|
rainbow (3.1.1)
|
|
56
56
|
rake (12.3.3)
|
|
57
57
|
rb-fsevent (0.11.2)
|
|
58
58
|
rb-inotify (0.10.1)
|
|
59
59
|
ffi (~> 1.0)
|
|
60
60
|
regexp_parser (2.7.0)
|
|
61
|
-
rexml (3.2
|
|
61
|
+
rexml (3.4.2)
|
|
62
62
|
rspec (3.12.0)
|
|
63
63
|
rspec-core (~> 3.12.0)
|
|
64
64
|
rspec-expectations (~> 3.12.0)
|
|
@@ -106,6 +106,8 @@ GEM
|
|
|
106
106
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
107
107
|
|
|
108
108
|
PLATFORMS
|
|
109
|
+
arm64-darwin-22
|
|
110
|
+
arm64-darwin-25
|
|
109
111
|
x86_64-linux
|
|
110
112
|
|
|
111
113
|
DEPENDENCIES
|
data/README.md
CHANGED
|
@@ -25,6 +25,7 @@ Or install it yourself as:
|
|
|
25
25
|
This gem provides support for the following APIs:
|
|
26
26
|
|
|
27
27
|
- Validation API v4
|
|
28
|
+
- Sortware API v4
|
|
28
29
|
|
|
29
30
|
## Usage
|
|
30
31
|
|
|
@@ -79,6 +80,44 @@ iban.failed_checks
|
|
|
79
80
|
# #<Ibancom::Resources::IBAN::Check:0x00007f384a576cf8 @code="203", @message="IBAN Length is not correct. Spain IBAN must be 24 characters long.", @response=nil, @type=:length>]
|
|
80
81
|
```
|
|
81
82
|
|
|
83
|
+
You can also validate United Kingdom Sort Code and Account Numbers:
|
|
84
|
+
|
|
85
|
+
```rb
|
|
86
|
+
scan = client.validations.validate_scan("200415", "38290008")
|
|
87
|
+
scan.valid? # true
|
|
88
|
+
|
|
89
|
+
# What is the bank/branch associated to this account?
|
|
90
|
+
bank = scan.bank # <Ibancom::Resources::SCAN::Bank:0x0000000107c0fc80 ...
|
|
91
|
+
bank.bank # "BARCLAYS BANK UK PLC"
|
|
92
|
+
bank.bic # "BUKBGB22XXX"
|
|
93
|
+
bank.branch # "BARCLAYBANK B'CARD N'PTON"
|
|
94
|
+
bank.address # "Dept AC Barclaycard House "
|
|
95
|
+
bank.city # "Northampton"
|
|
96
|
+
bank.zip # "NN4 7SG"
|
|
97
|
+
bank.phone # "01604 234234"
|
|
98
|
+
bank.country # "GB"
|
|
99
|
+
|
|
100
|
+
# What payment schemes does it support?
|
|
101
|
+
scan.supported_schemes
|
|
102
|
+
#[#<Ibancom::Resources::SCAN::Scheme:0x0000000107c0df70 @code=:FPS_PAYMENTS, @response=nil, @supported="YES">,
|
|
103
|
+
# #<Ibancom::Resources::SCAN::Scheme:0x0000000107c0def8 @code=:CHAPS, @response=nil, @supported="YES">,
|
|
104
|
+
# #<Ibancom::Resources::SCAN::Scheme:0x0000000107c0de80 @code=:BACS, @response=nil, @supported="YES">,
|
|
105
|
+
# #<Ibancom::Resources::SCAN::Scheme:0x0000000107c0de08 @code=:CCC_PAYMENTS, @response=nil, @supported="YES">]
|
|
106
|
+
|
|
107
|
+
# Does the SCAN supports faster payments?
|
|
108
|
+
scan.supported_scheme?(:FPS_PAYMENTS) # true
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
In the same way as with the IBAN, when the SCAN is not valid the failed checks are available for inspection:
|
|
112
|
+
|
|
113
|
+
```rb
|
|
114
|
+
scan = client.validations.validate_scan("000001", "00000002")
|
|
115
|
+
scan.valid? # false
|
|
116
|
+
scan.failed_checks
|
|
117
|
+
#[#<Ibancom::Resources::SCAN::Check:0x00000001088debf0 @code="202", @message="Sort Code not found in bank directory",
|
|
118
|
+
# @response=nil, @type=:length>]
|
|
119
|
+
```
|
|
120
|
+
|
|
82
121
|
## Development
|
|
83
122
|
|
|
84
123
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
@@ -86,8 +125,12 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
|
86
125
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then tag and push the new version:
|
|
87
126
|
|
|
88
127
|
```git
|
|
89
|
-
|
|
90
|
-
git
|
|
128
|
+
bundle install
|
|
129
|
+
git add .
|
|
130
|
+
git commit -m 'feat(release): Bump to vX.X.X'
|
|
131
|
+
git push
|
|
132
|
+
git tag vX.X.X main
|
|
133
|
+
git push origin vX.X.X
|
|
91
134
|
```
|
|
92
135
|
|
|
93
136
|
The tagging will trigger the GitHub action defined in `release.yml`, pushing the gem to [rubygems.org](https://rubygems.org).
|
|
@@ -7,6 +7,11 @@ module Ibancom
|
|
|
7
7
|
response = client.post("/v4/iban/", { iban: iban, sci: 1 })
|
|
8
8
|
Resources::IBAN::Validation.new(response, response.body)
|
|
9
9
|
end
|
|
10
|
+
|
|
11
|
+
def validate_scan(sort_code, account_number)
|
|
12
|
+
response = client.post("/v4/sort/", { sortcode: sort_code, account: account_number })
|
|
13
|
+
Resources::SCAN::Validation.new(response, response.body)
|
|
14
|
+
end
|
|
10
15
|
end
|
|
11
16
|
end
|
|
12
17
|
end
|
|
@@ -31,3 +31,10 @@ require_relative "iban/checks"
|
|
|
31
31
|
require_relative "iban/check"
|
|
32
32
|
require_relative "iban/schemes"
|
|
33
33
|
require_relative "iban/scheme"
|
|
34
|
+
require_relative "scan/validation"
|
|
35
|
+
require_relative "scan/bank"
|
|
36
|
+
require_relative "scan/account"
|
|
37
|
+
require_relative "scan/checks"
|
|
38
|
+
require_relative "scan/check"
|
|
39
|
+
require_relative "scan/schemes"
|
|
40
|
+
require_relative "scan/scheme"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ibancom
|
|
4
|
+
module Resources
|
|
5
|
+
module SCAN
|
|
6
|
+
class Check < Base
|
|
7
|
+
PASSED_MESSAGES = {
|
|
8
|
+
"001" => "Modulus Success: Check digit is valid",
|
|
9
|
+
"002" => "Sort Code found in bank directory",
|
|
10
|
+
"006" => "Sort Code does not contain illegal characters",
|
|
11
|
+
"007" => "Account Number does not contain illegal characters",
|
|
12
|
+
"008" => "Sort Code length is correct",
|
|
13
|
+
"009" => "Account Number length is correct",
|
|
14
|
+
}.freeze
|
|
15
|
+
|
|
16
|
+
attr_accessor :type,
|
|
17
|
+
:code,
|
|
18
|
+
:message
|
|
19
|
+
|
|
20
|
+
def passed?
|
|
21
|
+
PASSED_MESSAGES[code] == message
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def failed?
|
|
25
|
+
!passed?
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ibancom
|
|
4
|
+
module Resources
|
|
5
|
+
module SCAN
|
|
6
|
+
class Checks < Collection
|
|
7
|
+
def initialize(response, attributes_collection)
|
|
8
|
+
parsed = attributes_collection.map do |check_attributes|
|
|
9
|
+
{
|
|
10
|
+
type: check_attributes[0],
|
|
11
|
+
code: check_attributes[1][:code],
|
|
12
|
+
message: check_attributes[1][:message],
|
|
13
|
+
}
|
|
14
|
+
end
|
|
15
|
+
super(response, Check, parsed)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ibancom
|
|
4
|
+
module Resources
|
|
5
|
+
module SCAN
|
|
6
|
+
class Schemes < Collection
|
|
7
|
+
def initialize(response, attributes_collection)
|
|
8
|
+
parsed = attributes_collection.map do |attributes|
|
|
9
|
+
{
|
|
10
|
+
code: attributes[0],
|
|
11
|
+
supported: attributes[1],
|
|
12
|
+
}
|
|
13
|
+
end
|
|
14
|
+
super(response, Scheme, parsed)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ibancom
|
|
4
|
+
module Resources
|
|
5
|
+
module SCAN
|
|
6
|
+
class Validation < Base
|
|
7
|
+
attr_reader :bank,
|
|
8
|
+
:account,
|
|
9
|
+
:checks,
|
|
10
|
+
:schemes
|
|
11
|
+
|
|
12
|
+
def initialize(response, attributes = {})
|
|
13
|
+
super(response, attributes)
|
|
14
|
+
@bank = Bank.new(response, attributes[:bank_data])
|
|
15
|
+
@account = Account.new(response, attributes[:account_data])
|
|
16
|
+
@checks = Checks.new(response, attributes[:validations])
|
|
17
|
+
@schemes = Schemes.new(response, attributes[:payment_schemes])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def valid?
|
|
21
|
+
checks.all?(&:passed?)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def failed_checks
|
|
25
|
+
checks.select(&:failed?)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def supported_schemes
|
|
29
|
+
schemes.select(&:supported?)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def supported_scheme?(code)
|
|
33
|
+
scheme = supported_schemes.find { |supported| supported.code == code }
|
|
34
|
+
|
|
35
|
+
return false if scheme.nil?
|
|
36
|
+
|
|
37
|
+
scheme.supported?
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
data/lib/ibancom/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ibancom
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aitor García Rey
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: faraday
|
|
@@ -198,6 +197,13 @@ files:
|
|
|
198
197
|
- lib/ibancom/resources/iban/scheme.rb
|
|
199
198
|
- lib/ibancom/resources/iban/schemes.rb
|
|
200
199
|
- lib/ibancom/resources/iban/validation.rb
|
|
200
|
+
- lib/ibancom/resources/scan/account.rb
|
|
201
|
+
- lib/ibancom/resources/scan/bank.rb
|
|
202
|
+
- lib/ibancom/resources/scan/check.rb
|
|
203
|
+
- lib/ibancom/resources/scan/checks.rb
|
|
204
|
+
- lib/ibancom/resources/scan/scheme.rb
|
|
205
|
+
- lib/ibancom/resources/scan/schemes.rb
|
|
206
|
+
- lib/ibancom/resources/scan/validation.rb
|
|
201
207
|
- lib/ibancom/version.rb
|
|
202
208
|
- sig/ibancom.rbs
|
|
203
209
|
homepage: https://github.com/devengoapp/ibancom-ruby
|
|
@@ -207,7 +213,6 @@ metadata:
|
|
|
207
213
|
homepage_uri: https://github.com/devengoapp/ibancom-ruby
|
|
208
214
|
source_code_uri: https://github.com/devengoapp/ibancom-ruby
|
|
209
215
|
rubygems_mfa_required: 'true'
|
|
210
|
-
post_install_message:
|
|
211
216
|
rdoc_options: []
|
|
212
217
|
require_paths:
|
|
213
218
|
- lib
|
|
@@ -222,8 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
222
227
|
- !ruby/object:Gem::Version
|
|
223
228
|
version: '0'
|
|
224
229
|
requirements: []
|
|
225
|
-
rubygems_version: 3.
|
|
226
|
-
signing_key:
|
|
230
|
+
rubygems_version: 3.6.9
|
|
227
231
|
specification_version: 4
|
|
228
232
|
summary: Ruby client for iban.com APIs
|
|
229
233
|
test_files: []
|