banktools-de 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -2
- data/banktools-de.gemspec +5 -4
- data/lib/banktools-de/iban_bic.rb +40 -0
- data/lib/banktools-de/version.rb +1 -1
- data/lib/banktools-de.rb +1 -0
- data/spec/iban_bic_spec.rb +40 -0
- metadata +36 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59b514513c7f20f8507e5c1f7680f8f7b134e6c5
|
4
|
+
data.tar.gz: a45d5a67dd11410894a9ee0f41ace47af66a534c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4daaee0d8bacc9fb0db4cb6b002a77c3930a650c3e0146b48d20e310d8baf4ae1a095bbcae59eb295d44844c6b7b1d562ecf9c70cbdd49ffa2655ac8c7e70f24
|
7
|
+
data.tar.gz: cc6cae467328770ed2af664596920f91c4bf47830d48105a7ce40f0d4a2024514c13abef83528e2fb03e85dd4fb2aeed50bc35d485d3cf580b091439a2e12897
|
data/README.md
CHANGED
@@ -36,6 +36,12 @@ If we got anything wrong, please file an issue or contribute a fix yourself.
|
|
36
36
|
bad_account.valid? # => false
|
37
37
|
bad_account.errors # => [:too_short]
|
38
38
|
|
39
|
+
# Convert BLZ and account number to IBAN/BIC
|
40
|
+
|
41
|
+
result = BankTools::DE::IbanBicConverter.run(blz: "37040044", account: "532013000")
|
42
|
+
result.iban # => "DE89370400440532013000"
|
43
|
+
result.bic # => "COBADEFFXXX"
|
44
|
+
# Or raises an exception.
|
39
45
|
|
40
46
|
## Tests
|
41
47
|
|
@@ -92,9 +98,15 @@ Or install it yourself as:
|
|
92
98
|
* [Konto API online service](https://www.kontoapi.de)
|
93
99
|
|
94
100
|
|
95
|
-
## Credits
|
101
|
+
## Credits
|
102
|
+
|
103
|
+
* [Henrik Nyh](http://henrik.nyh.se)
|
104
|
+
* Tomas Skogberg
|
105
|
+
* Victor Arias
|
106
|
+
|
107
|
+
## License
|
96
108
|
|
97
|
-
|
109
|
+
MIT license:
|
98
110
|
|
99
111
|
Copyright (c) 2014 Barsoom AB
|
100
112
|
|
data/banktools-de.gemspec
CHANGED
@@ -6,9 +6,9 @@ require 'banktools-de/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "banktools-de"
|
8
8
|
spec.version = BankTools::DE::VERSION
|
9
|
-
spec.authors = ["Henrik Nyh"]
|
10
|
-
spec.email = ["henrik@nyh.se"]
|
11
|
-
spec.summary = %q{Validate and normalize German Bankleitzahl (BLZ) and bank account numbers.}
|
9
|
+
spec.authors = [ "Henrik Nyh" ]
|
10
|
+
spec.email = [ "henrik@nyh.se" ]
|
11
|
+
spec.summary = %q{Validate and normalize German Bankleitzahl (BLZ) and bank account numbers. Also it converts BLZ to IBAN/BIC.}
|
12
12
|
spec.homepage = ""
|
13
13
|
spec.license = "MIT"
|
14
14
|
|
@@ -17,7 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_dependency "attr_extras", "
|
20
|
+
spec.add_dependency "attr_extras", ">= 2.2.3"
|
21
|
+
spec.add_dependency "ibanomat" # Convert BLZ to IBAN/BIC
|
21
22
|
spec.add_development_dependency "bundler", "~> 1.5"
|
22
23
|
spec.add_development_dependency "rake"
|
23
24
|
spec.add_development_dependency "rspec"
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "ibanomat"
|
2
|
+
require "attr_extras"
|
3
|
+
|
4
|
+
class BankTools::DE::IbanBicConverter
|
5
|
+
class CouldNotConvertError < StandardError; end
|
6
|
+
class ServiceUnavailable < StandardError; end
|
7
|
+
class UnknownError < StandardError; end
|
8
|
+
|
9
|
+
class IbanBic
|
10
|
+
vattr_initialize :iban, :bic
|
11
|
+
end
|
12
|
+
|
13
|
+
method_object :run,
|
14
|
+
[ :blz!, :account! ]
|
15
|
+
|
16
|
+
def run
|
17
|
+
account_data = get_account_data
|
18
|
+
build_result(account_data)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def get_account_data
|
24
|
+
Ibanomat.find(bank_code: blz, bank_account_number: account)
|
25
|
+
rescue RestClient::RequestTimeout
|
26
|
+
raise ServiceUnavailable
|
27
|
+
rescue
|
28
|
+
raise UnknownError
|
29
|
+
end
|
30
|
+
|
31
|
+
def build_result(account_data)
|
32
|
+
# Non-"00" values represent an Ibanomat warning or error.
|
33
|
+
return_code = account_data.fetch(:return_code)
|
34
|
+
raise CouldNotConvertError unless return_code == "00"
|
35
|
+
|
36
|
+
iban = account_data.fetch(:iban)
|
37
|
+
bic = account_data.fetch(:bic)
|
38
|
+
IbanBic.new(iban, bic)
|
39
|
+
end
|
40
|
+
end
|
data/lib/banktools-de/version.rb
CHANGED
data/lib/banktools-de.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "banktools-de/iban_bic"
|
3
|
+
|
4
|
+
describe BankTools::DE::IbanBicConverter, ".run" do
|
5
|
+
let(:blz) { "abc" }
|
6
|
+
let(:account) { "def" }
|
7
|
+
|
8
|
+
it "returns the BIC and IBAN" do
|
9
|
+
allow(Ibanomat).to receive(:find).and_return(iban: "some iban", bic: "some bic", return_code: "00")
|
10
|
+
|
11
|
+
actual = BankTools::DE::IbanBicConverter.run(blz: blz, account: account)
|
12
|
+
|
13
|
+
expect(actual.iban).to eq("some iban")
|
14
|
+
expect(actual.bic).to eq("some bic")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "raises CouldNotConvertError on conversion errors" do
|
18
|
+
allow(Ibanomat).to receive(:find).and_return(return_code: "1")
|
19
|
+
|
20
|
+
expect {
|
21
|
+
BankTools::DE::IbanBicConverter.run(blz: blz, account: account)
|
22
|
+
}.to raise_error(BankTools::DE::IbanBicConverter::CouldNotConvertError)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "raises ServiceUnavailable when the service is down" do
|
26
|
+
allow(Ibanomat).to receive(:find).and_raise(RestClient::RequestTimeout)
|
27
|
+
|
28
|
+
expect {
|
29
|
+
BankTools::DE::IbanBicConverter.run(blz: blz, account: account)
|
30
|
+
}.to raise_error(BankTools::DE::IbanBicConverter::ServiceUnavailable)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "raises UnknownError on other errors" do
|
34
|
+
allow(Ibanomat).to receive(:find).and_raise("unknown error")
|
35
|
+
|
36
|
+
expect {
|
37
|
+
BankTools::DE::IbanBicConverter.run(blz: blz, account: account)
|
38
|
+
}.to raise_error(BankTools::DE::IbanBicConverter::UnknownError)
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,83 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: banktools-de
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrik Nyh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: attr_extras
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.2.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.2.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ibanomat
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - ~>
|
45
|
+
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: '1.5'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - ~>
|
52
|
+
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '1.5'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: creek
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- -
|
87
|
+
- - ">="
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: '0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- -
|
94
|
+
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
description:
|
@@ -87,7 +101,7 @@ executables: []
|
|
87
101
|
extensions: []
|
88
102
|
extra_rdoc_files: []
|
89
103
|
files:
|
90
|
-
- .gitignore
|
104
|
+
- ".gitignore"
|
91
105
|
- Gemfile
|
92
106
|
- README.md
|
93
107
|
- Rakefile
|
@@ -98,10 +112,12 @@ files:
|
|
98
112
|
- lib/banktools-de/blz.rb
|
99
113
|
- lib/banktools-de/blz_downloader.rb
|
100
114
|
- lib/banktools-de/errors.rb
|
115
|
+
- lib/banktools-de/iban_bic.rb
|
101
116
|
- lib/banktools-de/version.rb
|
102
117
|
- spec/account_spec.rb
|
103
118
|
- spec/banktools_spec.rb
|
104
119
|
- spec/blz_spec.rb
|
120
|
+
- spec/iban_bic_spec.rb
|
105
121
|
- spec/spec_helper.rb
|
106
122
|
homepage: ''
|
107
123
|
licenses:
|
@@ -113,22 +129,24 @@ require_paths:
|
|
113
129
|
- lib
|
114
130
|
required_ruby_version: !ruby/object:Gem::Requirement
|
115
131
|
requirements:
|
116
|
-
- -
|
132
|
+
- - ">="
|
117
133
|
- !ruby/object:Gem::Version
|
118
134
|
version: '0'
|
119
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
136
|
requirements:
|
121
|
-
- -
|
137
|
+
- - ">="
|
122
138
|
- !ruby/object:Gem::Version
|
123
139
|
version: '0'
|
124
140
|
requirements: []
|
125
141
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.2.
|
142
|
+
rubygems_version: 2.2.2
|
127
143
|
signing_key:
|
128
144
|
specification_version: 4
|
129
145
|
summary: Validate and normalize German Bankleitzahl (BLZ) and bank account numbers.
|
146
|
+
Also it converts BLZ to IBAN/BIC.
|
130
147
|
test_files:
|
131
148
|
- spec/account_spec.rb
|
132
149
|
- spec/banktools_spec.rb
|
133
150
|
- spec/blz_spec.rb
|
151
|
+
- spec/iban_bic_spec.rb
|
134
152
|
- spec/spec_helper.rb
|