luma 0.1.3 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -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/contact.rb +1 -1
- data/lib/luma/patient.rb +4 -13
- 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 +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d3915bbf6dc23b7c8cd06e63ac1e36c6b3a3930f654c9307920dd55077f15b0
|
4
|
+
data.tar.gz: 8852faa9418bbbe6fb3e2b5b8cd9ecfdc91a6349ce298060642667d545ed7473
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f5724cf37277996895d9646d4c8e6b5a46411668034b788078e829583781c13742687bf877d6d33808b6d21fe79fe826260adf64a1c8299070f224ccd4f6c43
|
7
|
+
data.tar.gz: 901b3c31e7e98a055136a9ed8d88674735a5a2d92b42e3d49b5c8ebd99491e43b4ee14716b6e6fdcce69c79c4a85b492b0e3b9529df0f4974d4a32971f5b5fdc
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,28 @@ 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
|
+
|
7
|
+
## [0.2.1] - 2022-05-17
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
- Removed default value for the property active on contact model
|
12
|
+
|
13
|
+
## [0.2.0] - 2022-05-04
|
14
|
+
|
15
|
+
### Added
|
16
|
+
- Luma::ResponseData object with recommend_retry? method
|
17
|
+
|
18
|
+
### Changed
|
19
|
+
- Updated requests to return Luma::ResponseData object
|
20
|
+
|
21
|
+
## [0.1.4] - 2022-02-15
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- Authentication accounts for token expiration
|
26
|
+
- Connection memoizes authentication
|
27
|
+
|
6
28
|
## [0.1.3] - 2022-02-10
|
7
29
|
|
8
30
|
### Changed
|
@@ -80,6 +102,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
80
102
|
|
81
103
|
- Initial Create
|
82
104
|
|
105
|
+
[0.2.1]: https://github.com/WeInfuse/luma/compare/v0.2.0...v0.2.1
|
106
|
+
[0.2.0]: https://github.com/WeInfuse/luma/compare/v0.1.4...v0.2.0
|
107
|
+
[0.1.4]: https://github.com/WeInfuse/luma/compare/v0.1.3...v0.1.4
|
83
108
|
[0.1.3]: https://github.com/WeInfuse/luma/compare/v0.1.2...v0.1.3
|
84
109
|
[0.1.2]: https://github.com/WeInfuse/luma/compare/v0.1.1...v0.1.2
|
85
110
|
[0.1.1]: https://github.com/WeInfuse/luma/compare/v0.1.0...v0.1.1
|
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
|
data/lib/luma/models/contact.rb
CHANGED
data/lib/luma/patient.rb
CHANGED
@@ -5,28 +5,19 @@ 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
|
-
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)
|
12
|
+
luma_request(auth: auth, body: body, endpoint: endpoint, identifier: identifier, verb: verb)
|
21
13
|
end
|
22
14
|
|
23
15
|
def get_patient(identifier:, endpoint: PATIENT_ENDPOINT, headers: {}, auth: true, verb: :get, debug_output: $stdout)
|
24
|
-
self.
|
16
|
+
self.add_header if auth
|
25
17
|
|
26
18
|
endpoint = "#{endpoint}/#{identifier}"
|
27
19
|
|
28
|
-
response = self.
|
29
|
-
|
20
|
+
response = self.request(endpoint: endpoint, headers: @headers, auth: auth, verb: verb)
|
30
21
|
Luma::Models::PatientResponse.new(response: response)
|
31
22
|
end
|
32
23
|
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
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
|
4
|
+
version: 0.2.1
|
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-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- lib/luma/models/patient_response.rb
|
169
169
|
- lib/luma/patient.rb
|
170
170
|
- lib/luma/provider.rb
|
171
|
+
- lib/luma/response_data.rb
|
171
172
|
- lib/luma/version.rb
|
172
173
|
- luma.gemspec
|
173
174
|
homepage: https://github.com/WeInfuse/luma
|