luma 0.1.0 → 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: 0b1c0cd76f2a756cf7bc743c37bff453c3ec10296f0b454b76666a8e4f55a858
4
- data.tar.gz: 6fff9b6757c64c9449f64f54afaafa1bac2f183a6b7452dce7e35eaaf1d1c3b6
3
+ metadata.gz: 31e15523557fdb75d2fc4884ed91488fcbce40cfc380d346a70d1aa725fcc510
4
+ data.tar.gz: 48106270eb2c8b3f9cdca4abd859c9ef3516545cb43a253277fe906514728d0f
5
5
  SHA512:
6
- metadata.gz: e06a22f14e2f101dafd0669d60f1ec04a8e924ab0cdf8576faf9aa21f661433d05ac971cb590fdd8bb019519bd84d4c0a6e7fa29515b8d850c93f2abd45dd035
7
- data.tar.gz: 0f9b502a82e0ee14568d8cc7b15b7e09c8b80003b148506a1e04a2c299169686411ee603b735f3584e58d3435fc70fe353554c2bd51d3a6d02df589faebb71b4
6
+ metadata.gz: 51a4eb724be12656f1fb90ba7458724812db5a5fa7649dffd10e98c45cdb929586d2e1b8b156eac188dc21e6f429f439b82122b50e9af70abb0cd96e31f8a73e
7
+ data.tar.gz: 1bc827dff83cc98e23f1caf966802f0f886a858fbca374c124e923ce83d34eddb24e2967fa33b3de0015bba5025cf58ab4245cd44a8f0408cece7f13e0823bd0
data/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@ 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
+
13
+ ## [0.1.3] - 2022-02-10
14
+
15
+ ### Changed
16
+
17
+ - Added API access for patient data (GET)
18
+
19
+ ## [0.1.2] - 2022-01-13
20
+
21
+ ### Changed
22
+
23
+ - Added API access for updating a patient (PUT)
24
+
25
+ ## [0.1.1] - 2021-11-16
26
+
27
+ ### Changed
28
+
29
+ - Added API access for updating an appointment (PUT)
6
30
 
7
31
  ## [0.1.0] - 2021-11-10
8
32
 
@@ -63,6 +87,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
63
87
 
64
88
  - Initial Create
65
89
 
90
+ [0.1.4]: https://github.com/WeInfuse/luma/compare/v0.1.3...v0.1.4
91
+ [0.1.3]: https://github.com/WeInfuse/luma/compare/v0.1.2...v0.1.3
92
+ [0.1.2]: https://github.com/WeInfuse/luma/compare/v0.1.1...v0.1.2
93
+ [0.1.1]: https://github.com/WeInfuse/luma/compare/v0.1.0...v0.1.1
66
94
  [0.1.0]: https://github.com/WeInfuse/luma/compare/v0.0.8...v0.1.0
67
95
  [0.0.8]: https://github.com/WeInfuse/luma/compare/v0.0.7...v0.0.8
68
96
  [0.0.7]: https://github.com/WeInfuse/luma/compare/v0.0.6...v0.0.7
