bankster-client 0.0.5 → 0.0.6

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: b719fbb94d277694b56663bab9c67c2622cef7da
4
- data.tar.gz: e02d1bf64b21d4b4e40d973fb5b0a19c79b26a0c
3
+ metadata.gz: 64029ea6a27e2f54eff6adc40ead807eeb5cb2df
4
+ data.tar.gz: f30e871a722a0dc02100b5112a905249d5dd4ddf
5
5
  SHA512:
6
- metadata.gz: dba22f2217678f053b8ee30c9a3e067e33de25e7bf2f28476315a245f5bcd63655ab41580a38dddd949e18a9eb6f9580419c50dbcc1658f515f937df5e7ba6e3
7
- data.tar.gz: 7a803a95da9ab57b45e055b00b93082fe68b249f017901b1c8e48e04f4f45dc1c4de51d584873a20f3ec8e47dc8a0e75a372f0b6d2ffed5aa114d30ba4e4831d
6
+ metadata.gz: a5f465a79af34f299f641455ea00682bdf541a8e47dc503817c6e45425f1525128e7a91dae3aace145b1d9c03c120c416333ef1456dd0663bd4ab448889f0e8b
7
+ data.tar.gz: 26e47bad8d480207e095fb7ba176452b1bb21fd84515de8eac0868ecfedcccf5e36909aa6621ba74ca4f86ba56227aef9e3e4f2493462cb30881494495138812
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  *.gem
11
+ .byebug_history
data/.rubocop.yml CHANGED
@@ -1,3 +1,6 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
3
+
1
4
  Metrics/LineLength:
2
5
  Max: 200
3
6
 
data/Gemfile CHANGED
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  # Specify your gem's dependencies in bankster-client.gemspec
4
5
  gemspec
5
6
 
6
7
  gem 'rubocop', require: false
8
+ gem 'byebug'
7
9
 
8
10
  group :test do
9
11
  gem 'webmock'
data/README.md CHANGED
@@ -6,9 +6,9 @@ A tiny http wrapper for bankster.io
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- ```ruby
10
- gem 'bankster-client'
11
- ```
9
+ ```ruby
10
+ gem 'bankster-client'
11
+ ```
12
12
 
13
13
  And then execute:
14
14
 
@@ -20,26 +20,51 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- ```ruby
24
- bank_credentials = Bankster::BankCredentials::Hbci.new({
25
- url: 'https://hbci11.fiducia.de/cgi-bin/hbciservlet',
26
- bank_code: '67290000',
27
- user_id: 'my_hbci_user_id',
28
- pin: 'my_hbci_pin'
29
- })
30
- api_key = '9daad1ea407b91745d99e78ec1602110'
23
+ Bankster::Client can be configured globaly or on instance level.
31
24
 
32
- bankster_client = Bankster::Client.new(bank_credentials, api_key)
25
+ ### Global Configuration:
33
26
 
34
- transactions = bankster_client.transactions('my_account_number', Date.new(2016,5,1), Date.new(2016,5,11))
35
- ```
27
+ ```ruby
28
+ Bankster::Client.configure do
29
+ api_key = "my_api_key"
30
+ api_url = "http://bankster.io"
31
+ credentials = some_bankster_credentials
32
+ end
33
+ ```
36
34
 
37
- To override the hostname where the bankster-proxy resides, define
35
+ Afterwards, the Bankster::Client can be initialized:
38
36
 
39
- ```ruby
40
- BANSTER_BASE_URI = 'http://localhost:9292'
41
- ```
42
37
 
38
+ ```ruby
39
+ client = Bankster::Client.new
40
+ ```
41
+
42
+ ### Configure every instance:
43
+
44
+ If configuration params are given to the initializer, they override an existing global configuration:
45
+
46
+ ```ruby
47
+ client = Bankster::Client.new(credentials: hbci_credentials, api_key: 'my_key', base_uri: 'http://some_host')
48
+ ```
49
+
50
+ ## Credentials
51
+
52
+ Credentials are one of `Bankster::BankCredentials::Hbci` or `Bankster::BankCredentials::Ebics`, e.g.:
53
+
54
+ ```ruby
55
+ hbci_credentials = Bankster::BankCredentials::Hbci.new({
56
+ url: 'https://hbci11.fiducia.de/cgi-bin/hbciservlet',
57
+ bank_code: '67290000',
58
+ user_id: 'my_hbci_user_id',
59
+ pin: 'my_hbci_pin'
60
+ })
61
+ ```
62
+
63
+ ## Receiving transactions
64
+
65
+ ```ruby
66
+ transactions = client.transactions('my_account_number', Date.new(2016,5,1), Date.new(2016,5,11))
67
+ ```
43
68
 
