whiplash-app 0.6.0 → 0.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29188ceeacb00228aee15d9f56ab151aac8b491c43b05463d25e648114fbb8ac
4
- data.tar.gz: 93b8d38a3809d3e30d570f4acfe1ad3007f3754273d2ae1cf7299f3f4ce0f113
3
+ metadata.gz: af0e2584ec8d271d28ae6e773358050f539cc0a49f260507900cdfd2f9cb8d37
4
+ data.tar.gz: c56bd7ecbc582ebf360a71f142098b1043975c65cc54254469a80aa308d656c4
5
5
  SHA512:
6
- metadata.gz: 8a952642f993be0711907cbef3567362f7eb55026c43f22a2d0a1a83e40c24742d5f26db1e9ab0ca36ad7ca8479c9b04e3dc5b930cc8eebfa97b09a7d9e834ca
7
- data.tar.gz: a2e597b3658c0cdfec8727e44f91a5b6050871ab62d876f59fddcfb8c9412aba62bd0ecac8a4d300ffc5a85002553e746234cde7b70bbdf29c656655fff43a87
6
+ metadata.gz: d937fbb0f4e06b25efee934edef18e7a791a67b3c24a12a07b6757253458b0a9d35acde7ecc9f7de78f2ffa86a3650ace8c595d1ad15e5557e35ff23b23534eb
7
+ data.tar.gz: 345f2b474912b83daa0f6c8e0ee11b9dccc154d9353248da8f92142b0f27e659e7700cd6cd5c388c86a47be913668d1c1d060081dcf04366abfb20eba928e081
@@ -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.has_key?("whiplash_api_token")
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
@@ -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.body if response.success?
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)
@@ -1,5 +1,5 @@
1
1
  module Whiplash
2
2
  class App
3
- VERSION = "0.6.0"
3
+ VERSION = "0.6.1"
4
4
  end
5
5
  end
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.0
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-26 00:00:00.000000000 Z
11
+ date: 2020-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2