iban-lookup 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 172c5f4609a374272990b4257335ce1f5754157c
4
+ data.tar.gz: 3c5647232711abfe03cc23db35b2034d25cd0f7e
5
+ SHA512:
6
+ metadata.gz: bacb06ab2508c670de91cf33c4245ad2766853dcf0623193e2579d9aaecf291951ff66f7e7021d0e51cf85944bc884cc8ebf8c7ba24666f4f73c9e899ed16336
7
+ data.tar.gz: bbac78cf16a7fadfffe6a4e2877dd3837820628a87484f996fc3776590e90ad2bed63d78a24ef1bc0c67fd879c8261c123f3cd3b311039baebcbbfabddbc7757
@@ -0,0 +1,54 @@
1
+ require 'active_support/all'
2
+ require 'faraday'
3
+
4
+ # Lookup a new iban number
5
+ #
6
+ # Getting the BIC number
7
+ #
8
+ # IbanLookup.lookup(iban).bic # => BARCGB22
9
+ #
10
+ module IbanLookup
11
+ class Configuration
12
+ attr_accessor :api_key, :service
13
+
14
+ def initialize
15
+ end
16
+ end
17
+
18
+ class << self
19
+ attr_accessor :configuration
20
+ end
21
+
22
+ def configure
23
+ self.configuration ||= Configuration.new
24
+ yield(configuration)
25
+ end
26
+ module_function :configure
27
+
28
+ class IbanCom
29
+ URL = 'https://www.iban.com'
30
+ ENDPOINT = 'clients/api/ibanv2.php'
31
+
32
+ attr_reader :response
33
+
34
+ def initialize(iban)
35
+ params = {
36
+ api_key: IbanLookup.configuration.api_key,
37
+ format: :json,
38
+ iban: iban,
39
+ }
40
+ @response = Faraday.get("#{URL.chomp('/')}/#{ENDPOINT.chomp('/')}?#{params.to_query}")
41
+ end
42
+
43
+ private
44
+
45
+ def method_missing(name, *args)
46
+ JSON.parse(response.body.presence || '{}').fetch('bank_data', {}).fetch(String(name), nil) || :not_available
47
+ end
48
+ end
49
+
50
+ def lookup(iban)
51
+ "IbanLookup::#{configuration.service.classify}".constantize.new(iban)
52
+ end
53
+ module_function :lookup
54
+ end
@@ -0,0 +1,5 @@
1
+ module Iban
2
+ module Lookup
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: iban-lookup
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Emil Kampp
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: vcr
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.24'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.24'
83
+ description: IBAN Lookup wrapper for iban.com
84
+ email:
85
+ - emil@kampp.me
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - lib/iban-lookup.rb
91
+ - lib/iban-lookup/version.rb
92
+ homepage: https://github.com//iban-lookup
93
+ licenses: []
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.6.1
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: IBAN Lookup wrapper for iban.com
115
+ test_files: []