data/README.md CHANGED
@@ -66,6 +66,21 @@ body = Luma::Models::Patient.new(first_name: 'Ruby',
66
66
  Luma::Patient.new(email: email, password: password).create_patient(body: body)
67
67
  ```
68
68
 
69
+ ### Update Patient
70
+ ```ruby
71
+ body = Luma::Models::Patient.new(address: '456 Old Main')
72
+ patient_identifier = '12345a45b67c89101d2e3456'
73
+
74
+ Luma::Patient.new(email: email, password: password).update_patient(identifier: patient_identifier, body: body)
75
+ ```
76
+
77
+ ### GET Patient
78
+ ```ruby
79
+ patient_identifier = '12345a45b67c89101d2e3456'
80
+
81
+ Luma::Patient.new(email: email, password: password).get_patient(identifier: patient_identifier)
82
+ ```
83
+
69
84
  ### Create Appointment
70
85
  ```ruby
71
86
  body = Luma::Models::Appointment.new(
@@ -81,6 +96,15 @@ body = Luma::Models::Appointment.new(
81
96
  Luma::Appointment.new(email: email, password: password).create_appointment(body: body)
82
97
  ```
83
98
 
99
+ ### Update Appointment
100
+ ```ruby
101
+ body = {
102
+ appt_duration: '60'
103
+ }
104
+
105
+ Luma::Appointment.new(email: email, password: password).update_appointment('appointment_id', body: body)
106
+ ```
107
+
84
108
  ## Development
85
109
 
86
110
  ### Prep
@@ -10,5 +10,14 @@ module Luma
10
10
 
11
11
  self.class.send(verb.to_s, endpoint, body: @body, headers: @headers)
12
12
  end
13
+
14
+ def update_appointment(appt_identifier, endpoint: APPOINTMENT_ENDPOINT, body: nil, headers: {}, auth: true, verb: :put, debug_output: $stdout)
15
+ @body = body
16
+ self.add_headers_and_body if auth
17
+
18
+ endpoint = "#{endpoint}/#{appt_identifier}"
19
+
20
+ self.class.send(verb.to_s, endpoint, body: @body, headers: @headers)
21
+ end
13
22
  end
14
23
  end
@@ -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
@@ -0,0 +1,30 @@
1
+ module Luma
2
+ module Models
3
+ class PatientResponse
4
+ attr_reader :data
5
+
6
+ def initialize(data: nil, response: nil)
7
+ @data = data
8
+ @data = response.parsed_response if @data.nil? && response && response.ok?
9
+ @data ||= {}
10
+ @response = response
11
+ end
12
+
13
+ def do_not_contact
14
+ @data['doNotContact']
15
+ end
16
+
17
+ def contact
18
+ @data['contact']
19
+ end
20
+
21
+ def ok?
22
+ @response&.ok?
23
+ end
24
+
25
+ def errors?
26
+ !@data['errors'].nil? && !@data['errors'].empty?
27
+ end
28
+ end
29
+ end
30
+ end
data/lib/luma/patient.rb CHANGED
@@ -1,14 +1,33 @@
1
1
  module Luma
2
2
  class Patient < Connection
3
- PATIENT_ENDPOINT = '/api/patients'.freeze
3
+ PATIENT_ENDPOINT = '/api/patients'.freeze
4
4
 
5
- base_uri 'https://api.lumahealth.io/'.freeze
5
+ base_uri 'https://api.lumahealth.io/'.freeze
6
6
 
7
- def create_patient(endpoint: PATIENT_ENDPOINT, body: nil, headers: {}, auth: true, verb: :post, debug_output: $stdout)
8
- @body = body
9
- self.add_headers_and_body if auth
7
+ def create_patient(endpoint: PATIENT_ENDPOINT, body: nil, headers: {}, auth: true, verb: :post, debug_output: $stdout)
8
+ @body = body
9
+ self.add_headers_and_body if auth
10
10
 
11
- self.class.send(verb.to_s, endpoint, body: @body, headers: @headers)
12
- end
11
+ self.class.send(verb.to_s, endpoint, body: @body, headers: @headers)
12
+ end
13
+
14
+ def update_patient(identifier:, endpoint: PATIENT_ENDPOINT, body: nil, headers: {}, auth: true, verb: :put, debug_output: $stdout)
15
+ @body = body
16
+ self.add_headers_and_body if auth
17
+
18
+ endpoint = "#{endpoint}/#{identifier}"
19
+
20
+ self.class.send(verb.to_s, endpoint, body: @body, headers: @headers)
21
+ end
22
+
23
+ def get_patient(identifier:, endpoint: PATIENT_ENDPOINT, headers: {}, auth: true, verb: :get, debug_output: $stdout)
24
+ self.add_headers_and_body if auth
25
+
26
+ endpoint = "#{endpoint}/#{identifier}"
27
+
28
+ response = self.class.send(verb.to_s, endpoint, headers: @headers)
29
+
30
+ Luma::Models::PatientResponse.new(response: response)
31
+ end
13
32
  end
14
33
  end
data/lib/luma/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Luma
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
data/lib/luma.rb CHANGED
@@ -10,6 +10,7 @@ require 'luma/facilities'
10
10
  require 'luma/patient'
11
11
  require 'luma/models/contact'
12
12
  require 'luma/models/date_of_birth'
13
+ require 'luma/models/patient_response'
13
14
  require 'luma/models/patient'
14
15
  require 'luma/appointment'
15
16
  require 'luma/models/appointment'
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.0
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Angela Rodriguez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-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
@@ -165,6 +165,7 @@ files:
165
165
  - lib/luma/models/contact.rb
166
166
  - lib/luma/models/date_of_birth.rb
167
167
  - lib/luma/models/patient.rb
168
+ - lib/luma/models/patient_response.rb
168
169
  - lib/luma/patient.rb
169
170
  - lib/luma/provider.rb
170
171
  - lib/luma/version.rb