luma 0.1.2 → 0.2.0
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 +4 -4
- data/CHANGELOG.md +23 -0
- data/README.md +7 -0
- data/lib/luma/appointment.rb +8 -16
- data/lib/luma/appointment_type.rb +13 -16
- data/lib/luma/authentication.rb +25 -10
- data/lib/luma/connection.rb +11 -5
- data/lib/luma/facilities.rb +7 -10
- data/lib/luma/models/patient_response.rb +30 -0
- data/lib/luma/patient.rb +8 -7
- data/lib/luma/provider.rb +7 -11
- data/lib/luma/response_data.rb +23 -0
- data/lib/luma/version.rb +1 -1
- data/lib/luma.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0a5471261caf0a2f46a1277261a6311ec609aadadd957384c796845467e4442
|
4
|
+
data.tar.gz: 442634ebdd3d19176a7a15f9aec977ca251216bdf972c47f024455eb4dcbc7c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 140255c76810710c84e041a9d91d17daf0d62d2d12deebbe4f25a511a91ca9a12528faa6d82951c62e02ec405bcfe100c5bec35b37def6c3a648e58f179db579
|
7
|
+
data.tar.gz: 504ccc244d416918a8e9f89990935db20e1770ca857178d745daa0c2168376d2c18f3d6b0e55d03e87b3b0be9c33af86cd5e9de3c4faceaebb8578a8387c554a
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,26 @@ 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.2.0] - 2022-05-04
|
7
|
+
|
8
|
+
### Added
|
9
|
+
- Luma::ResponseData object with recommend_retry? method
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
- Updated requests to return Luma::ResponseData object
|
13
|
+
|
14
|
+
## [0.1.4] - 2022-02-15
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
|
18
|
+
- Authentication accounts for token expiration
|
19
|
+
- Connection memoizes authentication
|
20
|
+
|
21
|
+
## [0.1.3] - 2022-02-10
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- Added API access for patient data (GET)
|
6
26
|
|
7
27
|
## [0.1.2] - 2022-01-13
|
8
28
|
|
@@ -75,6 +95,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
75
95
|
|
76
96
|
- Initial Create
|
77
97
|
|
98
|
+
[0.2.0]: https://github.com/WeInfuse/luma/compare/v0.1.4...v0.2.0
|
99
|
+
[0.1.4]: https://github.com/WeInfuse/luma/compare/v0.1.3...v0.1.4
|
100
|
+
[0.1.3]: https://github.com/WeInfuse/luma/compare/v0.1.2...v0.1.3
|
78
101
|
[0.1.2]: https://github.com/WeInfuse/luma/compare/v0.1.1...v0.1.2
|
79
102
|
[0.1.1]: https://github.com/WeInfuse/luma/compare/v0.1.0...v0.1.1
|
80
103
|
[0.1.0]: https://github.com/WeInfuse/luma/compare/v0.0.8...v0.1.0
|
data/README.md
CHANGED
@@ -74,6 +74,13 @@ patient_identifier = '12345a45b67c89101d2e3456'
|
|
74
74
|
Luma::Patient.new(email: email, password: password).update_patient(identifier: patient_identifier, body: body)
|
75
75
|
```
|
76
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
|
+
|
77
84
|
### Create Appointment
|
78
85
|
```ruby
|
79
86
|
body = Luma::Models::Appointment.new(
|
data/lib/luma/appointment.rb
CHANGED
@@ -1,23 +1,15 @@
|
|
1
1
|
module Luma
|
2
2
|
class Appointment < Connection
|
3
|
-
|
3
|
+
APPOINTMENT_ENDPOINT = '/api/appointments'.freeze
|
4
4
|
|
5
|
-
|
5
|
+
base_uri 'https://api.lumahealth.io/'.freeze
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
def create_appointment(endpoint: APPOINTMENT_ENDPOINT, body: nil, headers: {}, auth: true, verb: :post, debug_output: $stdout)
|
8
|
+
luma_request(auth: auth, body: body, endpoint: endpoint, verb: verb)
|
9
|
+
end
|
10
10
|
|
11
|
-
|
12
|
-
|
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
|
11
|
+
def update_appointment(appt_identifier, endpoint: APPOINTMENT_ENDPOINT, body: nil, headers: {}, auth: true, verb: :put, debug_output: $stdout)
|
12
|
+
luma_request(auth: auth, body: body, endpoint: endpoint, identifier: appt_identifier, verb: :put)
|
13
|
+
end
|
22
14
|
end
|
23
15
|
end
|
@@ -1,23 +1,20 @@
|
|
1
1
|
module Luma
|
2
|
-
|
3
|
-
|
2
|
+
class AppointmentType < Connection
|
3
|
+
APPOINTMENT_TYPE_ENDPOINT = '/api/appointmentTypes'.freeze
|
4
4
|
|
5
|
-
|
5
|
+
base_uri 'https://api.lumahealth.io/'.freeze
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
def view_appointment_types(endpoint: APPOINTMENT_TYPE_ENDPOINT, auth: true, name: nil, description: nil, debug_output: $stdout)
|
8
|
+
self.add_header if auth
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
url = "api/appointmentTypes?name=#{name}&description=#{description}"
|
11
|
+
full_url = "https://api.lumahealth.io/" + url
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
HTTParty.get(full_url.to_str, headers: @headers, debug_output: $stdout)
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
self.class.send(verb.to_s, endpoint, body: @body, headers: @headers, debug_output: $stdout)
|
21
|
-
end
|
22
|
-
end
|
16
|
+
def create_appointment_type(endpoint: APPOINTMENT_TYPE_ENDPOINT, body: nil, headers: {}, auth: true, verb: :post, debug_output: $stdout)
|
17
|
+
luma_request(auth: auth, body: body, endpoint: endpoint, verb: verb)
|
18
|
+
end
|
19
|
+
end
|
23
20
|
end
|
data/lib/luma/authentication.rb
CHANGED
@@ -14,18 +14,21 @@ module Luma
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def authenticate
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
if (self.expires?)
|
18
|
+
request = {
|
19
|
+
body: { email: email, password: password },
|
20
|
+
endpoint: AUTH_ENDPOINT
|
21
|
+
}
|
21
22
|
|
22
|
-
|
23
|
+
response = self.request(**request, auth: false)
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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,
|
data/lib/luma/connection.rb
CHANGED
@@ -24,17 +24,23 @@ module Luma
|
|
24
24
|
self.class.send("#{verb}", endpoint, body: body, headers: headers)
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
@body = @body.to_json
|
29
|
-
@headers = auth_header.merge(@headers)
|
27
|
+
def add_header
|
30
28
|
@headers["Content-Type"] = 'application/json'
|
31
29
|
end
|
32
30
|
|
31
|
+
def luma_request(auth:, body:, endpoint:, verb:, identifier: nil)
|
32
|
+
@body = body
|
33
|
+
self.add_header if auth
|
34
|
+
|
35
|
+
endpoint = "#{endpoint}/#{identifier}" unless identifier.nil?
|
36
|
+
|
37
|
+
Luma::ResponseData.new(response: self.request(endpoint: endpoint, body: @body, headers: @headers, auth: auth, verb: verb))
|
38
|
+
end
|
39
|
+
|
33
40
|
private
|
34
41
|
|
35
42
|
def auth_header
|
36
|
-
@auth
|
37
|
-
|
43
|
+
@auth ||= Authentication.new(email: @email, password: @password)
|
38
44
|
return @auth.authenticate.access_header
|
39
45
|
end
|
40
46
|
end
|
data/lib/luma/facilities.rb
CHANGED
@@ -1,14 +1,11 @@
|
|
1
1
|
module Luma
|
2
|
-
|
3
|
-
|
2
|
+
class Facilities < Connection
|
3
|
+
FACILITY_ENDPOINT = '/api/facilities'.freeze
|
4
4
|
|
5
|
-
|
5
|
+
base_uri 'https://api.lumahealth.io/'.freeze
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
self.class.send(verb.to_s, endpoint, body: @body, headers: @headers)
|
12
|
-
end
|
13
|
-
end
|
7
|
+
def create_facility(endpoint: FACILITY_ENDPOINT, body: nil, headers: {}, auth: true, verb: :post, debug_output: $stdout)
|
8
|
+
luma_request(auth: auth, body: body, endpoint: endpoint, verb: verb)
|
9
|
+
end
|
10
|
+
end
|
14
11
|
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
@@ -5,19 +5,20 @@ module Luma
|
|
5
5
|
base_uri 'https://api.lumahealth.io/'.freeze
|
6
6
|
|
7
7
|
def create_patient(endpoint: PATIENT_ENDPOINT, body: nil, headers: {}, auth: true, verb: :post, debug_output: $stdout)
|
8
|
-
|
9
|
-
self.add_headers_and_body if auth
|
10
|
-
|
11
|
-
self.class.send(verb.to_s, endpoint, body: @body, headers: @headers)
|
8
|
+
luma_request(auth: auth, body: body, endpoint: endpoint, verb: verb)
|
12
9
|
end
|
13
10
|
|
14
11
|
def update_patient(identifier:, endpoint: PATIENT_ENDPOINT, body: nil, headers: {}, auth: true, verb: :put, debug_output: $stdout)
|
15
|
-
|
16
|
-
|
12
|
+
luma_request(auth: auth, body: body, endpoint: endpoint, identifier: identifier, verb: verb)
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_patient(identifier:, endpoint: PATIENT_ENDPOINT, headers: {}, auth: true, verb: :get, debug_output: $stdout)
|
16
|
+
self.add_header if auth
|
17
17
|
|
18
18
|
endpoint = "#{endpoint}/#{identifier}"
|
19
19
|
|
20
|
-
self.
|
20
|
+
response = self.request(endpoint: endpoint, headers: @headers, auth: auth, verb: verb)
|
21
|
+
Luma::Models::PatientResponse.new(response: response)
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
data/lib/luma/provider.rb
CHANGED
@@ -1,15 +1,11 @@
|
|
1
1
|
module Luma
|
2
|
-
|
3
|
-
|
2
|
+
class Provider < Connection
|
3
|
+
PROVIDER_ENDPOINT = '/api/providers'.freeze
|
4
4
|
|
5
|
-
|
5
|
+
base_uri 'https://api.lumahealth.io/'.freeze
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
self.class.send(verb.to_s, endpoint, body: @body, headers: @headers, debug_output: $stdout)
|
13
|
-
end
|
14
|
-
end
|
7
|
+
def create_provider(endpoint: PROVIDER_ENDPOINT, body: nil, headers: {}, auth: true, verb: :post)
|
8
|
+
luma_request(auth: auth, body: body, endpoint: endpoint, verb: verb)
|
9
|
+
end
|
10
|
+
end
|
15
11
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Luma
|
2
|
+
class ResponseData
|
3
|
+
attr_reader :response, :raw
|
4
|
+
|
5
|
+
BAD_GATEWAY_CODE = 502.freeze
|
6
|
+
RETRYABLE_CODES = [BAD_GATEWAY_CODE].freeze
|
7
|
+
|
8
|
+
def initialize(response: nil)
|
9
|
+
@response = response
|
10
|
+
|
11
|
+
begin
|
12
|
+
@raw ||= response&.parsed_response
|
13
|
+
rescue JSON::ParserError
|
14
|
+
end
|
15
|
+
|
16
|
+
@raw ||= {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def recommend_retry?
|
20
|
+
return true if RETRYABLE_CODES.include? response.code
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/luma/version.rb
CHANGED
data/lib/luma.rb
CHANGED
@@ -10,9 +10,11 @@ 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'
|
17
|
+
require 'luma/response_data'
|
16
18
|
|
17
19
|
module Luma
|
18
20
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Angela Rodriguez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -165,8 +165,10 @@ 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
|
171
|
+
- lib/luma/response_data.rb
|
170
172
|
- lib/luma/version.rb
|
171
173
|
- luma.gemspec
|
172
174
|
homepage: https://github.com/WeInfuse/luma
|