ibanomat 1.3.2 → 2.0.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/LICENSE +1 -1
- data/README.md +50 -36
- data/lib/ibanomat/client.rb +63 -25
- data/lib/ibanomat/version.rb +1 -1
- metadata +12 -75
- data/.gitignore +0 -19
- data/.rspec +0 -2
- data/.travis.yml +0 -11
- data/Gemfile +0 -4
- data/Rakefile +0 -6
- data/bin/console +0 -7
- data/ibanomat.gemspec +0 -29
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 736d1a8b735519b13b678bf10f86a72b81bc9f923de756e6966341ba2a1ae610
|
|
4
|
+
data.tar.gz: 4cdff4bea58bca485148548df6a37cbcd609ca1267cf4f03b8f6d62d630c9792
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1311ddc1ef6bf24e4b4d76b86975d272c1927de8a4b5d6eb9363058fd464c95ea512ad483274ac2e62e0fde9f7b4755be51a1cdb9786750da21f8025a6663411
|
|
7
|
+
data.tar.gz: 74b74c9d693c14ade12ff747b3c3a90be756dc1dfdd94300d336f4e29f3e3115dac3f8145c18dfeffa4a31bb0576540f0c1388b025884b4795216fb023d97ddf
|
data/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2013-
|
|
3
|
+
Copyright (c) 2013-2026 Georg Ledermann
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
6
|
this software and associated documentation files (the "Software"), to deal in
|
data/README.md
CHANGED
|
@@ -1,62 +1,76 @@
|
|
|
1
1
|
# IBANomat
|
|
2
2
|
|
|
3
|
-
[](http://badge.fury.io/rb/ibanomat)
|
|
6
|
-
[](https://gemnasium.com/ledermann/ibanomat)
|
|
3
|
+
[](https://github.com/ledermann/ibanomat/actions)
|
|
4
|
+
[](https://badge.fury.io/rb/ibanomat)
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
IBANomat is a Ruby wrapper for the [IBAN calculator of the German "Sparkasse"](https://www.sparkasse.de/pk/produkte/konten-und-karten/banking/iban-rechner.html). It calculates the IBAN for a German bank code ("Bankleitzahl") and bank account number ("Kontonummer"). The gem sends the data to the web service of the Sparkasse and returns the result.
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
**WARNING: I'm not affiliated in any way with the web service or the Sparkasse. The web service seems not to be official. Maybe it will be offline soon. I didn't find any terms of use on their website. Use this gem at your own risk!**
|
|
8
|
+
Warning: I am not affiliated with the Sparkasse. The web service is not official, and I found no terms of use for it. The Sparkasse can change or remove it at any time. Use this gem at your own risk.
|
|
12
9
|
|
|
13
10
|
## Requirements
|
|
14
11
|
|
|
15
|
-
Ruby
|
|
16
|
-
|
|
12
|
+
Ruby 3.3 or newer.
|
|
17
13
|
|
|
18
14
|
## Installation
|
|
19
15
|
|
|
20
|
-
Add this line to your application
|
|
16
|
+
Add this line to the Gemfile of your application:
|
|
21
17
|
|
|
22
|
-
|
|
18
|
+
```ruby
|
|
19
|
+
gem 'ibanomat'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Then run:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
bundle install
|
|
26
|
+
```
|
|
23
27
|
|
|
24
|
-
|
|
28
|
+
## Usage
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
```ruby
|
|
31
|
+
Ibanomat.find bank_code: '37040044', bank_account_number: '532013000'
|
|
32
|
+
# =>
|
|
33
|
+
# {
|
|
34
|
+
# bank_name: 'Commerzbank',
|
|
35
|
+
# bic: 'COBADEFFXXX',
|
|
36
|
+
# iban: 'DE89370400440532013000',
|
|
37
|
+
# bank_code: '37040044',
|
|
38
|
+
# bank_account_number: '0532013000',
|
|
39
|
+
# return_code: '00',
|
|
40
|
+
# message: 'Berechnung erfolgreich'
|
|
41
|
+
# }
|
|
42
|
+
```
|
|
27
43
|
|
|
28
|
-
|
|
44
|
+
If the `return_code` is not `'00'`, the web service cannot calculate the IBAN. In this case, `iban` is `nil` and `message` gives the reason in German.
|
|
29
45
|
|
|
30
|
-
|
|
46
|
+
`Ibanomat.find` raises these errors:
|
|
31
47
|
|
|
48
|
+
- `ArgumentError` if the bank code or the bank account number is missing.
|
|
49
|
+
- `Ibanomat::ResourceNotFoundError` if the web service returns HTTP 404.
|
|
50
|
+
- `Ibanomat::Error` if the web service returns another HTTP error or a response that is not JSON.
|
|
51
|
+
- `Timeout::Error` if the web service does not answer in 10 seconds.
|
|
32
52
|
|
|
33
|
-
##
|
|
53
|
+
## Development
|
|
34
54
|
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# {
|
|
39
|
-
# :bank_name => 'Commerzbank',
|
|
40
|
-
# :bic => 'COBADEFFXXX',
|
|
41
|
-
# :iban => 'DE89370400440532013000',
|
|
42
|
-
# :bank_code => '37040044',
|
|
43
|
-
# :bank_account_number => '0532013000',
|
|
44
|
-
# :return_code => '00'
|
|
45
|
-
# }
|
|
55
|
+
```sh
|
|
56
|
+
bundle install
|
|
57
|
+
bundle exec rspec
|
|
46
58
|
```
|
|
47
59
|
|
|
48
|
-
|
|
60
|
+
The default specs do not connect to the network. To test against the real web service, run:
|
|
49
61
|
|
|
62
|
+
```sh
|
|
63
|
+
LIVE=1 bundle exec rspec
|
|
64
|
+
```
|
|
50
65
|
|
|
51
66
|
## Contributing
|
|
52
67
|
|
|
53
|
-
1. Fork
|
|
54
|
-
2. Create
|
|
55
|
-
3. Commit your changes
|
|
56
|
-
4. Push
|
|
57
|
-
5.
|
|
58
|
-
|
|
68
|
+
1. Fork the repository.
|
|
69
|
+
2. Create a feature branch: `git checkout -b my-new-feature`
|
|
70
|
+
3. Commit your changes: `git commit -am 'Add some feature'`
|
|
71
|
+
4. Push the branch: `git push origin my-new-feature`
|
|
72
|
+
5. Open a pull request.
|
|
59
73
|
|
|
60
|
-
|
|
74
|
+
## Author
|
|
61
75
|
|
|
62
|
-
Copyright (c) 2013-
|
|
76
|
+
Copyright (c) 2013-2026 Georg Ledermann, released under the MIT license
|
data/lib/ibanomat/client.rb
CHANGED
|
@@ -2,36 +2,74 @@ require 'net/http'
|
|
|
2
2
|
require 'json'
|
|
3
3
|
|
|
4
4
|
module Ibanomat
|
|
5
|
-
|
|
5
|
+
# Inherits from RuntimeError to stay compatible with older versions
|
|
6
|
+
class Error < RuntimeError
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class ResourceNotFoundError < Error
|
|
10
|
+
end
|
|
6
11
|
|
|
7
|
-
URL = 'https://www.sparkasse.de/
|
|
12
|
+
URL = 'https://www.sparkasse.de/api/calculations/iban'.freeze
|
|
13
|
+
TIMEOUT = 10
|
|
8
14
|
|
|
9
15
|
def self.find(options)
|
|
10
|
-
raise ArgumentError
|
|
11
|
-
raise ArgumentError.new('Option :bank_code is missing!') if options[:bank_code].empty?
|
|
12
|
-
raise ArgumentError.new('Option :bank_account_number is missing!') if options[:bank_account_number].empty?
|
|
16
|
+
raise ArgumentError, 'Options must be a Hash!' unless options.is_a?(Hash)
|
|
13
17
|
|
|
18
|
+
bank_code = options[:bank_code].to_s.strip
|
|
19
|
+
bank_account_number = options[:bank_account_number].to_s.strip
|
|
20
|
+
raise ArgumentError, 'Option :bank_code is missing!' if bank_code.empty?
|
|
21
|
+
if bank_account_number.empty?
|
|
22
|
+
raise ArgumentError, 'Option :bank_account_number is missing!'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
response =
|
|
26
|
+
request(bankCode: bank_code, bankAccountNumber: bank_account_number)
|
|
27
|
+
|
|
28
|
+
case response
|
|
29
|
+
when Net::HTTPSuccess
|
|
30
|
+
parse(response.body)
|
|
31
|
+
when Net::HTTPNotFound
|
|
32
|
+
raise ResourceNotFoundError, "Web service not found: #{URL}"
|
|
33
|
+
else
|
|
34
|
+
raise Error, "Web service returned HTTP #{response.code}"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.request(payload)
|
|
14
39
|
uri = URI(URL)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
when Net::HTTPNotFound
|
|
32
|
-
raise ResourceNotFoundError
|
|
33
|
-
else
|
|
34
|
-
raise RuntimeError
|
|
40
|
+
|
|
41
|
+
Net::HTTP.start(
|
|
42
|
+
uri.host,
|
|
43
|
+
uri.port,
|
|
44
|
+
use_ssl: true,
|
|
45
|
+
open_timeout: TIMEOUT,
|
|
46
|
+
read_timeout: TIMEOUT,
|
|
47
|
+
) do |http|
|
|
48
|
+
http.post(
|
|
49
|
+
uri.path,
|
|
50
|
+
payload.to_json,
|
|
51
|
+
'Content-Type' => 'application/json',
|
|
52
|
+
'Accept' => 'application/json',
|
|
53
|
+
'User-Agent' => "ibanomat/#{VERSION}",
|
|
54
|
+
)
|
|
35
55
|
end
|
|
36
56
|
end
|
|
57
|
+
private_class_method :request
|
|
58
|
+
|
|
59
|
+
def self.parse(body)
|
|
60
|
+
hash = JSON.parse(body)
|
|
61
|
+
|
|
62
|
+
{
|
|
63
|
+
bank_name: hash['instituteName'],
|
|
64
|
+
bic: hash['bic'],
|
|
65
|
+
iban: hash['iban'],
|
|
66
|
+
bank_code: hash['bankCode'],
|
|
67
|
+
bank_account_number: hash['bankAccountNumber'],
|
|
68
|
+
return_code: hash['returnCode'],
|
|
69
|
+
message: hash['message'],
|
|
70
|
+
}
|
|
71
|
+
rescue JSON::ParserError
|
|
72
|
+
raise Error, 'Web service returned invalid JSON'
|
|
73
|
+
end
|
|
74
|
+
private_class_method :parse
|
|
37
75
|
end
|
data/lib/ibanomat/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,95 +1,33 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ibanomat
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Georg Ledermann
|
|
8
|
-
|
|
9
|
-
bindir: exe
|
|
8
|
+
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: bundler
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - ">="
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0'
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - ">="
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: rake
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - ">="
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - ">="
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rspec
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '3.0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '3.0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: webmock
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - ">="
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0'
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - ">="
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0'
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
69
12
|
description: 'Germany only: Bankleitzahl & Kontonummer => IBAN'
|
|
70
13
|
email:
|
|
71
|
-
-
|
|
14
|
+
- georg@ledermann.dev
|
|
72
15
|
executables: []
|
|
73
16
|
extensions: []
|
|
74
17
|
extra_rdoc_files: []
|
|
75
18
|
files:
|
|
76
|
-
- ".gitignore"
|
|
77
|
-
- ".rspec"
|
|
78
|
-
- ".travis.yml"
|
|
79
|
-
- Gemfile
|
|
80
19
|
- LICENSE
|
|
81
20
|
- README.md
|
|
82
|
-
- Rakefile
|
|
83
|
-
- bin/console
|
|
84
|
-
- ibanomat.gemspec
|
|
85
21
|
- lib/ibanomat.rb
|
|
86
22
|
- lib/ibanomat/client.rb
|
|
87
23
|
- lib/ibanomat/version.rb
|
|
88
|
-
homepage:
|
|
24
|
+
homepage: https://github.com/ledermann/ibanomat
|
|
89
25
|
licenses:
|
|
90
26
|
- MIT
|
|
91
|
-
metadata:
|
|
92
|
-
|
|
27
|
+
metadata:
|
|
28
|
+
source_code_uri: https://github.com/ledermann/ibanomat
|
|
29
|
+
changelog_uri: https://github.com/ledermann/ibanomat/releases
|
|
30
|
+
rubygems_mfa_required: 'true'
|
|
93
31
|
rdoc_options: []
|
|
94
32
|
require_paths:
|
|
95
33
|
- lib
|
|
@@ -97,15 +35,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
97
35
|
requirements:
|
|
98
36
|
- - ">="
|
|
99
37
|
- !ruby/object:Gem::Version
|
|
100
|
-
version:
|
|
38
|
+
version: '3.3'
|
|
101
39
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
40
|
requirements:
|
|
103
41
|
- - ">="
|
|
104
42
|
- !ruby/object:Gem::Version
|
|
105
43
|
version: '0'
|
|
106
44
|
requirements: []
|
|
107
|
-
rubygems_version:
|
|
108
|
-
signing_key:
|
|
45
|
+
rubygems_version: 4.0.24
|
|
109
46
|
specification_version: 4
|
|
110
47
|
summary: Wrapper for a web service to calculate the IBAN of german bank account numbers
|
|
111
48
|
test_files: []
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/bin/console
DELETED
data/ibanomat.gemspec
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require 'ibanomat/version'
|
|
5
|
-
|
|
6
|
-
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name = 'ibanomat'
|
|
8
|
-
spec.version = Ibanomat::VERSION
|
|
9
|
-
spec.authors = ['Georg Ledermann']
|
|
10
|
-
spec.email = ['mail@georg-ledermann.de']
|
|
11
|
-
spec.description = 'Germany only: Bankleitzahl & Kontonummer => IBAN'
|
|
12
|
-
spec.summary = 'Wrapper for a web service to calculate the IBAN of german bank account numbers'
|
|
13
|
-
spec.homepage = 'http://github.com/ledermann/ibanomat'
|
|
14
|
-
spec.license = 'MIT'
|
|
15
|
-
|
|
16
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
17
|
-
f.match(%r{^(test|spec|features)/})
|
|
18
|
-
end
|
|
19
|
-
spec.bindir = 'exe'
|
|
20
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
21
|
-
spec.require_paths = ['lib']
|
|
22
|
-
|
|
23
|
-
spec.required_ruby_version = '>= 2.0.0'
|
|
24
|
-
|
|
25
|
-
spec.add_development_dependency 'bundler'
|
|
26
|
-
spec.add_development_dependency 'rake'
|
|
27
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
28
|
-
spec.add_development_dependency 'webmock'
|
|
29
|
-
end
|