session-validator-client 5.0.0 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/session_validator/client.rb +7 -3
- data/session-validator-client.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d091acd762f22b286f6c92cde9e72642b8ff3919cbbc0df99e48a159c111d65a
|
4
|
+
data.tar.gz: af944e85aa7a0199f1ec0d115582046826f838124e04440e4106550512cde3c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bb739c2ae71f993ed3e7ed6a1309b8be0e25163afd858d09960071ba737e9ea380e2ab720ae7cd5993cc37307497f9311c8291761226dcc9ce46940300df310
|
7
|
+
data.tar.gz: 44cfd9d65bd547f96895971d5f796568a30a3e42115eb457a0a28b18e8ba717d573601bee8fa85428e85ad45c08b61d42758820bf771038b1149e17ec883c320
|
@@ -15,6 +15,10 @@ class SessionValidator::Client
|
|
15
15
|
SERVICE_REQUEST_TIMEOUT = 2.freeze
|
16
16
|
NETWORK_ERRORS = Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS + [Faraday::ConnectionFailed] - ['Timeout::Error']
|
17
17
|
|
18
|
+
def initialize(use_escher: true)
|
19
|
+
@use_escher = use_escher
|
20
|
+
end
|
21
|
+
|
18
22
|
def valid?(msid)
|
19
23
|
response_status = client.get("/sessions/#{msid}", nil, headers).status
|
20
24
|
(200..299).include?(response_status) || (500..599).include?(response_status)
|
@@ -23,7 +27,7 @@ class SessionValidator::Client
|
|
23
27
|
end
|
24
28
|
|
25
29
|
def filter_invalid(msids)
|
26
|
-
response = client.post("/sessions/filter", JSON.generate({msids: msids}), headers)
|
30
|
+
response = client.post("/sessions/filter", JSON.generate({ msids: msids }), headers)
|
27
31
|
if response.status == 200
|
28
32
|
JSON.parse(response.body)
|
29
33
|
else
|
@@ -40,7 +44,7 @@ class SessionValidator::Client
|
|
40
44
|
faraday.options[:open_timeout] = SERVICE_REQUEST_TIMEOUT
|
41
45
|
faraday.options[:timeout] = SERVICE_REQUEST_TIMEOUT
|
42
46
|
faraday.request :retry, interval: 0.05, interval_randomness: 0.5, backoff_factor: 2, methods: [:get, :post], exceptions: NETWORK_ERRORS
|
43
|
-
faraday.use
|
47
|
+
faraday.use(Faraday::Middleware::Escher::RequestSigner, escher_config) if @use_escher
|
44
48
|
faraday.adapter Faraday.default_adapter
|
45
49
|
end
|
46
50
|
end
|
@@ -67,6 +71,6 @@ class SessionValidator::Client
|
|
67
71
|
end
|
68
72
|
|
69
73
|
def headers
|
70
|
-
{"content-type" => "application/json"}
|
74
|
+
{ "content-type" => "application/json" }
|
71
75
|
end
|
72
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: session-validator-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emarsys Technologies Ltd.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: escher-keypool
|