ibancom 0.0.8 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25b94a77a717ff4aa52de122a08578c9912180d10dfe76baa301d48bf7363028
4
- data.tar.gz: 689b1ac403436b3103790b16e9aee7c27dafa4895a0b233e6affaab51f3ddfee
3
+ metadata.gz: e59cb3b331969ed988a60ce1c2df37c0bd572ec76da3516daa8485918ea156b0
4
+ data.tar.gz: 8ae96791cf287f92c589d07c60270cb081908bcf262a707618847eec613f0ec2
5
5
  SHA512:
6
- metadata.gz: 47b14f2079f3cdfada534bea71f1750f821ccde622f9c0a5b73ac670ddc06277f22d67495825f64acc0a6e231560bdaedf18a557d29cde08bb78afa7d809eb64
7
- data.tar.gz: 8f683eb5a7a1e95bf1e9cbb4b9f9033a2eab4f499891ca3b44ef6dfaec5510a84fd0e9d387905a394e2b924185c39627f527c4b5738a2d47c0e3f04232d2585d
6
+ metadata.gz: 29fb3e3fac6917fbbfe48296884e93e7530cc0dc81962682acf4d52f67ee2e7d651156945f0b9cfcdc9e663fa8c203900b5d9de2bc6d80ba2aa9a16648981306
7
+ data.tar.gz: ec9eac65ef0b236859f30a2404c9c55fd1d434358d57f11c0fa3672201f8477ceb2ef4a3929f9109043b6bc839103f84e985445028fafa2a68ddeadec707b308
data/Gemfile.lock CHANGED
@@ -1,23 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ibancom (0.0.8)
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.8.1)
11
- public_suffix (>= 2.0.2, < 6.0)
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)
15
15
  rexml
16
16
  diff-lcs (1.5.0)
17
- faraday (2.5.2)
17
+ faraday (2.7.4)
18
18
  faraday-net_http (>= 2.0, < 3.1)
19
19
  ruby2_keywords (>= 0.0.4)
20
- faraday-net_http (3.0.0)
20
+ faraday-net_http (3.0.2)
21
21
  ffi (1.15.5)
22
22
  formatador (1.1.0)
23
23
  guard (2.18.0)
@@ -35,8 +35,8 @@ GEM
35
35
  guard-compat (~> 1.1)
36
36
  rspec (>= 2.99.0, < 4.0)
37
37
  hashdiff (1.0.1)
38
- json (2.6.2)
39
- listen (3.7.1)
38
+ json (2.6.3)
39
+ listen (3.8.0)
40
40
  rb-fsevent (~> 0.10, >= 0.10.3)
41
41
  rb-inotify (~> 0.9, >= 0.9.10)
42
42
  lumberjack (1.2.8)
@@ -46,63 +46,68 @@ GEM
46
46
  nenv (~> 0.1)
47
47
  shellany (~> 0.0)
48
48
  parallel (1.22.1)
49
- parser (3.1.2.1)
49
+ parser (3.2.1.1)
50
50
  ast (~> 2.4.1)
51
- pry (0.14.1)
51
+ pry (0.14.2)
52
52
  coderay (~> 1.1)
53
53
  method_source (~> 1.0)
54
- public_suffix (5.0.0)
54
+ public_suffix (5.1.1)
55
55
  rainbow (3.1.1)
56
56
  rake (12.3.3)
57
- rb-fsevent (0.11.1)
57
+ rb-fsevent (0.11.2)
58
58
  rb-inotify (0.10.1)
59
59
  ffi (~> 1.0)
60
- regexp_parser (2.5.0)
61
- rexml (3.2.5)
62
- rspec (3.11.0)
63
- rspec-core (~> 3.11.0)
64
- rspec-expectations (~> 3.11.0)
65
- rspec-mocks (~> 3.11.0)
66
- rspec-core (3.11.0)
67
- rspec-support (~> 3.11.0)
68
- rspec-expectations (3.11.0)
60
+ regexp_parser (2.7.0)
61
+ rexml (3.4.2)
62
+ rspec (3.12.0)
63
+ rspec-core (~> 3.12.0)
64
+ rspec-expectations (~> 3.12.0)
65
+ rspec-mocks (~> 3.12.0)
66
+ rspec-core (3.12.1)
67
+ rspec-support (~> 3.12.0)
68
+ rspec-expectations (3.12.2)
69
69
  diff-lcs (>= 1.2.0, < 2.0)