44
69
  ## Development
45
70
 
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'bundler/gem_tasks'
2
3
  require 'rspec/core/rake_task'
3
4
 
@@ -1,10 +1,11 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
 
5
6
  Gem::Specification.new do |spec|
6
7
  spec.name = 'bankster-client'
7
- spec.version = '0.0.5'
8
+ spec.version = '0.0.6'
8
9
  spec.authors = ['Roman Lehnert', 'Alexander Klaiber']
9
10
  spec.email = ['mail@bankster.io']
10
11
 
@@ -25,9 +26,9 @@ Gem::Specification.new do |spec|
25
26
  spec.require_paths = ['lib']
26
27
 
27
28
  spec.add_runtime_dependency 'httparty'
28
- spec.add_runtime_dependency 'bankster-bank_credentials'
29
+ spec.add_runtime_dependency 'bankster-bank_credentials', '~> 0.1.5'
29
30
 
30
31
  spec.add_development_dependency 'bundler', '~> 1.12'
31
- spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rake', '~> 11.0'
32
33
  spec.add_development_dependency 'rspec', '~> 3.0'
33
34
  end
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'bankster/client'
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ require 'httparty'
3
+ require 'bankster/bank_credentials'
4
+
5
+ require_relative 'client/configuration'
6
+ require_relative 'client/client'
7
+ require_relative 'client/bank_account'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module BanksterClient
2
3
  class BankAccount
3
4
  attr_reader :owner, :iban, :bic
@@ -1,13 +1,25 @@
1
- module BanksterClient
1
+ # frozen_string_literal: true
2
+ module Bankster
2
3
  class Client
3
4
  include HTTParty
4
5
 
5
- def initialize
6
+ attr_reader :credentials
7
+
8
+ def self.configuration
9
+ Configuration.instance
10
+ end
11
+
12
+ def self.configure
13
+ yield Configuration.instance
14
+ end
15
+
16
+ def initialize(credentials)
17
+ @credentials = credentials
6
18
  @options = {
7
- base_uri: BanksterClient.configuration.api,
19
+ base_uri: self.class.configuration.api_url,
8
20
  headers: {
9
- 'Api-Key' => BanksterClient.configuration.api_key,
10
- 'Bank-Credentials' => Base64.urlsafe_encode64(BanksterClient.configuration.credentials.to_json)
21
+ 'Api-Key': self.class.configuration.api_key,
22
+ 'Bank-Credentials': encoded_credentials
11
23
  }
12
24
  }
13
25
  end
@@ -32,7 +44,14 @@ module BanksterClient
32
44
  }
33
45
  )
34
46
  response = self.class.post('/transfers', attributes)
35
- raise(response.body) unless response.ok?
47
+ raise(response.body) if !response.code.eql?(200) && !response.code.eql?(201)
48
+ end
49
+
50
+ private
51
+
52
+ def encoded_credentials
53
+ raise 'No credentials given' unless credentials
54
+ credentials.encode
36
55
  end
37
56
  end
