whiplash-app 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/whiplash/app.rb +8 -1
- data/lib/whiplash/app/caching.rb +2 -2
- data/lib/whiplash/app/connections.rb +1 -1
- data/lib/whiplash/app/version.rb +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: af0e2584ec8d271d28ae6e773358050f539cc0a49f260507900cdfd2f9cb8d37
|
4
|
+
data.tar.gz: c56bd7ecbc582ebf360a71f142098b1043975c65cc54254469a80aa308d656c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d937fbb0f4e06b25efee934edef18e7a791a67b3c24a12a07b6757253458b0a9d35acde7ecc9f7de78f2ffa86a3650ace8c595d1ad15e5557e35ff23b23534eb
|
7
|
+
data.tar.gz: 345f2b474912b83daa0f6c8e0ee11b9dccc154d9353248da8f92142b0f27e659e7700cd6cd5c388c86a47be913668d1c1d060081dcf04366abfb20eba928e081
|
data/lib/whiplash/app.rb
CHANGED
@@ -20,11 +20,18 @@ module Whiplash
|
|
20
20
|
|
21
21
|
def initialize(token=nil, options={})
|
22
22
|
opts = options.with_indifferent_access
|
23
|
+
token ||= cache_store["whiplash_api_token"]
|
23
24
|
@token = format_token(token) unless token.nil?
|
24
25
|
@customer_id = options[:customer_id]
|
25
26
|
@shop_id = options[:shop_id]
|
26
27
|
end
|
27
28
|
|
29
|
+
def self.whiplash_api_token
|
30
|
+
store = Moneta.new(:Redis, host: ENV["REDIS_HOST"], port: ENV["REDIS_PORT"], password: ENV["REDIS_PASSWORD"], expires: 7200)
|
31
|
+
cache_store = Moneta::Namespace.new store, Whiplash::App::Caching.namespace_value
|
32
|
+
cache_store["whiplash_api_token"]
|
33
|
+
end
|
34
|
+
|
28
35
|
def client
|
29
36
|
OAuth2::Client.new(ENV["WHIPLASH_CLIENT_ID"], ENV["WHIPLASH_CLIENT_SECRET"], site: api_url)
|
30
37
|
end
|
@@ -57,7 +64,7 @@ module Whiplash
|
|
57
64
|
|
58
65
|
def token_expired?
|
59
66
|
return token.expired? unless token.blank?
|
60
|
-
return true unless cache_store.
|
67
|
+
return true unless cache_store.key?("whiplash_api_token")
|
61
68
|
return true if cache_store["whiplash_api_token"].blank?
|
62
69
|
false
|
63
70
|
end
|
data/lib/whiplash/app/caching.rb
CHANGED
@@ -7,13 +7,13 @@ module Whiplash
|
|
7
7
|
def cache_store
|
8
8
|
if ENV["REDIS_HOST"]
|
9
9
|
store = Moneta.new(:Redis, host: ENV["REDIS_HOST"], port: ENV["REDIS_PORT"], password: ENV["REDIS_PASSWORD"], expires: 7200)
|
10
|
-
Moneta::Namespace.new store, namespace_value
|
10
|
+
Moneta::Namespace.new store, Whiplash::App::Caching.namespace_value
|
11
11
|
else
|
12
12
|
Moneta.new(:File, dir: "tmp", expires: 7200)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def namespace_value
|
16
|
+
def self.namespace_value
|
17
17
|
ENV["REDIS_NAMESPACE"] || ENV["WHIPLASH_CLIENT_ID"]
|
18
18
|
end
|
19
19
|
|
@@ -33,7 +33,7 @@ module Whiplash
|
|
33
33
|
def app_request!(options = {})
|
34
34
|
begin
|
35
35
|
response = app_request(options)
|
36
|
-
return response
|
36
|
+
return response if response.success?
|
37
37
|
message = response.body if response.body.is_a? String
|
38
38
|
message = response.body.dig('error') if response.body.respond_to?(:dig)
|
39
39
|
store_whiplash_error!(response.status)
|
data/lib/whiplash/app/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whiplash-app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Don Sullivan, Mark Dickson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|