ibancom 0.0.11 → 0.0.12
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +12 -0
- data/lib/ibancom/api/validation_service.rb +1 -1
- data/lib/ibancom/client.rb +4 -2
- data/lib/ibancom/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 47cb70450c2d3171087a946ac9bb141c8d24fd23355bbaa3f281b1f0ff843b30
|
|
4
|
+
data.tar.gz: 18b1bb8d814c8688543a44175e90d480dd2bd31ed9a2a32a1aa38c074218e2bb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 193f5a9634022ee954039f7287d3ac1532a8f73adba28eae1890dfc0de4fb4660f9c115959dae12ac83532b566889464665f3da9c3ea3caeb13b524329924356
|
|
7
|
+
data.tar.gz: e1de0d21ad7bc55b7a473fc987211286ff2487339a98ee459860a050758dc08e2d722800168c3b3b20de527671c06d783f981eab7aa187c7c3c684013b11d40f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -35,6 +35,18 @@ The first step for using this gem is to instantiate the client:
|
|
|
35
35
|
client = Ibancom::Client.new(apikey: "YOUR_API_KEY")
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
HTTP logging is enabled by default through `Faraday::Response::Logger`. You can replace that middleware and pass extra options to it:
|
|
39
|
+
|
|
40
|
+
```rb
|
|
41
|
+
client = Ibancom::Client.new(
|
|
42
|
+
apikey: "YOUR_API_KEY",
|
|
43
|
+
logger_middleware: CustomMiddleware,
|
|
44
|
+
logger_options: { log_level: :debug }
|
|
45
|
+
)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`logger_options` are merged over `{ headers: true, bodies: true }`. The middleware is initialized as `Middleware.new(app, nil, options)` and receives the existing password filter block. Set `logger_enabled: false` to skip logging.
|
|
49
|
+
|
|
38
50
|
Once you have an authenticated client, you can validate any IBAN easily by using the validations service:
|
|
39
51
|
|
|
40
52
|
```rb
|
|
@@ -4,7 +4,7 @@ module Ibancom
|
|
|
4
4
|
module API
|
|
5
5
|
class ValidationService < Service
|
|
6
6
|
def validate(iban)
|
|
7
|
-
response = client.post("/v4/iban/", { iban: iban, sci: 1 })
|
|
7
|
+
response = client.post("/v4/iban/", { iban: iban, sci: 1, sci_tips: 1 })
|
|
8
8
|
Resources::IBAN::Validation.new(response, response.body)
|
|
9
9
|
end
|
|
10
10
|
|
data/lib/ibancom/client.rb
CHANGED
|
@@ -13,7 +13,7 @@ module Ibancom
|
|
|
13
13
|
|
|
14
14
|
BASE_URL = "https://api.iban.com/clients/api"
|
|
15
15
|
|
|
16
|
-
attr_reader :base_url, :user_agent, :proxy, :apikey, :logger_enabled
|
|
16
|
+
attr_reader :base_url, :user_agent, :proxy, :apikey, :logger_enabled, :logger_middleware, :logger_options
|
|
17
17
|
|
|
18
18
|
def initialize(options = {})
|
|
19
19
|
@base_url = options[:base_url] || BASE_URL
|
|
@@ -21,6 +21,8 @@ module Ibancom
|
|
|
21
21
|
@proxy = options[:proxy]
|
|
22
22
|
@apikey = options[:apikey] || ENV["IBANCOM_APIKEY"]
|
|
23
23
|
@logger_enabled = options[:logger_enabled].nil? ? true : options[:logger_enabled]
|
|
24
|
+
@logger_middleware = options.fetch(:logger_middleware, Faraday::Response::Logger)
|
|
25
|
+
@logger_options = options.fetch(:logger_options, {})
|
|
24
26
|
@services = {}
|
|
25
27
|
end
|
|
26
28
|
|
|
@@ -34,7 +36,7 @@ module Ibancom
|
|
|
34
36
|
parser_options: { symbolize_names: true }
|
|
35
37
|
builder.proxy = @proxy if proxy
|
|
36
38
|
if @logger_enabled
|
|
37
|
-
builder.
|
|
39
|
+
builder.use @logger_middleware, nil, { headers: true, bodies: true }.merge(@logger_options) do |logger|
|
|
38
40
|
logger.filter(/("password":)"(\w+)"/, '\1[FILTERED]')
|
|
39
41
|
end
|
|
40
42
|
end
|
data/lib/ibancom/version.rb
CHANGED