hbci 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.rubocop.yml +26 -0
  4. data/.rubocop_todo.yml +26 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +1 -0
  7. data/Gemfile +5 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +107 -0
  10. data/Rakefile +8 -0
  11. data/bin/console +15 -0
  12. data/bin/setup +7 -0
  13. data/examples/credentials.rb +62 -0
  14. data/examples/get_accounts.rb +11 -0
  15. data/examples/get_balance.rb +8 -0
  16. data/examples/get_system_id.rb +6 -0
  17. data/examples/get_transactions.rb +15 -0
  18. data/hbci.gemspec +36 -0
  19. data/lib/development_profiler.rb +26 -0
  20. data/lib/hbci.rb +66 -0
  21. data/lib/hbci/connector.rb +33 -0
  22. data/lib/hbci/dialog.rb +77 -0
  23. data/lib/hbci/element_group.rb +93 -0
  24. data/lib/hbci/element_groups/generated_element_groups.rb +969 -0
  25. data/lib/hbci/element_groups/segment_head.rb +12 -0
  26. data/lib/hbci/element_groups/unknown.rb +11 -0
  27. data/lib/hbci/element_unparser.rb +21 -0
  28. data/lib/hbci/message.rb +47 -0
  29. data/lib/hbci/message_factory.rb +17 -0
  30. data/lib/hbci/parser.rb +114 -0
  31. data/lib/hbci/request.rb +32 -0
  32. data/lib/hbci/response.rb +25 -0
  33. data/lib/hbci/segment.rb +118 -0
  34. data/lib/hbci/segment_factory.rb +15 -0
  35. data/lib/hbci/segments/hikaz.rb +29 -0
  36. data/lib/hbci/segments/hikazs.rb +31 -0
  37. data/lib/hbci/segments/hirmg.rb +10 -0
  38. data/lib/hbci/segments/hirms.rb +17 -0
  39. data/lib/hbci/segments/hisal.rb +100 -0
  40. data/lib/hbci/segments/hisals.rb +19 -0
  41. data/lib/hbci/segments/hisyn.rb +11 -0
  42. data/lib/hbci/segments/hiupa.rb +12 -0
  43. data/lib/hbci/segments/hiupd.rb +37 -0
  44. data/lib/hbci/segments/hkend.rb +14 -0
  45. data/lib/hbci/segments/hkidn.rb +22 -0
  46. data/lib/hbci/segments/hkkaz.rb +25 -0
  47. data/lib/hbci/segments/hksal.rb +31 -0
  48. data/lib/hbci/segments/hksyn.rb +12 -0
  49. data/lib/hbci/segments/hkvvb.rb +18 -0
  50. data/lib/hbci/segments/hnhbk.rb +27 -0
  51. data/lib/hbci/segments/hnhbs.rb +14 -0
  52. data/lib/hbci/segments/hnsha.rb +31 -0
  53. data/lib/hbci/segments/hnshk.rb +79 -0
  54. data/lib/hbci/segments/hnvsd.rb +50 -0
  55. data/lib/hbci/segments/hnvsk.rb +60 -0
  56. data/lib/hbci/segments/segment_head.rb +11 -0
  57. data/lib/hbci/segments/unknown.rb +21 -0
  58. data/lib/hbci/services/accounts_receiver.rb +19 -0
  59. data/lib/hbci/services/balance_receiver.rb +69 -0
  60. data/lib/hbci/services/base_receiver.rb +43 -0
  61. data/lib/hbci/services/system_id_receiver.rb +35 -0
  62. data/lib/hbci/services/transactions_receiver.rb +75 -0
  63. data/lib/hbci/version.rb +5 -0
  64. metadata +315 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 10048414b4db622a1759e8d9c0535e5d1d71d8f705ce7887c17dc1710a7123a6
