kontoapi-ruby 0.0.1
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.
- data/Gemfile +11 -0
- data/Gemfile.lock +32 -0
- data/LICENSE +20 -0
- data/README.markdown +35 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/lib/kontoapi-ruby.rb +66 -0
- data/spec/kontoapi-ruby_spec.rb +7 -0
- data/spec/spec_helper.rb +12 -0
- metadata +166 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.2.5)
|
5
|
+
diff-lcs (1.1.2)
|
6
|
+
git (1.2.5)
|
7
|
+
jeweler (1.5.2)
|
8
|
+
bundler (~> 1.0.0)
|
9
|
+
git (>= 1.2.5)
|
10
|
+
rake
|
11
|
+
nibbler (1.2.1)
|
12
|
+
rake (0.8.7)
|
13
|
+
rcov (0.9.9)
|
14
|
+
rspec (2.3.0)
|
15
|
+
rspec-core (~> 2.3.0)
|
16
|
+
rspec-expectations (~> 2.3.0)
|
17
|
+
rspec-mocks (~> 2.3.0)
|
18
|
+
rspec-core (2.3.1)
|
19
|
+
rspec-expectations (2.3.0)
|
20
|
+
diff-lcs (~> 1.1.2)
|
21
|
+
rspec-mocks (2.3.0)
|
22
|
+
|
23
|
+
PLATFORMS
|
24
|
+
ruby
|
25
|
+
|
26
|
+
DEPENDENCIES
|
27
|
+
addressable
|
28
|
+
bundler (~> 1.0.0)
|
29
|
+
jeweler (~> 1.5.2)
|
30
|
+
nibbler (>= 1.2.0)
|
31
|
+
rcov
|
32
|
+
rspec (~> 2.3.0)
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 General Scripting - Jan Schwenzien
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
Konto API Ruby Library
|
2
|
+
======================
|
3
|
+
|
4
|
+
This library provides an easy way to access the Konto API (https://www.kontoapi.de/), a webservice that performs validity checks and other services regarding german bank accounts.
|
5
|
+
|
6
|
+
INSTALLATION
|
7
|
+
------------
|
8
|
+
|
9
|
+
$ [sudo] gem install kontoapi-ruby
|
10
|
+
|
11
|
+
USAGE
|
12
|
+
-----
|
13
|
+
|
14
|
+
require 'kontoapi-ruby'
|
15
|
+
|
16
|
+
# mendatory settings
|
17
|
+
KontoAPI::api_key = "abc123"
|
18
|
+
|
19
|
+
# optional settings
|
20
|
+
KontoAPI::timeout = 10 # 10 seconds is the default
|
21
|
+
|
22
|
+
# Check account validity: KontoAPI::valid?(account_number, bank_code)
|
23
|
+
KontoAPI::valid?('1234567', '12312312')
|
24
|
+
#=> false
|
25
|
+
KontoAPI::valid?('49379110', '10010010')
|
26
|
+
#=> true
|
27
|
+
|
28
|
+
# Get the name of a bank by its code: KontoAPI::bank_name(bank_code)
|
29
|
+
KontoAPI::bank_name('10010010')
|
30
|
+
#=> 'Postbank'
|
31
|
+
|
32
|
+
Copyright
|
33
|
+
---------
|
34
|
+
|
35
|
+
Copyright (c) 2011 General Scripting - Jan Schwenzien. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "kontoapi-ruby"
|
16
|
+
gem.homepage = "http://github.com/GeneralScripting/kontoapi-ruby"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{Konto API Ruby Library}
|
19
|
+
gem.description = %Q{A ruby library to access the Konto API (https://www.kontoapi.de/), a webservice that performs validity checks and other services regarding german bank accounts.}
|
20
|
+
gem.email = "jan@general-scripting.com"
|
21
|
+
gem.authors = ["Jan Schwenzien"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
36
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
37
|
+
spec.rcov = true
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rake/rdoctask'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "kontoapi-ruby #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'addressable/uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'net/https'
|
4
|
+
|
5
|
+
module KontoAPI
|
6
|
+
|
7
|
+
extend self
|
8
|
+
|
9
|
+
VALIDITY_URL = Addressable::URI.parse 'https://ask.kontoapi.de/for/validity.json'
|
10
|
+
BANKNAME_URL = Addressable::URI.parse 'https://ask.kontoapi.de/for/bankname.json'
|
11
|
+
DEFAULT_TIMEOUT = 10
|
12
|
+
|
13
|
+
@@api_key = nil
|
14
|
+
def api_key=(key)
|
15
|
+
@@api_key = key
|
16
|
+
end
|
17
|
+
def api_key
|
18
|
+
@@api_key
|
19
|
+
end
|
20
|
+
|
21
|
+
@@timeout = nil
|
22
|
+
def timeout=(new_timeout)
|
23
|
+
@@timeout = new_timeout
|
24
|
+
end
|
25
|
+
def timeout
|
26
|
+
@@timeout || DEFAULT_TIMEOUT
|
27
|
+
end
|
28
|
+
|
29
|
+
def valid?(account_number, bank_code)
|
30
|
+
response = ask_for(:validity, { :ktn => account_number, :blz => bank_code })
|
31
|
+
response[:answer].eql?('yes')
|
32
|
+
end
|
33
|
+
|
34
|
+
def bank_name(bank_code)
|
35
|
+
response = ask_for(:bankname, { :blz => bank_code })
|
36
|
+
response[:answer]
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def ask_for(what, options={})
|
44
|
+
raise 'Please set your API Key first (KontoAPI::api_key = "<your_key>"). You can get one at https://www.kontoapi.de/' unless api_key
|
45
|
+
url = const_get("#{what}_URL".upcase).dup
|
46
|
+
options.merge!( :key => api_key )
|
47
|
+
url.query_values = options
|
48
|
+
body = get_url(url)
|
49
|
+
NibblerJSON.parse(body)
|
50
|
+
end
|
51
|
+
|
52
|
+
def get_url(url)
|
53
|
+
http = Net::HTTP.new(url.host, 443)
|
54
|
+
http.use_ssl = true
|
55
|
+
http.read_timeout = timeout
|
56
|
+
# TODO include certs and enable SSL verification
|
57
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
58
|
+
response = http.get url.request_uri, 'User-agent' => 'Konto API Ruby Client'
|
59
|
+
if Net::HTTPSuccess == response
|
60
|
+
response.body
|
61
|
+
else
|
62
|
+
response.error!
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'kontoapi-ruby'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kontoapi-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Jan Schwenzien
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-17 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: addressable
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: nibbler
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 31
|
43
|
+
segments:
|
44
|
+
- 1
|
45
|
+
- 2
|
46
|
+
- 0
|
47
|
+
version: 1.2.0
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: rspec
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 2
|
61
|
+
- 3
|
62
|
+
- 0
|
63
|
+
version: 2.3.0
|
64
|
+
type: :development
|
65
|
+
version_requirements: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: bundler
|
68
|
+
prerelease: false
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 23
|
75
|
+
segments:
|
76
|
+
- 1
|
77
|
+
- 0
|
78
|
+
- 0
|
79
|
+
version: 1.0.0
|
80
|
+
type: :development
|
81
|
+
version_requirements: *id004
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: jeweler
|
84
|
+
prerelease: false
|
85
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ~>
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
hash: 7
|
91
|
+
segments:
|
92
|
+
- 1
|
93
|
+
- 5
|
94
|
+
- 2
|
95
|
+
version: 1.5.2
|
96
|
+
type: :development
|
97
|
+
version_requirements: *id005
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rcov
|
100
|
+
prerelease: false
|
101
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
type: :development
|
111
|
+
version_requirements: *id006
|
112
|
+
description: A ruby library to access the Konto API (https://www.kontoapi.de/), a webservice that performs validity checks and other services regarding german bank accounts.
|
113
|
+
email: jan@general-scripting.com
|
114
|
+
executables: []
|
115
|
+
|
116
|
+
extensions: []
|
117
|
+
|
118
|
+
extra_rdoc_files:
|
119
|
+
- LICENSE
|
120
|
+
- README.markdown
|
121
|
+
files:
|
122
|
+
- Gemfile
|
123
|
+
- Gemfile.lock
|
124
|
+
- LICENSE
|
125
|
+
- README.markdown
|
126
|
+
- Rakefile
|
127
|
+
- VERSION
|
128
|
+
- lib/kontoapi-ruby.rb
|
129
|
+
- spec/kontoapi-ruby_spec.rb
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
homepage: http://github.com/GeneralScripting/kontoapi-ruby
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
hash: 3
|
145
|
+
segments:
|
146
|
+
- 0
|
147
|
+
version: "0"
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
hash: 3
|
154
|
+
segments:
|
155
|
+
- 0
|
156
|
+
version: "0"
|
157
|
+
requirements: []
|
158
|
+
|
159
|
+
rubyforge_project:
|
160
|
+
rubygems_version: 1.7.2
|
161
|
+
signing_key:
|
162
|
+
specification_version: 3
|
163
|
+
summary: Konto API Ruby Library
|
164
|
+
test_files:
|
165
|
+
- spec/kontoapi-ruby_spec.rb
|
166
|
+
- spec/spec_helper.rb
|