iban-lookup 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/iban-lookup.rb +26 -6
- data/lib/iban-lookup/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8b7733d28ed617952917053f247a28fa737fa67
|
4
|
+
data.tar.gz: 9f33173ccd290ad234debc076a97d8a4d0ec0a08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de0c3e32f4e14c2283855938785060711eb9c5e88302bf5ca511995383f6c2dfe4629550a01f985c13880621e4fabdac02c56a03e69dc6118abf777dbf600f63
|
7
|
+
data.tar.gz: a1370925b097d710f4d83ca5802aaee51d82b07c8720fe1a15b0ee723fef3b6a6641491d06378fcc7478fba2a283a490b765660ebeee989791bbcc4800d81be9
|
data/lib/iban-lookup.rb
CHANGED
@@ -9,7 +9,7 @@ require 'faraday'
|
|
9
9
|
#
|
10
10
|
module IbanLookup
|
11
11
|
class Configuration
|
12
|
-
attr_accessor :api_key, :service
|
12
|
+
attr_accessor :api_key, :service, :cache
|
13
13
|
|
14
14
|
def initialize
|
15
15
|
end
|
@@ -29,26 +29,46 @@ module IbanLookup
|
|
29
29
|
URL = 'https://www.iban.com'
|
30
30
|
ENDPOINT = 'clients/api/ibanv2.php'
|
31
31
|
|
32
|
-
attr_reader :
|
32
|
+
attr_reader :params
|
33
33
|
|
34
34
|
def initialize(iban)
|
35
|
-
params = {
|
35
|
+
@params = {
|
36
36
|
api_key: IbanLookup.configuration.api_key,
|
37
37
|
format: :json,
|
38
38
|
iban: iban,
|
39
39
|
}
|
40
|
-
@response = Faraday.get("#{URL.chomp('/')}/#{ENDPOINT.chomp('/')}?#{params.to_query}")
|
41
40
|
end
|
42
41
|
|
43
42
|
def valid?
|
44
43
|
valid_codes = %w(001 002 003 004 005)
|
45
|
-
|
44
|
+
json.fetch('validations', []).all? { valid_codes.include? v['code'] }
|
45
|
+
end
|
46
|
+
|
47
|
+
def json
|
48
|
+
@json ||= begin
|
49
|
+
body = if cache
|
50
|
+
cache.get(params[:iban]).presence ||
|
51
|
+
response.body.presence.tap { |j| cache.set(params[:iban], j) }
|
52
|
+
else
|
53
|
+
response.body.presence
|
54
|
+
end
|
55
|
+
JSON.parse(body || '{}')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def response
|
60
|
+
p 'hello'
|
61
|
+
Faraday.get("#{URL.chomp('/')}/#{ENDPOINT.chomp('/')}?#{params.to_query}")
|
62
|
+
end
|
63
|
+
|
64
|
+
def cache
|
65
|
+
IbanLookup.configuration.cache
|
46
66
|
end
|
47
67
|
|
48
68
|
private
|
49
69
|
|
50
70
|
def method_missing(name, *args)
|
51
|
-
|
71
|
+
json.fetch('bank_data', {}).fetch(String(name), nil)
|
52
72
|
end
|
53
73
|
end
|
54
74
|
|
data/lib/iban-lookup/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iban-lookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Kampp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.24'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: memcache_mock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.0'
|
83
97
|
description: IBAN Lookup wrapper for iban.com
|
84
98
|
email:
|
85
99
|
- emil@kampp.me
|