aq_banking 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70d0bb8ab7a557647a25a06b7a73765cab0270ad
4
- data.tar.gz: 378949a71c9fe792ce46a6211f263abc5d97b1b9
3
+ metadata.gz: 609175a7c3cc48f8fd363bef763738f608c8cb94
4
+ data.tar.gz: 5a77dc9be4047aeecdb885a7336eba78619f963c
5
5
  SHA512:
6
- metadata.gz: c70c690ba8abaaf78102c6f8d60f7007d8d02ac0fa7adb3b84f76bd2b0445850b9fa50cbfb5e665ef3ef2f1067740a5329edbf16be9f4d7a65fde00491bd474c
7
- data.tar.gz: 39ece253a7a92c3aaca0800e28a738204ac745e0a1df9fea4ad894b14b7cd54e433505251e7b61a044f791be9dd612f2ceeadf60f0e4d745c7384ff642aaf485
6
+ metadata.gz: 1a3c37599be9fc428c46d7c0914c47d8b4f45d0d8f60fe85ba115ce1f75656061a75f59f3df4c1011ae57bfc5c3ceea6cdeee0b47f21a173be083b09a43e336f
7
+ data.tar.gz: d3af01a507153d2e26417d66706fbc00ea054a187a836a4aa750a73d03ade9e78cfa511c32f2be808d23d6b517ff154ab4dafaf504371dd524124ad064765fc7
@@ -1 +1 @@
1
- ruby-2.3
1
+ ruby-2.3.1
@@ -2,6 +2,5 @@ language: ruby
2
2
  rvm:
3
3
  - 2.3.0
4
4
  - 2.2.2
5
- - 2.1.5
6
5
  before_install: gem install bundler -v 1.10.3
7
6
  script: bundle exec rspec
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ruby:2.3.0
1
+ FROM ruby:2.3.1
2
2
  MAINTAINER Robin Wenglewski, robin@wenglewski.de
3
3
 
4
4
  RUN apt-get update -qq && apt-get install -y \
@@ -6,6 +6,9 @@ RUN apt-get update -qq && apt-get install -y \
6
6
  aqbanking-tools \
7
7
  ktoblzcheck
8
8
 
9
+ WORKDIR /gem
10
+
11
+ COPY ./pkg /gem
9
12
  RUN gem install aq_banking
10
13
 
11
14
  ENTRYPOINT ["aq_banking"]
data/README.md CHANGED
@@ -9,31 +9,10 @@ Sample:
9
9
 
10
10
  ```bash
11
11
  $ aq_banking request --bank=diba BLZ ACCCOUNT_NUMBER LOGIN_ID PASSWORD --from=2016-04-18
12
- {
13
- "iban": "...",
14
- "bic": "...",
15
- "owner": "WENGLEWSKI, ROBIN",
16
- "currency": "EUR",
17
- "bank_code": "...",
18
- "bank_name": "ING-DiBa",
19
- "booked_balance": 123.45,
20
- "noted_balance": 123.45,
21
- "number": "...",
22
- "name": "Girokonto",
23
- "transactions": [
24
- {
25
- "amount": -22.0,
26
- "currency": "EUR",
27
- "date": "2016-04-18 12:00:00 UTC",
28
- "valuta_date": "2016-04-18 12:00:00 UTC"
29
- ...
30
- },
31
- ...
32
- ],
33
- ...
34
- }
35
12
  ```
36
13
 
14
+ See (transaction.txt.json)[./spec/fixtures/transaction.txt.json] for a sample response.
15
+
37
16
  It still requires the aq_banking command line tools (aqhbci-tool4, aqbanking-cli) to be present.
38
17
  To my experience, these tools are very unstable and full of bugs.
39
18
  This tool is developed using a specific version which ships with the docker image.
@@ -75,8 +54,11 @@ And then execute:
75
54
 
76
55
  ## Release
77
56
 
78
- # publish gem, build and push docker container
79
- rake release && docker-compose build --no-cache gem && docker push rweng/aq_banking
57
+ # publish gem
58
+ rake release
59
+
60
+ # publish docker
61
+ rake build && docker-compose build gem && docker push rweng/aq_banking
80
62
 
81
63
 
82
64
  # Contributing
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency "treetop"
22
22
  spec.add_dependency "activesupport"
23
23
  spec.add_dependency "highline", "~> 1.7.8"
