bankster-client 0.0.4 → 0.0.5

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: e9115b6d8b1dc99e819f4fdf20e423f07c9342c2
4
- data.tar.gz: 24a87c7715542b325fd3e57f657d40be0bdde726
3
+ metadata.gz: b719fbb94d277694b56663bab9c67c2622cef7da
4
+ data.tar.gz: e02d1bf64b21d4b4e40d973fb5b0a19c79b26a0c
5
5
  SHA512:
6
- metadata.gz: 93387bcf0e6d9d36dd474a86eeb016da1640a6506a44bdf20de0b93bbbfe622c5e90e7020ce158d9eb1e5f756b8459f34e6699dc1bf9c761ae4264d81a335ca0
7
- data.tar.gz: 72a806906c1b6c8e9faa8393d0cb9f292813db74d9218418bd19b696506a50c764de981f93672738b7d02f75ce222a951dae05f3fd60b2fdc01045f6500d52cf
6
+ metadata.gz: dba22f2217678f053b8ee30c9a3e067e33de25e7bf2f28476315a245f5bcd63655ab41580a38dddd949e18a9eb6f9580419c50dbcc1658f515f937df5e7ba6e3
7
+ data.tar.gz: 7a803a95da9ab57b45e055b00b93082fe68b249f017901b1c8e48e04f4f45dc1c4de51d584873a20f3ec8e47dc8a0e75a372f0b6d2ffed5aa114d30ba4e4831d
data/.overcommit.yml ADDED
@@ -0,0 +1,32 @@
1
+ # Use this file to configure the Overcommit hooks you wish to use. This will
2
+ # extend the default configuration defined in:
3
+ # https://github.com/brigade/overcommit/blob/master/config/default.yml
4
+ #
5
+ # At the topmost level of this YAML file is a key representing type of hook
6
+ # being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
7
+ # customize each hook, such as whether to only run it on certain files (via
8
+ # `include`), whether to only display output if it fails (via `quiet`), etc.
9
+ #
10
+ # For a complete list of hooks, see:
11
+ # https://github.com/brigade/overcommit/tree/master/lib/overcommit/hook
12
+ #
13
+ # For a complete list of options that you can use to customize hooks, see:
14
+ # https://github.com/brigade/overcommit#configuration
15
+ #
16
+ # Uncomment the following lines to make the configuration take effect.
17
+
18
+ PreCommit:
19
+ RuboCop:
20
+ enabled: true
21
+ on_warn: fail # Treat all warnings as failures
22
+
23
+ # TrailingWhitespace:
24
+ # exclude:
25
+ # - '**/db/structure.sql' # Ignore trailing whitespace in generated files
26
+ #
27
+ #PostCheckout:
28
+ # ALL: # Special hook name that customizes all hooks of this type
29
+ # quiet: true # Change all post-checkout hooks to only display output on failure
30
+ #
31
+ # IndexTags:
32
+ # enabled: true # Generate a tags file with `ctags` each time HEAD changes
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ Metrics/LineLength:
2
+ Max: 200
3
+
4
+ Style/Documentation:
5
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.1
data/Gemfile CHANGED
@@ -2,3 +2,10 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in bankster-client.gemspec
4
4
  gemspec
5
+
6
+ gem 'rubocop', require: false
7
+
8
+ group :test do
9
+ gem 'webmock'
10
+ gem 'forgery', github: 'romanlehnert/forgery', branch: 'feature/banking'
11
+ end
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -3,33 +3,31 @@ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "bankster-client"
7
- spec.version = '0.0.4'
8
- spec.authors = ["Roman Lehnert"]
9
- spec.email = ["roman.lehnert@googlemail.com"]
6
+ spec.name = 'bankster-client'
7
+ spec.version = '0.0.5'
8
+ spec.authors = ['Roman Lehnert', 'Alexander Klaiber']
9
+ spec.email = ['mail@bankster.io']
10
10
 
11
11
  spec.summary = 'Bankster Client'
12
12
  spec.description = 'A tiny http wrapper for bankster.io'
13
- spec.homepage = "http://bankster.io"
14
- spec.license = "MIT"
13
+ spec.homepage = 'http://bankster.io'
14
+ spec.license = 'MIT'
15
15
 
16
16
  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
17
  # delete this section to allow pushing this gem to any host.
18
- if spec.respond_to?(:metadata)
19
- spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
- else
21
- raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
- end
18
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)
19
+
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
23
21
 
24
22
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
- spec.bindir = "exe"
23
+ spec.bindir = 'exe'
26
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
- spec.require_paths = ["lib"]
25
+ spec.require_paths = ['lib']
28
26
 
29
27
  spec.add_runtime_dependency 'httparty'
30
28
  spec.add_runtime_dependency 'bankster-bank_credentials'
31
29
 
