luma 0.1.3 → 0.1.4

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: f722a4bfdbfbdc81d2e9b85e52c8dd78aef2fdd64df668be3424bcbec766876d
4
- data.tar.gz: 21be1a31248e6787d5b2b6a272a5d0ef424dcc01564a5a6e2942a880a4108014
3
+ metadata.gz: 31e15523557fdb75d2fc4884ed91488fcbce40cfc380d346a70d1aa725fcc510
4
+ data.tar.gz: 48106270eb2c8b3f9cdca4abd859c9ef3516545cb43a253277fe906514728d0f
5
5
  SHA512:
6
- metadata.gz: 6cfc178b60a519cfe2fec7d61c0aa26e410e5a47dc2c743239cfeb275f97548366ea7e61961cad3d1495df2696e6c66421126f1a98200963c855291cf1653fe1
7
- data.tar.gz: d39c57e2e8c78fe22f425fdbf560691907f308b4ae2e4e4553f5f4b362dbc4fc07e1f83ea4d42bc452adfb95e9b5af3470343073e83d6f6b618917ec7fc084c5
6
+ metadata.gz: 51a4eb724be12656f1fb90ba7458724812db5a5fa7649dffd10e98c45cdb929586d2e1b8b156eac188dc21e6f429f439b82122b50e9af70abb0cd96e31f8a73e
7
+ data.tar.gz: 1bc827dff83cc98e23f1caf966802f0f886a858fbca374c124e923ce83d34eddb24e2967fa33b3de0015bba5025cf58ab4245cd44a8f0408cece7f13e0823bd0
data/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+ ## [0.1.4] - 2022-02-15
7
+
8
+ ### Changed
9
+
10
+ - Authentication accounts for token expiration
11
+ - Connection memoizes authentication
12
+
6
13
  ## [0.1.3] - 2022-02-10
7
14
 
8
15
  ### Changed
@@ -80,6 +87,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
80
87
 
81
88
  - Initial Create
82
89
 
90
+ [0.1.4]: https://github.com/WeInfuse/luma/compare/v0.1.3...v0.1.4
83
91
  [0.1.3]: https://github.com/WeInfuse/luma/compare/v0.1.2...v0.1.3
84
92
  [0.1.2]: https://github.com/WeInfuse/luma/compare/v0.1.1...v0.1.2
85
93
  [0.1.1]: https://github.com/WeInfuse/luma/compare/v0.1.0...v0.1.1
@@ -14,18 +14,21 @@ module Luma
14
14
  end
15
15
 
16
16
  def authenticate
17
- request = {
18
- body: { email: email, password: password },
19
- endpoint: AUTH_ENDPOINT
20
- }
17
+ if (self.expires?)
18
+ request = {
19
+ body: { email: email, password: password },
20
+ endpoint: AUTH_ENDPOINT
21
+ }
21
22
 
22
- response = self.request(**request, auth: false)
23
+ response = self.request(**request, auth: false)
23
24
 
24
- if (false == response.ok?)
25
- @response = nil
26
- raise LumaException.from_response(response, msg: 'Authentication')
27
- else
28
- @response = response
25
+ if (false == response.ok?)
26
+ @response = nil
27
+ raise LumaException.from_response(response, msg: 'Authentication')
28
+ else
29
+ @response = response
30
+ validate
31
+ end
29
32
  end
30
33
 
31
34
  return self
@@ -51,6 +54,18 @@ module Luma
51
54
  return @response['token'] if @response
52
55
  end
53
56
 
57
+ def expiry
58
+ return @validation_response['exp'] if @validation_response
59
+ end
60
+
61
+ def expires?
62
+ if (self.expiry)
63
+ return (self.expiry / 1000) <= Time.now.to_f.floor
64
+ else
65
+ return true
66
+ end
67
+ end
68
+
54
69
  def access_header
55
70
  return {
56
71
  'X-Access-Token' => self.access_token,
@@ -33,8 +33,7 @@ module Luma
33
33
  private
34
34
 
35
35
  def auth_header
36
- @auth = Authentication.new(email: @email, password: @password)
37
-
36
+ @auth ||= Authentication.new(email: @email, password: @password)
38
37
  return @auth.authenticate.access_header
39
38
  end
40
39
  end
data/lib/luma/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Luma
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Angela Rodriguez
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-10 00:00:00.000000000 Z
11
+ date: 2022-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -142,7 +142,7 @@ dependencies:
142
142
  - - ">="
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
- description:
145
+ description:
146
146
  email:
147
147
  - angela.rodriguez@weinfuse.com
148
148
  executables: []
@@ -175,7 +175,7 @@ licenses:
175
175
  - MIT
176
176
  metadata:
177
177
  allowed_push_host: https://rubygems.org
178
- post_install_message:
178
+ post_install_message:
179
179
  rdoc_options: []
180
180
  require_paths:
181
181
  - lib
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  version: '0'
192
192
  requirements: []
193
193
  rubygems_version: 3.1.4
194
- signing_key:
194
+ signing_key:
195
195
  specification_version: 4
196
196
  summary: Ruby wrapper for the Luma Health API
197
197
  test_files: []