luma 0.0.8 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 154f08ce7d11575161ae8c86c50e69caa8194a205562e94d340591bfaa6dd906
4
- data.tar.gz: 2e29bfa638c795d4708e449ca8fbfc93a6ed23d9eed67c075687bd4b6eee158c
3
+ metadata.gz: 0b1c0cd76f2a756cf7bc743c37bff453c3ec10296f0b454b76666a8e4f55a858
4
+ data.tar.gz: 6fff9b6757c64c9449f64f54afaafa1bac2f183a6b7452dce7e35eaaf1d1c3b6
5
5
  SHA512:
6
- metadata.gz: f8d86c0863c92155c7e4700ab0cc827a4b4b10e1a6985f158427db84144f971e1764696616d0f5416d2bed915b53e8f881a7751aae1e20cc46c835b685b852ca
7
- data.tar.gz: 8f12b4d72357213e5db9e6f5c110abccced32403344541d57bf1edf2288d188143e0060a7183cbe26a4cb3ffb2c3bf1babe3443cdf58eb981266030425a9f7b4
6
+ metadata.gz: e06a22f14e2f101dafd0669d60f1ec04a8e924ab0cdf8576faf9aa21f661433d05ac971cb590fdd8bb019519bd84d4c0a6e7fa29515b8d850c93f2abd45dd035
7
+ data.tar.gz: 0f9b502a82e0ee14568d8cc7b15b7e09c8b80003b148506a1e04a2c299169686411ee603b735f3584e58d3435fc70fe353554c2bd51d3a6d02df589faebb71b4
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
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
6
 
7
+ ## [0.1.0] - 2021-11-10
8
+
9
+ ### Changed
10
+
11
+ - Removed global configuration of API credentials
12
+ - Added required email and password parameters to Authentication as API user is client-specific.
13
+
7
14
  ## [0.0.8] - 2021-11-02
8
15
 
9
16
  ### Added
@@ -56,6 +63,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
56
63
 
57
64
  - Initial Create
58
65
 
66
+ [0.1.0]: https://github.com/WeInfuse/luma/compare/v0.0.8...v0.1.0
59
67
  [0.0.8]: https://github.com/WeInfuse/luma/compare/v0.0.7...v0.0.8
60
68
  [0.0.7]: https://github.com/WeInfuse/luma/compare/v0.0.6...v0.0.7
61
69
  [0.0.6]: https://github.com/WeInfuse/luma/compare/v0.0.5...v0.0.6
data/README.md CHANGED
@@ -18,21 +18,11 @@ Or install it yourself as:
18
18
  $ gem install luma
19
19
 
20
20
  ## Usage
21
-
22
- ### Configuration
23
-
24
- ```ruby
25
- Luma.configure do |c|
26
- c.email = ENV['LUMA_EMAIL']
27
- c.password = ENV['LUMA_PASSWORD']
28
- c.api_endpoint = 'http://hello.com' # Defaults to Luma endpoint
29
- end
30
- ```
31
-
21
+ Supply email and password with each request based upon the requesting client/group's API user.
32
22
  ### Create Appointment Type
33
23
  ```ruby
34
24
  body = { "name": "Infusion", "description": "Infusion" }
35
- Luma::AppointmentType.new.create_appointment_type(body: body)
25
+ Luma::AppointmentType.new(email: email, password: password).create_appointment_type(body: body)
36
26
  ```
37
27
 
38
28
  ### Create Facility
@@ -46,13 +36,13 @@ body = {
46
36
  postcode: 78705
47
37
  }
48
38
 
49
- Luma::Facilities.new.create_facility(body: body)
39
+ Luma::Facilities.new(email: email, password: password).create_facility(body: body)
50
40
  ```
51
41
 
52
42
  ### Create Provider
53
43
  ```ruby
54
44
  body = { "name": "Billy Bob 2", "npi": 1234567891 }
55
- Luma::Provider.new.create_provider(body: body)
45
+ Luma::Provider.new(email: email, password: password).create_provider(body: body)
56
46
  ```
57
47
 
58
48
  ### Create Patient
@@ -73,7 +63,7 @@ body = Luma::Models::Patient.new(first_name: 'Ruby',
73
63
  do_not_contact: false
74
64
  )
75
65
 
76
- Luma::Patient.new.create_patient(body: body)
66
+ Luma::Patient.new(email: email, password: password).create_patient(body: body)
77
67
  ```
78
68
 
79
69
  ### Create Appointment
@@ -88,7 +78,7 @@ body = Luma::Models::Appointment.new(
88
78
  appt_type_id: '45678',
89
79
  )
90
80
 