32
- spec.add_development_dependency "bundler", "~> 1.11"
33
- spec.add_development_dependency "rake", "~> 10.0"
34
- spec.add_development_dependency "rspec", "~> 3.0"
30
+ spec.add_development_dependency 'bundler', '~> 1.12'
31
+ spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rspec', '~> 3.0'
35
33
  end
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "bankster/client"
3
+ require 'bundler/setup'
4
+ require 'bankster/client'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "bankster/client"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start
@@ -0,0 +1,19 @@
1
+ module BanksterClient
2
+ class BankAccount
3
+ attr_reader :owner, :iban, :bic
4
+
5
+ def initialize(owner, iban, bic)
6
+ @owner = owner
7
+ @iban = iban
8
+ @bic = bic
9
+ end
10
+
11
+ def to_h
12
+ {
13
+ owner: @owner,
14
+ iban: @iban,
15
+ bic: @bic
16
+ }
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,38 @@
1
+ module BanksterClient
2
+ class Client
3
+ include HTTParty
4
+
5
+ def initialize
6
+ @options = {
7
+ base_uri: BanksterClient.configuration.api,
8
+ headers: {
9
+ 'Api-Key' => BanksterClient.configuration.api_key,
10
+ 'Bank-Credentials' => Base64.urlsafe_encode64(BanksterClient.configuration.credentials.to_json)
11
+ }
12
+ }
13
+ end
14
+
15
+ def transactions(account, from, to)
16
+ response = self.class.get('/transactions', @options.merge(query: { account: account, start: from, end: to }))
17
+ raise(response.body) unless response.ok?
18
+ JSON.parse(response.body)
19
+ end
20
+
21
+ # FIXME : Parameter lists longer
22
+ # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
23
+ def transfer(sending_account, receiving_account, amount_cents, purpose, reference, identification = nil)
24
+ attributes = @options.merge(
25
+ body: {
26
+ sending_account: sending_account.to_h,
27
+ receiving_account: receiving_account.to_h,
28
+ purpose: purpose,
29
+ amount_cents: amount_cents,
30
+ reference: reference,
31
+ identification: identification
32
+ }
33
+ )
34
+ response = self.class.post('/transfers', attributes)
35
+ raise(response.body) unless response.ok?
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,17 @@
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
@@ -0,0 +1,3 @@
1
+ module BanksterClient
2
+ VERSION = '0.0.1'.freeze
3
+ end
@@ -0,0 +1,16 @@
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
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bankster-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Lehnert
8
+ - Alexander Klaiber
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2016-05-13 00:00:00.000000000 Z
12
+ date: 2016-07-12 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: httparty
@@ -44,14 +45,14 @@ dependencies:
44
45
  requirements:
45
46
  - - "~>"
46
47
  - !ruby/object:Gem::Version
47
- version: '1.11'
48
+ version: '1.12'
48
49
  type: :development
49
50
  prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
52
53
  - - "~>"
53
54
  - !ruby/object:Gem::Version
54
- version: '1.11'
55
+ version: '1.12'
55
56
  - !ruby/object:Gem::Dependency
56
57
  name: rake
57
58
  requirement: !ruby/object:Gem::Requirement
@@ -82,13 +83,16 @@ dependencies:
82
83
  version: '3.0'
83
84
  description: A tiny http wrapper for bankster.io
84
85
  email:
85
- - roman.lehnert@googlemail.com
86
+ - mail@bankster.io
86
87
  executables: []
87
88
  extensions: []
88
89
  extra_rdoc_files: []
89
90
  files:
90
91
  - ".gitignore"
92
+ - ".overcommit.yml"
91
93
  - ".rspec"
94
+ - ".rubocop.yml"
95
+ - ".ruby-version"
92
96
  - ".travis.yml"
93
97
  - Gemfile
94
98
  - LICENSE.txt
@@ -97,7 +101,11 @@ files:
97
101
  - bankster-client.gemspec
98
102
  - bin/console
99
103
  - bin/setup
100
- - lib/bankster/client.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
+ - lib/bankster_client/version.rb
101
109
  homepage: http://bankster.io
102
110
  licenses:
103
111
  - MIT
@@ -1,30 +0,0 @@
1
- require 'httparty'
2
- require 'bankster/bank_credentials'
3
-
4
- module Bankster
5
- class Client
6
- include HTTParty
7
- attr_reader :credentials
8
-
9
- def initialize(credentials, api_key)
10
- @credentials = credentials
11
- @api_key = api_key
12
- @options = {
13
- base_uri: BANKSTER_BASE_URI || 'https://api.bankster.io',
14
- headers: {
15
- 'Api-Key' => api_key,
16
- 'Bank-Credentials' => Base64.urlsafe_encode64(credentials.to_json)
17
- }
18
- }
19
- end
20
-
21
- def transactions(account, from, to)
22
- response = self.class.get("/transactions", @options.merge(query: {account: account, start: from, end: to}))
23
- if response.ok?
24
- JSON.parse(response.body)
25
- else
26
- raise(response.body)
27
- end
28
- end
29
- end
30
- end