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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90e8170825a2cc1b8e72b44509684ff3bb99776a042c12944533cb9e6255afae
4
- data.tar.gz: '0799228435f1ddb152efc9f18ebfa7a99418cc835e1d346c9023fcb150043087'
3
+ metadata.gz: 736d1a8b735519b13b678bf10f86a72b81bc9f923de756e6966341ba2a1ae610
4
+ data.tar.gz: 4cdff4bea58bca485148548df6a37cbcd609ca1267cf4f03b8f6d62d630c9792
5
5
  SHA512:
6
- metadata.gz: f963a12bb3bf72fbdf905077ff81512b2ad8bdba17597c3b5f01319eba05754720e8925a6d0fcb998b28beac8a735c589e180f37d8a6e6daccda945343d4ce65
7
- data.tar.gz: 1e09e585fab50a9c02b80e14ef99674002fd8a10d06dde9ec75cee1a196860c1cfec6828daf920f603a66378b6c536515e9ee12be590f80ecd71fa441b1efae4
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-2019 Georg Ledermann
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
- [![Build Status](https://secure.travis-ci.org/ledermann/ibanomat.svg)](http://travis-ci.org/ledermann/ibanomat)
4
- [![Code Climate](https://codeclimate.com/github/ledermann/ibanomat.svg)](https://codeclimate.com/github/ledermann/ibanomat)
5
- [![Gem Version](https://badge.fury.io/rb/ibanomat.svg)](http://badge.fury.io/rb/ibanomat)
6
- [![Dependency Status](https://gemnasium.com/ledermann/ibanomat.svg)](https://gemnasium.com/ledermann/ibanomat)
3
+ [![Build Status](https://github.com/ledermann/ibanomat/actions/workflows/ci.yml/badge.svg)](https://github.com/ledermann/ibanomat/actions)
4
+ [![Gem Version](https://badge.fury.io/rb/ibanomat.svg)](https://badge.fury.io/rb/ibanomat)
7
5
 
8
- The gem is a Ruby wrapper for a [web service of the german "Sparkasse"](https://www.sparkasse.de/unsere-loesungen/privatkunden/rund-ums-konto/iban-rechner.html). It calculates the **IBAN** for a given bank code (in German "Bankleitzahl") and bank account number ("Kontonummer"). Behind the scenes the web service returns JSON ([Example here](https://www.sparkasse.de/bin/servlets/sparkasse/iban?a=0532013000&b=37040044))
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 2.0.0 or newer.
16
-
12
+ Ruby 3.3 or newer.
17
13
 
18
14
  ## Installation
19
15
 
20
- Add this line to your application's Gemfile:
16
+ Add this line to the Gemfile of your application:
21
17
 
22
- gem 'ibanomat'
18
+ ```ruby
19
+ gem 'ibanomat'
20
+ ```
21
+
22
+ Then run:
23
+
24
+ ```sh
25
+ bundle install
26
+ ```
23
27
 
24
- And then execute:
28
+ ## Usage
25
29
 
26
- $ bundle
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
- Or install it yourself as:
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
- $ gem install ibanomat
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
- ## Usage
53
+ ## Development
34
54
 
35
- ```ruby
36
- Ibanomat.find :bank_code => '37040044', :bank_account_number => '532013000'
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
- A `return_code` other than '00' indicates a warning or error.
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 it
54
- 2. Create your feature branch (`git checkout -b my-new-feature`)
55
- 3. Commit your changes (`git commit -am 'Add some feature'`)
56
- 4. Push to the branch (`git push origin my-new-feature`)
57
- 5. Create new Pull Request
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
- # Author
74
+ ## Author
61
75
 
62
- Copyright (c) 2013-2019 Georg Ledermann, released under the MIT license
76
+ Copyright (c) 2013-2026 Georg Ledermann, released under the MIT license
@@ -2,36 +2,74 @@ require 'net/http'
2
2
  require 'json'
3
3
 
4
4
  module Ibanomat
5
- class ResourceNotFoundError < RuntimeError; end
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/bin/servlets/sparkasse/iban'
12
+ URL = 'https://www.sparkasse.de/api/calculations/iban'.freeze
13
+ TIMEOUT = 10
8
14
 
9
15
  def self.find(options)
10
- raise ArgumentError.new unless options.is_a?(Hash)
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
- params = { 'b' => options[:bank_code],
16
- 'a' => options[:bank_account_number]
17
- }
18
- uri.query = URI.encode_www_form(params)
19
-
20
- case response = Net::HTTP.get_response(uri)
21
- when Net::HTTPSuccess
22
- hash = JSON.parse(response.body)
23
-
24
- { :bank_name => hash['Institutsname'],
25
- :bic => hash['BIC'],
26
- :iban => hash['IBAN'],
27
- :bank_code => hash['BLZ'],
28
- :bank_account_number => hash['KtoNr'],
29
- :return_code => hash['RetCode']
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
@@ -1,3 +1,3 @@
1
1
  module Ibanomat
2
- VERSION = '1.3.2'
2
+ VERSION = '2.0.0'
3
3
  end
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: 1.3.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georg Ledermann
8
- autorequire:
9
- bindir: exe
8
+ bindir: bin
10
9
  cert_chain: []
11
- date: 2019-08-25 00:00:00.000000000 Z
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
- - mail@georg-ledermann.de
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: http://github.com/ledermann/ibanomat
24
+ homepage: https://github.com/ledermann/ibanomat
89
25
  licenses:
90
26
  - MIT
91
- metadata: {}
92
- post_install_message:
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: 2.0.0
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: 3.0.6
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
@@ -1,19 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- coverage
6
- InstalledFiles
7
- lib/bundler/man
8
- pkg
9
- rdoc
10
- spec/reports
11
- test/tmp
12
- test/version_tmp
13
- tmp
14
- Gemfile.lock
15
-
16
- # YARD artifacts
17
- .yardoc
18
- _yardoc
19
- doc/
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --format progress
data/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.0
4
- - 2.1
5
- - 2.2
6
- - 2.3
7
- - 2.4
8
- - 2.5
9
- - 2.6
10
- before_install: gem update bundler
11
- sudo: false
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in ibanomat.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
data/bin/console DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'ibanomat'
5
-
6
- require 'irb'
7
- IRB.start(__FILE__)
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