91
- Luma::Appointment.new.create_appointment(body: body)
81
+ Luma::Appointment.new(email: email, password: password).create_appointment(body: body)
92
82
  ```
93
83
 
94
84
  ## Development
@@ -1,32 +1,31 @@
1
1
  module Luma
2
2
  class Authentication < Connection
3
- attr_accessor :response, :validation_response
3
+ attr_accessor :email, :password, :response, :validation_response
4
4
 
5
5
  BASE_ENDPOINT = '/api'.freeze
6
6
  AUTH_ENDPOINT = "#{BASE_ENDPOINT}/users/login".freeze
7
7
  VALIDATE_ENDPOINT = "#{BASE_ENDPOINT}/tokens/validate".freeze
8
8
 
9
- def initialize
9
+ def initialize(email: nil, password: nil)
10
+ @email = email
11
+ @password = password
10
12
  @response = nil
11
13
  @validation_response = nil
12
14
  end
13
15
 
14
16
  def authenticate
15
- if (self.expires?)
16
- request = {
17
- body: { email: Luma.configuration.email, password: Luma.configuration.password },
18
- endpoint: AUTH_ENDPOINT
19
- }
17
+ request = {
18
+ body: { email: email, password: password },
19
+ endpoint: AUTH_ENDPOINT
20
+ }
20
21
 
21
- response = self.request(**request, auth: false)
22
+ response = self.request(**request, auth: false)
22
23
 
23
- if (false == response.ok?)
24
- @response = nil
25
- raise LumaException.from_response(response, msg: 'Authentication')
26
- else
27
- @response = response
28
- validate
29
- end
24
+ if (false == response.ok?)
25
+ @response = nil
26
+ raise LumaException.from_response(response, msg: 'Authentication')
27
+ else
28
+ @response = response
30
29
  end
31
30
 
32
31
  return self
@@ -52,26 +51,10 @@ module Luma
52
51
  return @response['token'] if @response
53
52
  end
54
53
 
55
- def expiry
56
- return @validation_response['exp'] if @validation_response
57
- end
58
-
59
- def expires?
60
- if (self.expiry)
61
- return self.expiry <= (Time.now.to_f * 1000).floor
62
- else
63
- return true
64
- end
65
- end
66
-
67
54
  def access_header
68
55
  return {
69
56
  'X-Access-Token' => self.access_token,
70
57
  }
71
58
  end
72
-
73
- def expire!
74
- @response = nil
75
- end
76
59
  end
77
60
  end
@@ -10,9 +10,11 @@ module Luma
10
10
 
11
11
  format :json
12
12
 
13
- def initialize(body: nil, headers: {})
14
- @body = body
13
+ def initialize(email: nil, password: nil, headers: {})
14
+ @email = email
15
+ @password = password
15
16
  @headers = headers
17
+ @body = nil
16
18
  end
17
19
 
18
20
  def request(endpoint: DEFAULT_ENDPOINT, body: nil, headers: {}, auth: true, verb: :post)
@@ -31,7 +33,7 @@ module Luma
31
33
  private
32
34
 
33
35
  def auth_header
34
- @auth ||= Authentication.new
36
+ @auth = Authentication.new(email: @email, password: @password)
35
37
 
36
38
  return @auth.authenticate.access_header
37
39
  end
@@ -9,8 +9,8 @@ module Luma
9
9
 
10
10
  if (error_response.is_a?(Hash) && error_response.include?("Meta") && error_response["Meta"].include?("Errors"))
11
11
  exception_msg << error_response["Meta"]["Errors"]
12
- else
13
- exception_msg << error_response
12
+ elsif (error_response.is_a?(Hash) && error_response.include?("message") && error_response.include?("detail"))
13
+ exception_msg << error_response["message"] + ": " + error_response["detail"]
14
14
  end
15
15
  rescue JSON::ParserError
16
16
  exception_msg << response.body
data/lib/luma/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Luma
2
- VERSION = '0.0.8'.freeze
2
+ VERSION = '0.1.0'.freeze
3
3
  end
data/lib/luma.rb CHANGED
@@ -15,59 +15,4 @@ require 'luma/appointment'
15
15
  require 'luma/models/appointment'
16
16
 
17
17
  module Luma
18
- class Configuration
19
- attr_accessor :email, :password
20
-
21
- def initialize
22
- @email = nil
23
- @password = nil
24
- end
25
-
26
- def api_endpoint=(endpoint)
27
- Connection.base_uri(endpoint.freeze)
28
- end
29
-
30
- def api_endpoint
31
- return Connection.base_uri
32
- end
33
-
34
- def to_h
35
- return {
36
- email: @email,
37
- password: @password,
38
- api_endpoint: api_endpoint
39
- }
40
- end
41
-
42
- def from_h(h)
43
- self.email = h[:email]
44
- self.password = h[:password]
45
- self.api_endpoint = h[:api_endpoint]
46
-
47
- return self
48
- end
49
- end
50
-
51
- class << self
52
- def configuration
53
- @configuration ||= Configuration.new
54
- end
55
-
56
- def configure
57
- yield(configuration)
58
- end
59
- end
60
-
61
- # Luma API client
62
- class LumaClient
63
- class << self
64
- def connection
65
- @connection ||= Connection.new
66
- end
67
-
68
- def release
69
- @connection = nil
70
- end
71
- end
72
- end
73
18
  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.0.8
4
+ version: 0.1.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: 2021-11-02 00:00:00.000000000 Z
11
+ date: 2021-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
191
  requirements: []
192
- rubygems_version: 3.0.3
192
+ rubygems_version: 3.1.4
193
193
  signing_key:
194
194
  specification_version: 4
195
195
  summary: Ruby wrapper for the Luma Health API