kontoapi-ruby 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -1,7 +1,7 @@
1
1
  Konto API Ruby Library
2
2
  ======================
3
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.
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 and international bank accounts.
5
5
 
6
6
  INSTALLATION
7
7
  ------------
@@ -19,10 +19,22 @@ USAGE
19
19
  # optional settings
20
20
  KontoAPI::timeout = 10 # 10 seconds is the default
21
21
 
22
- # Check account validity: KontoAPI::valid?(account_number, bank_code)
23
- KontoAPI::valid?('1234567', '12312312')
22
+ # Check account validity: KontoAPI::valid?(options)
23
+ KontoAPI::valid?( :ktn => '1234567', :blz => '12312312' )
24
24
  #=> false
25
- KontoAPI::valid?('49379110', '10010010')
25
+ KontoAPI::valid?( :ktn => '49379110', :blz => '10010010' )
26
+ #=> true
27
+
28
+ # Check IBAN only
29
+ KontoAPI::valid?( :iban => 'DE71100100100068118106' )
30
+ #=> true
31
+
32
+ # Check BIC only
33
+ KontoAPI::valid?( :bic => 'PBNKDEFF100' )
34
+ #=> true
35
+
36
+ # Check both IBAN and BIC
37
+ KontoAPI::valid?( :iban => 'DE71100100100068118106', :bic => 'PBNKDEFF100' )
26
38
  #=> true
27
39
 
28
40
  # Get the name of a bank by its code: KontoAPI::bank_name(bank_code)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{kontoapi-ruby}
8
- s.version = "0.1.1"
7
+ s.name = "kontoapi-ruby"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jan Schwenzien"]
12
- s.date = %q{2011-04-20}
13
- s.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.}
14
- s.email = %q{jan@general-scripting.com}
12
+ s.date = "2012-04-08"
13
+ s.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."
14
+ s.email = "jan@general-scripting.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
17
  "README.markdown"
@@ -28,11 +28,11 @@ Gem::Specification.new do |s|
28
28
  "spec/kontoapi-ruby_spec.rb",
29
29
  "spec/spec_helper.rb"
30
30
  ]