70
- rspec-support (~> 3.11.0)
71
- rspec-mocks (3.11.1)
70
+ rspec-support (~> 3.12.0)
71
+ rspec-mocks (3.12.4)
72
72
  diff-lcs (>= 1.2.0, < 2.0)
73
- rspec-support (~> 3.11.0)
74
- rspec-support (3.11.0)
75
- rubocop (1.35.1)
73
+ rspec-support (~> 3.12.0)
74
+ rspec-support (3.12.0)
75
+ rubocop (1.48.1)
76
76
  json (~> 2.3)
77
77
  parallel (~> 1.10)
78
- parser (>= 3.1.2.1)
78
+ parser (>= 3.2.0.0)
79
79
  rainbow (>= 2.2.2, < 4.0)
80
80
  regexp_parser (>= 1.8, < 3.0)
81
81
  rexml (>= 3.2.5, < 4.0)
82
- rubocop-ast (>= 1.20.1, < 2.0)
82
+ rubocop-ast (>= 1.26.0, < 2.0)
83
83
  ruby-progressbar (~> 1.7)
84
- unicode-display_width (>= 1.4.0, < 3.0)
85
- rubocop-ast (1.21.0)
86
- parser (>= 3.1.1.0)
87
- rubocop-performance (1.14.2)
84
+ unicode-display_width (>= 2.4.0, < 3.0)
85
+ rubocop-ast (1.27.0)
86
+ parser (>= 3.2.1.0)
87
+ rubocop-capybara (2.17.1)
88
+ rubocop (~> 1.41)
89
+ rubocop-performance (1.16.0)
88
90
  rubocop (>= 1.7.0, < 2.0)
89
91
  rubocop-ast (>= 0.4.0)
90
92
  rubocop-rake (0.6.0)
91
93
  rubocop (~> 1.0)
92
- rubocop-rspec (2.11.1)
93
- rubocop (~> 1.19)
94
- ruby-progressbar (1.11.0)
94
+ rubocop-rspec (2.19.0)
95
+ rubocop (~> 1.33)
96
+ rubocop-capybara (~> 2.17)
97
+ ruby-progressbar (1.13.0)
95
98
  ruby2_keywords (0.0.5)
96
99
  shellany (0.0.1)
97
- test-prof (1.0.9)
100
+ test-prof (1.2.1)
98
101
  thor (1.2.1)
99
- unicode-display_width (2.2.0)
102
+ unicode-display_width (2.4.2)
100
103
  webmock (3.18.1)
101
104
  addressable (>= 2.8.0)
102
105
  crack (>= 0.3.2)
103
106
  hashdiff (>= 0.4.0, < 2.0.0)
104
107
 
105
108
  PLATFORMS
109
+ arm64-darwin-22
110
+ arm64-darwin-25
106
111
  x86_64-linux
107
112
 
108
113
  DEPENDENCIES
@@ -119,4 +124,4 @@ DEPENDENCIES
119
124
  webmock (~> 3.0)
120
125
 
121
126
  BUNDLED WITH
122
- 2.3.3
127
+ 2.4.1
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
- git tag vx.x.x main
90
- git push origin vx.x.x
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"
@@ -8,6 +8,7 @@ module Ibancom
8
8
  "001" => "IBAN Check digit is correct",
9
9
  "002" => "Account Number check digit is correct",
10
10
  "003" => "IBAN Length is correct",
11
+ "004" => "Account Number check digit is not performed for this bank or branch",
11
12
  "005" => "IBAN structure is correct",
12
13
  "006" => "IBAN does not contain illegal characters",
13
14
  "007" => "Country supports IBAN standard",
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ibancom
4
+ module Resources
5
+ module SCAN
6
+ class Account < Base
7
+ attr_accessor :sortcode,
8
+ :account,
9
+ :iban
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ibancom
4
+ module Resources
5
+ module SCAN
6
+ class Bank < Base
7
+ attr_accessor :bic,
8
+ :branch,
9
+ :bank,
10
+ :address,
11
+ :city,
12
+ :zip,
13
+ :phone,
14
+ :country
15
+ end
16
+ end
17
+ end
18
+ end
@@ -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,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ibancom
4
+ module Resources
5
+ module SCAN
6
+ class Scheme < Base
7
+ attr_accessor :code,
8
+ :supported
9
+
10
+ def supported?
11
+ supported == "YES"
12
+ end
13
+ end
14
+ end
15
+ end
16
+ 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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ibancom
4
- VERSION = "0.0.8"
4
+ VERSION = "0.0.11"
5
5
  end
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.8
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: 2022-09-22 00:00:00.000000000 Z
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.3.7
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: []