kontoapi-rails 0.0.3 → 0.2.0
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 +1 -1
- data/Gemfile.lock +4 -4
- data/README.markdown +18 -0
- data/VERSION +1 -1
- data/kontoapi-rails.gemspec +5 -5
- data/lib/kontoapi-rails/orm/active_record_extension.rb +40 -0
- data/lib/kontoapi-rails/validators/bank_account_validator.rb +1 -1
- metadata +8 -6
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
activemodel (= 3.0.7)
|
29
29
|
activesupport (= 3.0.7)
|
30
30
|
activesupport (3.0.7)
|
31
|
-
addressable (2.2.
|
31
|
+
addressable (2.2.7)
|
32
32
|
arel (2.0.9)
|
33
33
|
builder (2.1.2)
|
34
34
|
diff-lcs (1.1.2)
|
@@ -40,7 +40,7 @@ GEM
|
|
40
40
|
bundler (~> 1.0.0)
|
41
41
|
git (>= 1.2.5)
|
42
42
|
rake
|
43
|
-
kontoapi-ruby (0.
|
43
|
+
kontoapi-ruby (0.2.0)
|
44
44
|
addressable
|
45
45
|
yajl-ruby
|
46
46
|
mail (2.2.17)
|
@@ -82,7 +82,7 @@ GEM
|
|
82
82
|
treetop (1.4.9)
|
83
83
|
polyglot (>= 0.3.1)
|
84
84
|
tzinfo (0.3.26)
|
85
|
-
yajl-ruby (
|
85
|
+
yajl-ruby (1.1.0)
|
86
86
|
|
87
87
|
PLATFORMS
|
88
88
|
ruby
|
@@ -90,7 +90,7 @@ PLATFORMS
|
|
90
90
|
DEPENDENCIES
|
91
91
|
bundler (~> 1.0.0)
|
92
92
|
jeweler (~> 1.5.2)
|
93
|
-
kontoapi-ruby
|
93
|
+
kontoapi-ruby (>= 0.2.0)
|
94
94
|
rails (>= 3.0.0)
|
95
95
|
rcov
|
96
96
|
rspec (~> 2.3.0)
|
data/README.markdown
CHANGED
@@ -43,6 +43,24 @@ Then, in one of the models you want to validate bank account data with:
|
|
43
43
|
# :invalid <-- if it is invalid
|
44
44
|
# :timeout <-- if :on_timeout is set to :fail and the api call timed out
|
45
45
|
validates_account_data
|
46
|
+
|
47
|
+
# IBAN validation
|
48
|
+
# Check if the given IBAN is valid
|
49
|
+
# Takes any of the following options (the defaults are shown here):
|
50
|
+
# :allow_nil => true, <-- don't validate if nil
|
51
|
+
# :on_timeout => :ignore <-- do nothing if a timeout occurs, others:
|
52
|
+
# :fail <-- throw a validation error
|
53
|
+
# :retry <-- (not supported yet)
|
54
|
+
validates_iban :iban
|
55
|
+
|
56
|
+
# BIC validation
|
57
|
+
# Check if the given BIC exists
|
58
|
+
# Takes any of the following options (the defaults are shown here):
|
59
|
+
# :allow_nil => true, <-- don't validate if nil
|
60
|
+
# :on_timeout => :ignore <-- do nothing if a timeout occurs, others:
|
61
|
+
# :fail <-- throw a validation error
|
62
|
+
# :retry <-- (not supported yet)
|
63
|
+
validates_bic :bic
|
46
64
|
|
47
65
|
end
|
48
66
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.2.0
|
data/kontoapi-rails.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "kontoapi-rails"
|
8
|
-
s.version = "0.0
|
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 = "2012-04-
|
12
|
+
s.date = "2012-04-08"
|
13
13
|
s.description = "This library is a wrapper for the Konto API (https://www.kontoapi.de/). It provides a validation method for models that checks if a given account number and bank code represent a valid combination."
|
14
14
|
s.email = "jan@schwenzien.org"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -51,14 +51,14 @@ Gem::Specification.new do |s|
|
|
51
51
|
|
52
52
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
53
|
s.add_runtime_dependency(%q<rails>, [">= 3.0.0"])
|
54
|
-
s.add_runtime_dependency(%q<kontoapi-ruby>, [">= 0"])
|
54
|
+
s.add_runtime_dependency(%q<kontoapi-ruby>, [">= 0.2.0"])
|
55
55
|
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
56
56
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
57
57
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
58
58
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
59
59
|
else
|
60
60
|
s.add_dependency(%q<rails>, [">= 3.0.0"])
|
61
|
-
s.add_dependency(%q<kontoapi-ruby>, [">= 0"])
|
61
|
+
s.add_dependency(%q<kontoapi-ruby>, [">= 0.2.0"])
|
62
62
|
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
63
63
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
64
64
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
@@ -66,7 +66,7 @@ Gem::Specification.new do |s|
|
|
66
66
|
end
|
67
67
|
else
|
68
68
|
s.add_dependency(%q<rails>, [">= 3.0.0"])
|
69
|
-
s.add_dependency(%q<kontoapi-ruby>, [">= 0"])
|
69
|
+
s.add_dependency(%q<kontoapi-ruby>, [">= 0.2.0"])
|
70
70
|
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
71
71
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
72
72
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
@@ -42,6 +42,46 @@ module KontoAPI
|
|
42
42
|
end
|
43
43
|
before_save :autocomplete_bank_name
|
44
44
|
end
|
45
|
+
|
46
|
+
def validates_iban(field, options={})
|
47
|
+
options.symbolize_keys!
|
48
|
+
options.reverse_merge!( :allow_nil => true, :on_timeout => :ignore )
|
49
|
+
define_method :iban_validation do
|
50
|
+
value = send(field)
|
51
|
+
return true if options[:allow_nil] && value.nil?
|
52
|
+
begin
|
53
|
+
record.errors.add(field, :invalid) unless KontoAPI::valid?( :iban => value )
|
54
|
+
rescue Timeout::Error => ex
|
55
|
+
case options[:on_timeout]
|
56
|
+
when :fail
|
57
|
+
record.errors.add(field, :timeout)
|
58
|
+
when :ignore
|
59
|
+
# nop
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
validate :iban_validation
|
64
|
+
end
|
65
|
+
|
66
|
+
def validates_bic(field, options={})
|
67
|
+
options.symbolize_keys!
|
68
|
+
options.reverse_merge!( :allow_nil => true, :on_timeout => :ignore )
|
69
|
+
define_method :bic_validation do
|
70
|
+
value = send(field)
|
71
|
+
return true if options[:allow_nil] && value.nil?
|
72
|
+
begin
|
73
|
+
record.errors.add(field, :invalid) unless KontoAPI::valid?( :bic => send(field) )
|
74
|
+
rescue Timeout::Error => ex
|
75
|
+
case options[:on_timeout]
|
76
|
+
when :fail
|
77
|
+
record.errors.add(field, :timeout)
|
78
|
+
when :ignore
|
79
|
+
# nop
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
validate :bic_validation
|
84
|
+
end
|
45
85
|
end
|
46
86
|
|
47
87
|
end
|
@@ -7,7 +7,7 @@ module KontoAPI
|
|
7
7
|
account_number = record.send(:"#{options[:account_number_field]}")
|
8
8
|
bank_code = record.send(:"#{options[:bank_code_field]}")
|
9
9
|
return true if options[:allow_nil] && (account_number.nil? || bank_code.nil?)
|
10
|
-
record.errors.add(:"#{options[:account_number_field]}", :invalid) unless KontoAPI::valid?(account_number, bank_code)
|
10
|
+
record.errors.add(:"#{options[:account_number_field]}", :invalid) unless KontoAPI::valid?( :ktn => account_number, :blz => bank_code )
|
11
11
|
rescue Timeout::Error => ex
|
12
12
|
case options[:on_timeout]
|
13
13
|
when :fail
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kontoapi-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 2
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.3
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jan Schwenzien
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-04-
|
18
|
+
date: 2012-04-08 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
@@ -39,10 +39,12 @@ dependencies:
|
|
39
39
|
requirements:
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
hash:
|
42
|
+
hash: 23
|
43
43
|
segments:
|
44
44
|
- 0
|
45
|
-
|
45
|
+
- 2
|
46
|
+
- 0
|
47
|
+
version: 0.2.0
|
46
48
|
name: kontoapi-ruby
|
47
49
|
prerelease: false
|
48
50
|
type: :runtime
|