24
+ spec.add_dependency 'awrence'
24
25
 
25
26
  spec.add_development_dependency "bundler", "~> 1.10"
26
27
  spec.add_development_dependency "rake", "~> 10.0"
@@ -2,6 +2,7 @@ require 'logger'
2
2
  require 'active_support/core_ext/object/try'
3
3
  require 'active_support/core_ext/string'
4
4
  require 'active_support/core_ext/module/delegation'
5
+ require 'awrence'
5
6
 
6
7
  module AqBanking
7
8
  HBCI_VERSIONS = %w(220 300)
@@ -15,6 +15,7 @@ module AqBanking
15
15
  option :hbci_version
16
16
  option :from, banner: 'FROM - e.g. 2016-01-01'
17
17
  option :to, banner: 'TO - e.g. 2016-01-01'
18
+ option :format, default: 'json', banner: 'choose from: raw | json'
18
19
  desc 'request BANK_CODE ACCOUNT_NUMBER USER_ID PASSWORD', 'requests balance and transactions for an account. you must either specify --bank= or (--server-url and maybe --hbci-version)'
19
20
  def request(bank_code, account_number, user_id, password)
20
21
  request_options = {
@@ -33,7 +34,14 @@ module AqBanking
33
34
  response = commander.send_request!(request_options)
34
35
  account = parser.parse_account_list(response).first
35
36
 
36
- puts account.to_json
37
+ case options[:format]
38
+ when 'json'
39
+ puts account.to_json
40
+ when 'raw'
41
+ puts account.to_raw
42
+ else
43
+ puts 'unknown format'
44
+ end
37
45
  end
38
46
 
39
47
  desc 'list_banks', 'shows valid values for the --bank flag'
@@ -98,7 +98,7 @@ module AqBanking
98
98
  loop do
99
99
  count = count + 1
100
100
  result = run "aqhbci-tool4 deluser --with-accounts -u %p -b %p" % [user_id, bank_code]
101
- break if result.stderr.include? 'ERROR: No matching users' or result.stdout.match /User %d+ deleted\./
101
+ break if result.success? or result.stderr.include? 'ERROR: No matching users'
102
102
 
103
103
  raise 'could not delete user' if count >= max_trials
104
104
  end
@@ -122,7 +122,7 @@ module AqBanking
122
122
 
123
123
  cmd = "#{aq_hbci} -P #{pin_file} getsysid -u #{user_id} -b #{bank_code}"
124
124
 
125
- run_or_raise(cmd, 'Could not get sysid. This might be because the userId or password is wrong. Check if these are the credentials with which you log into your online banking.')
125
+ run_or_raise(cmd, 'Could not get sysid. This might be because the bank_code, userId or password is wrong, or internet banking is not active. Check if you can log into your internet banking w/ these credentials.')
126
126
  end
127
127
 
128
128
  private
@@ -52,7 +52,11 @@ module AqBanking::Parsed
52
52
  end
53
53
 
54
54
  def to_json
55
- JSON.pretty_generate(to_h)
55
+ JSON.pretty_generate(to_h.to_camelback_keys)
56
+ end
57
+
58
+ def to_raw
59
+ tree.text_value
56
60
  end
57
61
 
58
62
  private
@@ -1,3 +1,5 @@
1
+ require 'digest'
2
+
1
3
  module AqBanking::Parsed
2
4
  class Transaction
3
5
  extend DefineField
@@ -15,8 +17,12 @@ module AqBanking::Parsed
15
17
  @tree = transaction_block
16
18
  end
17
19
 
20
+ def uid
21
+ Digest::SHA256.hexdigest self.tree.text_value
22
+ end
23
+
18
24
  def to_h
19
- %i(local_bank_code local_account_number local_name remote_bank_code remote_account_number remote_name
25
+ %i(uid purpose local_bank_code local_account_number local_name remote_bank_code remote_account_number remote_name
20
26
  currency amount date valuta_date).reduce({}) do |result, field|
21
27
  result[field] = send(field)
22
28
  result
@@ -1,3 +1,3 @@
1
1
  module AqBanking
2
- VERSION = "0.2.4"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aq_banking
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Wenglewski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-04 00:00:00.000000000 Z
11
+ date: 2016-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.7.8
69
+ - !ruby/object:Gem::Dependency
70
+ name: awrence
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
85
  requirement: !ruby/object:Gem::Requirement