4
+ data.tar.gz: 6aa5448aa56599bc95f83c43b65693680c1432dd2603b7669b3d02fbac02ca45
5
+ SHA512:
6
+ metadata.gz: 8b968e2b272d8820dcd6ad9a9770a99fdc76b9d6e610919d61135ef8a54685fec03395283f207fa70a6f93967ed0ef1eccb0cdec9223313dc875628a021a09ad
7
+ data.tar.gz: 6912d3aec1751fd9334a91b99de8d4b4ebe45059454efc8a95fd0fa23dd7a48ca2952c2bafaa16a40da1bb2559588750e4c5433a6354802dc010ffd7df2d2a27
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea
11
+ .byebug_history
12
+ *.gem
13
+ test.sh
data/.rubocop.yml ADDED
@@ -0,0 +1,26 @@
1
+ inherit_from: .rubocop_todo.yml
2
+ Style/Documentation:
3
+ Enabled: false
4
+
5
+ Metrics/BlockLength:
6
+ Exclude:
7
+ - spec/**/*
8
+
9
+ Metrics/ModuleLength:
10
+ Exclude:
11
+ - lib/hbci/element_groups/generated_element_groups.rb
12
+
13
+ Metrics/LineLength:
14
+ Exclude:
15
+ - spec/support/message_stubs.rb
16
+ - spec/support/request_stubs.rb
17
+
18
+ Metrics/AbcSize:
19
+ Exclude:
20
+ - spec/support/message_stubs.rb
21
+
22
+ Metrics/ParameterLists:
23
+ Exclude:
24
+ - spec/support/message_stubs.rb
25
+ - spec/support/request_stubs.rb
26
+
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,26 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2018-07-02 12:32:29 +0200 using RuboCop version 0.57.2.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 7
10
+ Metrics/AbcSize:
11
+ Max: 42
12
+
13
+ # Offense count: 1
14
+ Metrics/CyclomaticComplexity:
15
+ Max: 9
16
+
17
+ # Offense count: 11
18
+ # Configuration parameters: CountComments.
19
+ Metrics/MethodLength:
20
+ Max: 77
21
+
22
+ # Offense count: 55
23
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
24
+ # URISchemes: http, https
25
+ Metrics/LineLength:
26
+ Max: 117
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.1
data/.travis.yml ADDED
@@ -0,0 +1 @@
1
+ language: ruby
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Roman Lehnert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # Hbci
2
+
3
+ A pure ruby HBCI client for talking with german banks
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/hbci.svg)](https://badge.fury.io/rb/hbci)
6
+ [![Build Status](https://travis-ci.org/fintastic/hbci.svg?branch=master)](https://travis-ci.org/fintastic/hbci)
7
+ [![Depfu](https://badges.depfu.com/badges/9be5e8286939565cd257add25432b1a8/count.svg)](https://depfu.com/github/fintastic/hbci?project=Bundler)
8
+
9
+
10
+ ## Preface
11
+
12
+ This gem is considered experimental.
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'hbci'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install hbci
29
+
30
+ ## Usage
31
+
32
+ First, setup your credentials in a `BankCredentials::Hbci` instance:
33
+ ```ruby
34
+ credentials = BankCredentials::Hbci.new({
35
+ url: 'url',
36
+ bank_code: 'bank_code',
37
+ user_id: 'user_id',
38
+ pin: 'pin'
39
+ })
40
+ ```
41
+
42
+ Now, you can receive your balances, accounts and transactions:
43
+
44
+ ### Receiving the transactions
45
+
46
+ ```ruby
47
+ iban = 'DE05740900000011111111'
48
+ start_date = 3.day.ago
49
+ end_date = Time.now
50
+
51
+ Hbci::Dialog.open(credentials) do |dialog|
52
+ transactions = Hbci::Services::TransactionsReceiver.new(dialog, iban).perform(start_date, end_date)
53
+ transactions.each do |transaction|
54
+ puts transaction
55
+ end
56
+ end
57
+ ```
58
+
59
+ ### Receiving a balance
60
+
61
+ ```ruby
62
+ iban = 'DE05740900000011111111'
63
+
64
+ Hbci::Dialog.open(credentials) do |dialog|
65
+ puts Hbci::Services::BalanceReceiver.new(dialog, iban).perform
66
+ end
67
+ ```
68
+
69
+ ### Receiving the accounts
70
+
71
+ ```ruby
72
+ Hbci::Dialog.open(credentials) do |dialog|
73
+ accounts = Hbci::Services::AccountsReceiver.new(dialog).perform
74
+ accounts.each do |account|
75
+ puts account
76
+ end
77
+ end
78
+ ```
79
+ ## Banks tested
80
+
81
+ | Bank | Tested | HBCI URL |
82
+ | --------------- |:-------:| ----------------------------------------------|
83
+ | VR Bank | DONE | https://hbci11.fiducia.de/cgi-bin/hbciservlet |
84
+ | Postbank | DONE | https://hbci.postbank.de/banking/hbci.do |
85
+ | Consorsbank | DONE | https://brokerage-hbci.consorsbank.de/hbci |
86
+ | Hypovereinsbank | OPEN | - |
87
+
88
+ ## Development
89
+
90
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
91
+
92
+ 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 run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
93
+
94
+ ## Contributing
95
+
96
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fintastic/hbci
97
+
98
+
99
+ ## Hbci Documentation
100
+
101
+ * [FinTS 3.0 Formals](http://www.hbci-zka.de/dokumente/spezifikation_deutsch/fintsv3/FinTS_3.0_Formals_2017-10-06_final_version.pdf)
102
+ * [FinTS 3.0 Messages](https://www.hbci-zka.de/dokumente/spezifikation_deutsch/fintsv3/FinTS_3.0_Messages_Geschaeftsvorfaelle_2015-08-07_final_version.pdf)
103
+ * [FinTS 3.0 Sicherheitsverfahren](https://www.hbci-zka.de/dokumente/spezifikation_deutsch/fintsv3/FinTS_3.0_Security_Sicherheitsverfahren_HBCI_Rel_20130718_final_version.pdf)
104
+
105
+ ## License
106
+
107
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'hbci'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'optparse'
4
+ require 'active_support'
5
+ require 'active_support/core_ext'
6
+
7
+ @options = {
8
+ url: nil,
9
+ hbci_version: nil,
10
+ bank_code: nil,
11
+ user_id: nil,
12
+ pin: nil,
13
+ system_id: 0
14
+ }
15
+
16
+ OptionParser.new do |opts|
17
+ opts.banner = 'Usage: example.rb iban [options]'
18
+
19
+ opts.on '-url', '--url=URL', 'URL' do |arg|
20
+ @options[:url] = arg
21
+ end
22
+
23
+ opts.on '-v', '--hbci_version=VERSION', 'Version' do |arg|
24
+ @options[:hbci_version] = arg
25
+ end
26
+
27
+ opts.on '-b', '--bank_code=BANK_CODE', 'Bank code' do |arg|
28
+ @options[:bank_code] = arg
29
+ end
30
+
31
+ opts.on '-u', '--user_id=USER_ID', 'User id' do |arg|
32
+ @options[:user_id] = arg
33
+ end
34
+
35
+ opts.on '-p', '--pin=PIN', 'PIN' do |arg|
36
+ @options[:pin] = arg
37
+ end
38
+
39
+ opts.on '-s', '--system_id=SYSTEM_ID', 'SYSTEM_ID' do |arg|
40
+ @options[:system_id] = arg
41
+ end
42
+
43
+ opts.on('-h', '--help', 'Prints this help') do
44
+ puts opts
45
+ exit
46
+ end
47
+ end.parse!
48
+
49
+ @iban = ARGV.at(0)
50
+ raise 'missing iban' unless @iban
51
+
52
+ @hbci_version = @options[:hbci_version] ? @options[:hbci_version].to_i : nil
53
+ @credentials = BankCredentials::Hbci.new(
54
+ url: @options[:url],
55
+ bank_code: @options[:bank_code],
56
+ user_id: @options[:user_id],
57
+ pin: @options[:pin]
58
+ )
59
+
60
+ connector = Hbci::Connector.instance
61
+ connector.credentials = @credentials
62
+
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../lib/hbci'
4
+ require_relative 'credentials'
5
+
6
+ Hbci::Dialog.open(system_id: @options[:system_id]) do |dialog|
7
+ accounts = Hbci::Services::AccountsReceiver.new(dialog).perform
8
+ accounts.each do |account|
9
+ puts account
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../lib/hbci'
4
+ require_relative 'credentials'
5
+
6
+ Hbci::Dialog.open(system_id: @options[:system_id]) do |dialog|
7
+ puts Hbci::Services::BalanceReceiver.new(dialog, @iban).perform
8
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../lib/hbci'
4
+ require_relative 'credentials'
5
+
6
+ puts Hbci::Services::SystemIdReceiver.new.perform
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../lib/hbci'
4
+ require_relative 'credentials'
5
+
6
+ start_date = 3.day.ago
7
+ end_date = Time.now
8
+
9
+ Hbci::Dialog.open(system_id: @options[:system_id]) do |dialog|
10
+ transactions = Hbci::Services::TransactionsReceiver.new(dialog, @iban, @hbci_version).perform(start_date, end_date)
11
+ transactions.each do |transaction|
12
+ puts transaction
13
+ end
14
+ end
15
+
data/hbci.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'hbci/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'hbci'
9
+ spec.version = Hbci::VERSION
10
+ spec.authors = ['Roman Lehnert', 'Alexander Klaiber']
11
+ spec.email = ['roman.lehnert@googlemail.com']
12
+
13
+ spec.summary = 'A Ruby hbci client'
14
+ spec.description = 'A pure ruby hbci banking client'
15
+ spec.homepage = 'https://github.com/fintastic/hbci'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'bank_credentials', '~> 0.1'
22
+ spec.add_runtime_dependency 'cmxl', '~> 1.1'
23
+ spec.add_runtime_dependency 'httparty', '~> 0.16'
24
+ spec.add_runtime_dependency 'ibanizator', '~> 0.3'
25
+ spec.add_runtime_dependency 'monetize', ['>=1.8', '<2.0.0']
26
+ spec.add_runtime_dependency 'money', ['>=6.11', '<7.0.0']
27
+
28
+ spec.add_development_dependency 'activesupport', '~> 5.2'
29
+ spec.add_development_dependency 'bundler', '~> 1.10'
30
+ spec.add_development_dependency 'byebug', '~> 10.0'
31
+ spec.add_development_dependency 'rake', '~> 12.3'
32
+ spec.add_development_dependency 'rspec', '~> 3.7'
33
+ spec.add_development_dependency 'rubocop', '~> 0.57'
34
+ spec.add_development_dependency 'timecop', '~> 0.9'
35
+ spec.add_development_dependency 'webmock', '~> 3.4'
36
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ruby-prof'
4
+ class DevelopmentProfiler
5
+ def self.prof(file_name)
6
+ RubyProf.start
7
+ yield
8
+ results = RubyProf.stop
9
+
10
+ base_path = 'tmp'
11
+
12
+ # Print a flat profile to text
13
+ File.open "#{base_path}/#{file_name}-graph.html", 'w' do |file|
14
+ RubyProf::GraphHtmlPrinter.new(results).print(file)
15
+ end
16
+
17
+ File.open "#{base_path}/#{file_name}-flat.txt", 'w' do |file|
18
+ # RubyProf::FlatPrinter.new(results).print(file)
19
+ RubyProf::FlatPrinterWithLineNumbers.new(results).print(file)
20
+ end
21
+
22
+ File.open "#{base_path}/#{file_name}-stack.html", 'w' do |file|
23
+ RubyProf::CallStackPrinter.new(results).print(file)
24
+ end
25
+ end
26
+ end
data/lib/hbci.rb ADDED
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ # External gems
4
+ require 'httparty'
5
+ require 'money'
6
+ require 'monetize'
7
+ require 'cmxl'
8
+ require 'ibanizator'
9
+
10
+ require 'bank_credentials'
11
+
12
+ # Internal logic
13
+ require 'hbci/version'
14
+ require 'hbci/parser'
15
+ require 'hbci/segment_factory'
16
+ require 'hbci/dialog'
17
+ require 'hbci/message'
18
+ require 'hbci/request'
19
+ require 'hbci/response'
20
+ require 'hbci/element_unparser'
21
+ require 'hbci/connector'
22
+ require 'hbci/message_factory'
23
+
24
+ # Element groups
25
+ require 'hbci/element_group'
26
+ require 'hbci/element_groups/segment_head'
27
+ require 'hbci/element_groups/unknown'
28
+ require 'hbci/element_groups/generated_element_groups'
29
+
30
+ # Segments
31
+ require 'hbci/segment'
32
+ require 'hbci/segments/hnshk'
33
+ require 'hbci/segments/hnsha'
34
+ require 'hbci/segments/hnhbk'
35
+ require 'hbci/segments/hnvsk'
36
+ require 'hbci/segments/hnhbs'
37
+ require 'hbci/segments/hnvsd'
38
+ require 'hbci/segments/hkidn'
39
+ require 'hbci/segments/hkvvb'
40
+ require 'hbci/segments/hksal'
41
+ require 'hbci/segments/hkkaz'
42
+ require 'hbci/segments/hikaz'
43
+ require 'hbci/segments/hisal'
44
+ require 'hbci/segments/hirms'
45
+ require 'hbci/segments/hiupa'
46
+ require 'hbci/segments/hiupd'
47
+ require 'hbci/segments/hikaz'
48
+ require 'hbci/segments/hkend'
49
+ require 'hbci/segments/hikazs'
50
+ require 'hbci/segments/hisals'
51
+ require 'hbci/segments/hirmg'
52
+ require 'hbci/segments/hksyn'
53
+ require 'hbci/segments/hisyn'
54
+ require 'hbci/segments/unknown'
55
+
56
+ # Services
57
+ require 'hbci/services/base_receiver'
58
+ require 'hbci/services/transactions_receiver'
59
+ require 'hbci/services/balance_receiver'
60
+ require 'hbci/services/accounts_receiver'
61
+ require 'hbci/services/system_id_receiver'
62
+
63
+ I18n.enforce_available_locales = false if I18n.available_locales.none?
64
+
65
+ module Hbci
66
+ end