31
- s.homepage = %q{http://github.com/GeneralScripting/kontoapi-ruby}
31
+ s.homepage = "http://github.com/GeneralScripting/kontoapi-ruby"
32
32
  s.licenses = ["MIT"]
33
33
  s.require_paths = ["lib"]
34
- s.rubygems_version = %q{1.7.2}
35
- s.summary = %q{Konto API Ruby Library}
34
+ s.rubygems_version = "1.8.15"
35
+ s.summary = "Konto API Ruby Library"
36
36
  s.test_files = [
37
37
  "spec/kontoapi-ruby_spec.rb",
38
38
  "spec/spec_helper.rb"
data/lib/kontoapi-ruby.rb CHANGED
@@ -28,9 +28,9 @@ module KontoAPI
28
28
  @@timeout || DEFAULT_TIMEOUT
29
29
  end
30
30
 
31
- def valid?(account_number, bank_code)
32
- return false if account_number.to_s.strip.empty? || bank_code.to_s.strip.empty?
33
- response = ask_for(:validity, { :ktn => account_number.to_s, :blz => bank_code.to_s })
31
+ def valid?(options={})
32
+ return false unless (!options[:ktn].to_s.strip.empty? && !options[:blz].to_s.strip.empty?) || !options[:iban].to_s.strip.empty? || !options[:bic].to_s.strip.empty?
33
+ response = ask_for(:validity, options)
34
34
  response['answer'].eql?('yes')
35
35
  end
36
36
 
@@ -3,36 +3,36 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  describe "KontoAPI" do
4
4
 
5
5
  it "should raise if no api key was provided" do
6
- lambda { KontoAPI::valid?('1234567', '12312312') }.should raise_error(RuntimeError)
6
+ lambda { KontoAPI::valid?( :ktn => '1234567', :blz => '12312312' ) }.should raise_error(RuntimeError)
7
7
  end
8
8
 
9
9
  it "should raise if api key is invalid" do
10
10
  FakeWeb.register_uri(:get, %r|https://ask\.kontoapi\.de/for/validity.json?.*|, :body => '{"error":"unauthenticated"}', :status => ["401", "Unauthorized"])
11
11
  KontoAPI::api_key = 'abc123'
12
- lambda { KontoAPI::valid?('1234567', '12312312') }.should raise_error(Net::HTTPServerException)
12
+ lambda { KontoAPI::valid?( :ktn => '1234567', :blz => '12312312' ) }.should raise_error(Net::HTTPServerException)
13
13
  end
14
14
 
15
15
  context "checking validity" do
16
16
 
17
17
  it "should return false if account number or bank code are empty" do
18
- KontoAPI::valid?(nil, nil).should be_false
19
- KontoAPI::valid?('123', nil).should be_false
20
- KontoAPI::valid?(nil, '123').should be_false
21
- KontoAPI::valid?('', '').should be_false
22
- KontoAPI::valid?('123', '').should be_false
23
- KontoAPI::valid?('', '123').should be_false
18
+ KontoAPI::valid?( :ktn => nil, :blz => nil ).should be_false
19
+ KontoAPI::valid?( :ktn => '123', :blz => nil ).should be_false
20
+ KontoAPI::valid?( :ktn => nil, :blz => '123' ).should be_false
21
+ KontoAPI::valid?( :ktn => '', :blz => '' ).should be_false
22
+ KontoAPI::valid?( :ktn => '123', :blz => '' ).should be_false
23
+ KontoAPI::valid?( :ktn => '', :blz => '123' ).should be_false
24
24
  end
25
25
 
26
26
  it "should return true for successfull validity checks" do
27
27
  FakeWeb.register_uri(:get, %r|https://ask\.kontoapi\.de/for/validity.json?.*|, :body => '{"answer":"yes"}')
28
28
  KontoAPI::api_key = 'abc123'
29
- KontoAPI::valid?('correct_account_number', '12312312').should be_true
29
+ KontoAPI::valid?( :ktn => 'correct_account_number', :blz => '12312312' ).should be_true
30
30
  end
31
31
 
32
32
  it "should return false for unsuccessfull validity checks" do
33
33
  FakeWeb.register_uri(:get, %r|https://ask\.kontoapi\.de/for/validity.json?.*|, :body => '{"answer":"no"}')
34
34
  KontoAPI::api_key = 'abc123'
35
- KontoAPI::valid?('incorrect_account_number', '12312312').should be_false
35
+ KontoAPI::valid?( :ktn => 'incorrect_account_number', :blz => '12312312' ).should be_false
36
36
  end
37
37
 
38
38
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kontoapi-ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jan Schwenzien
@@ -15,12 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-20 00:00:00 Z
18
+ date: 2012-04-08 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: addressable
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
22
  none: false
25
23
  requirements:
26
24
  - - ">="
@@ -29,12 +27,12 @@ dependencies:
29
27
  segments:
30
28
  - 0
31
29
  version: "0"
30
+ name: addressable
31
+ prerelease: false
32
32
  type: :runtime
33
- version_requirements: *id001
33
+ requirement: *id001
34
34
  - !ruby/object:Gem::Dependency
35
- name: yajl-ruby
36
- prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
35
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
36
  none: false
39
37
  requirements:
40
38
  - - ">="
@@ -43,12 +41,12 @@ dependencies:
43
41
  segments:
44
42
  - 0
45
43
  version: "0"
44
+ name: yajl-ruby
45
+ prerelease: false
46
46
  type: :runtime
47
- version_requirements: *id002
47
+ requirement: *id002
48
48
  - !ruby/object:Gem::Dependency
49
- name: rspec
50
- prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
49
+ version_requirements: &id003 !ruby/object:Gem::Requirement
52
50
  none: false
53
51
  requirements:
54
52
  - - ~>
@@ -59,12 +57,12 @@ dependencies:
59
57
  - 3
60
58
  - 0
61
59
  version: 2.3.0
60
+ name: rspec
61
+ prerelease: false
62
62
  type: :development
63
- version_requirements: *id003
63
+ requirement: *id003
64
64
  - !ruby/object:Gem::Dependency
65
- name: bundler
66
- prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
65
+ version_requirements: &id004 !ruby/object:Gem::Requirement
68
66
  none: false
69
67
  requirements:
70
68
  - - ~>
@@ -75,12 +73,12 @@ dependencies:
75
73
  - 0
76
74
  - 0
77
75
  version: 1.0.0
76
+ name: bundler
77
+ prerelease: false
78
78
  type: :development
79
- version_requirements: *id004
79
+ requirement: *id004
80
80
  - !ruby/object:Gem::Dependency
81
- name: jeweler
82
- prerelease: false
83
- requirement: &id005 !ruby/object:Gem::Requirement
81
+ version_requirements: &id005 !ruby/object:Gem::Requirement
84
82
  none: false
85
83
  requirements:
86
84
  - - ~>
@@ -91,12 +89,12 @@ dependencies:
91
89
  - 5
92
90
  - 2
93
91
  version: 1.5.2
92
+ name: jeweler
93
+ prerelease: false
94
94
  type: :development
95
- version_requirements: *id005
95
+ requirement: *id005
96
96
  - !ruby/object:Gem::Dependency
97
- name: rcov
98
- prerelease: false
99
- requirement: &id006 !ruby/object:Gem::Requirement
97
+ version_requirements: &id006 !ruby/object:Gem::Requirement
100
98
  none: false
101
99
  requirements:
102
100
  - - ">="
@@ -105,12 +103,12 @@ dependencies:
105
103
  segments:
106
104
  - 0
107
105
  version: "0"
106
+ name: rcov
107
+ prerelease: false
108
108
  type: :development
109
- version_requirements: *id006
109
+ requirement: *id006
110
110
  - !ruby/object:Gem::Dependency
111
- name: fakeweb
112
- prerelease: false
113
- requirement: &id007 !ruby/object:Gem::Requirement
111
+ version_requirements: &id007 !ruby/object:Gem::Requirement
114
112
  none: false
115
113
  requirements:
116
114
  - - ">="
@@ -119,8 +117,10 @@ dependencies:
119
117
  segments:
120
118
  - 0
121
119
  version: "0"
120
+ name: fakeweb
121
+ prerelease: false
122
122
  type: :development
123
- version_requirements: *id007
123
+ requirement: *id007
124
124
  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.
125
125
  email: jan@general-scripting.com
126
126
  executables: []
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
170
  requirements: []
171
171
 
172
172
  rubyforge_project:
173
- rubygems_version: 1.7.2
173
+ rubygems_version: 1.8.15
174
174
  signing_key:
175
175
  specification_version: 3
176
176
  summary: Konto API Ruby Library