38
57
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ require 'singleton'
3
+
4
+ module Bankster
5
+ class Client
6
+ class Configuration
7
+ include Singleton
8
+
9
+ attr_accessor :api_url
10
+ attr_accessor :api_key
11
+
12
+ def initialize
13
+ @api_url = 'http://bankster-proxy-prod.eu-central-1.elasticbeanstalk.com'
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ require '../lib/bankster/client'
3
+
4
+ Bankster::Client.configure do |config|
5
+ config.api_url = ''
6
+ config.api_key = ''
7
+ end
8
+
9
+ credentials = Bankster::BankCredentials::Ebics.new(
10
+ key: '',
11
+ user_id: '',
12
+ passphrase: '',
13
+ host_id: '',
14
+ partner_id: '',
15
+ url: ''
16
+ )
17
+
18
+ client = Bankster::Client.new(credentials)
19
+
20
+ puts client.transactions('100490016', Date.new(2016, 7, 22), Date.new(2016, 7, 22))
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ require '../lib/bankster/client'
3
+
4
+ Bankster::Client.configure do |config|
5
+ config.api_url = ''
6
+ config.api_key = ''
7
+ end
8
+
9
+ credentials = Bankster::BankCredentials::Ebics.new(
10
+ key: '',
11
+ user_id: '',
12
+ passphrase: '',
13
+ host_id: '',
14
+ partner_id: '',
15
+ url: ''
16
+ )
17
+
18
+ client = Bankster::Client.new(credentials)
19
+
20
+ sending_account = BanksterClient::BankAccount.new('', '', '')
21
+ receiving_account = BanksterClient::BankAccount.new('', '', '')
22
+
23
+ puts client.transfer(
24
+ sending_account,
25
+ receiving_account,
26
+ 1000,
27
+ 'S UL 671891175',
28
+ '5791ffa538f8846d596accdb',
29
+ '5791ffa538f8846d596accdb'
30
+ )
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+ require '../lib/bankster/client'
3
+
4
+ Bankster::Client.configure do |config|
5
+ config.api_url = ''
6
+ config.api_key = ''
7
+ end
8
+
9
+ credentials = Bankster::BankCredentials::Hbci.new(
10
+ url: '',
11
+ bank_code: '',
12
+ user_id: '',
13
+ pin: ''
14
+ )
15
+
16
+ client = Bankster::Client.new(credentials)
17
+
18
+ puts client.transactions('490016', Date.new(2016, 7, 22), Date.new(2016, 7, 22))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bankster-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Lehnert
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-07-12 00:00:00.000000000 Z
12
+ date: 2016-08-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -29,16 +29,16 @@ dependencies:
29
29
  name: bankster-bank_credentials
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0'
34
+ version: 0.1.5
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '0'
41
+ version: 0.1.5
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -59,14 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '10.0'
62
+ version: '11.0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '10.0'
69
+ version: '11.0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -101,11 +101,13 @@ files:
101
101
  - bankster-client.gemspec
102
102
  - bin/console
103
103
  - bin/setup
104
- - lib/bankster_client.rb
105
- - lib/bankster_client/bank_account.rb
106
- - lib/bankster_client/client.rb
107
- - lib/bankster_client/configuration.rb
108
- - lib/bankster_client/version.rb
104
+ - lib/bankster/client.rb
105
+ - lib/bankster/client/bank_account.rb
106
+ - lib/bankster/client/client.rb
107
+ - lib/bankster/client/configuration.rb
108
+ - samples/ebic_transactions.rb
109
+ - samples/ebic_transfer.rb
110
+ - samples/hbci_transactions.rb
109
111
  homepage: http://bankster.io
110
112
  licenses:
111
113
  - MIT
@@ -1,16 +0,0 @@
1
- require 'httparty'
2
- require 'bankster/bank_credentials'
3
-
4
- require_relative 'bankster_client/configuration'
5
- require_relative 'bankster_client/client'
6
- require_relative 'bankster_client/bank_account'
7
-
8
- module BanksterClient
9
- def self.configuration
10
- Configuration.instance
11
- end
12
-
13
- def self.configure
14
- yield Configuration.instance
15
- end
16
- end
@@ -1,17 +0,0 @@
1
- require 'singleton'
2
-
3
- module BanksterClient
4
- class Configuration
5
- include Singleton
6
-
7
- attr_accessor :api, :api_key
8
-
9
- def credentials=(credentials)
10
- @hbci_credentials = Bankster::BankCredentials::Hbci.new(credentials)
11
- end
12
-
13
- def credentials
14
- @hbci_credentials
15
- end
16
- end
17
- end
@@ -1,3 +0,0 @@
1
- module BanksterClient
2
- VERSION = '0.0.1'.freeze
3
- end