dock_health_api 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60108cba91179c4029f17053daa0ee7cde2e6a067e48e35461db07e8c2bcefc0
4
- data.tar.gz: 49fd631f9c4f65bc3bdf7570848dad0f6da8a387b67bf65e0b0ff1d2ae8feb31
3
+ metadata.gz: 744bfe703e4f755b8a9b1e17713dc55e65d1a03f1e11de51fd0d684c3f031afb
4
+ data.tar.gz: 89dcf95b0ad77852e57e7ebe60b8c542f45758f986a702f2e72285f869a92fbd
5
5
  SHA512:
6
- metadata.gz: 839de68118bab1fb66bc0136ac1d5f53e8585cbcd97a393bd59a767357c94ee8d19c11df84f014c9ccccd0e1829d67a0087ab596fbaa8227d138572b52e26e83
7
- data.tar.gz: '0498a398b03fe384825157e1ee6d0135315443edb6ba97d5dd330a5e9d057eff3cf8a70d73e60ffad2231a01e528197046f5bdb9b4c68561626403106dcabd3f'
6
+ metadata.gz: 6f2bc2e66d7adee6e4984d7a21e05c91c7a24b5cd5d37fa850111ecdf004fc306e11812f4d4db48862ef9424457b2ee0495fc39b70ac4711e128439735bacac3
7
+ data.tar.gz: 3a986259f4154205e21a4b935bd981276b4ecd5139ced86486cfe18657c5107e177124ee1acc9733389d134b0e4ccdb621d73920a2fe1ff47bbd3b95f72135a1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dock_health_api (0.5.7)
4
+ dock_health_api (0.5.8)
5
5
  oauth2 (~> 1.4)
6
6
  ostruct
7
7
  rspec (~> 3.0)
@@ -6,17 +6,13 @@ module DockHealthApi
6
6
  BUFFER = 120
7
7
 
8
8
  include Singleton
9
-
9
+
10
10
  attr_reader :config
11
11
 
12
12
  def initialize
13
13
  @config = DockHealthApi.config
14
14
  end
15
15
 
16
- def active_client
17
- instance
18
- end
19
-
20
16
  def connection
21
17
  @connection ||= OAuth2::Client.new(config.api_key, config.api_secret, token_url: config.token_url, raise_errors: false)
22
18
  end
@@ -35,10 +31,18 @@ module DockHealthApi
35
31
  end
36
32
 
37
33
  def iframe_token_connection
38
- get_iframe_token
34
+ get_iframe_token if @iframe_token_connection.nil? || iframe_token_about_to_expire?
39
35
  @iframe_token_connection
40
36
  end
41
37
 
38
+ def iframe_token_expiration_time
39
+ @iframe_token_expiration_time ||= Time.now + @iframe_token_connection.expires_in
40
+ end
41
+
42
+ def iframe_token_about_to_expire?
43
+ Time.now + BUFFER > iframe_token_expiration_time
44
+ end
45
+
42
46
  def token
43
47
  @token ||= token_connection.token
44
48
  end
@@ -56,8 +60,8 @@ module DockHealthApi
56
60
  def get_iframe_token
57
61
  @iframe_token_connection = connection.client_credentials.get_token(scope:"dockhealth/system.embedded.launch")
58
62
  return @iframe_token_connection if @iframe_token_connection.nil?
59
- DockHealthApi.iframe_token = @iframe_token_connection.token
60
- DockHealthApi.iframe_token_expires_at = Time.now + @iframe_token_connection.expires_in
63
+ @iframe_token_expiration_time = Time.now + @iframe_token_connection.expires_in
64
+ @iframe_token_connection
61
65
  end
62
66
  end
63
67
  end
@@ -8,10 +8,6 @@ module DockHealthApi
8
8
  :org_id,
9
9
  :user_id,
10
10
  :api,
11
- :iframe_token,
12
- :token,
13
- :iframe_token_expires_at,
14
- :token_expires_at,
15
11
  :debug,
16
12
  :iframe_base_url
17
13
  end
@@ -1,3 +1,3 @@
1
1
  module DockHealthApi
2
- VERSION = "0.5.7"
2
+ VERSION = "0.5.8"
3
3
  end
@@ -45,24 +45,19 @@ module DockHealthApi
45
45
  def_delegators :@config, :org_id, :org_id=
46
46
  def_delegators :@config, :user_id, :user_id=
47
47
  def_delegators :@config, :api, :api=
48
- def_delegators :@config, :iframe_token, :iframe_token=
49
- def_delegators :@config, :iframe_token_expires_at, :iframe_token_expires_at=
50
- def_delegators :@config, :token, :token=
51
- def_delegators :@config, :token_expires_at, :token_expires_at=
52
48
  def_delegators :@config, :debug, :debug=
53
49
  def_delegators :@config, :iframe_base_url, :iframe_base_url=
54
50
 
55
51
  def receive_iframe_token
56
- Client.instance.iframe_token_connection if iframe_token_expired?
52
+ @receive_iframe_token ||= Client.instance.iframe_token_connection
57
53
  end
58
54
 
59
- def iframe_token_expired?
60
- return Time.now > self.iframe_token_expires_at if self.iframe_token_expires_at
61
- true
55
+ def iframe_token
56
+ receive_iframe_token.token
62
57
  end
63
58
 
64
59
  def iframe_url(arg={})
65
- DockHealthApi.receive_iframe_token
60
+ receive_iframe_token
66
61
  dock_user_id = arg[:user_id]
67
62
  view_type = arg[:view_type]
68
63
  target_type = arg[:target_type]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dock_health_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Magomero
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-01-19 00:00:00.000000000 Z
12
+ date: 2023-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2