redox-client 0.2.0 → 0.3.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 +7 -1
- data/Gemfile.lock +4 -1
- data/README.md +10 -1
- data/Rakefile +10 -4
- data/lib/redox.rb +19 -2
- data/lib/redox/model.rb +1 -1
- data/lib/redox/models/error.rb +12 -0
- data/lib/redox/models/location.rb +12 -0
- data/lib/redox/models/message.rb +1 -0
- data/lib/redox/models/meta.rb +1 -0
- data/lib/redox/models/patient.rb +7 -3
- data/lib/redox/models/patient_identifier.rb +7 -3
- data/lib/redox/models/phone_number.rb +11 -0
- data/lib/redox/models/provider.rb +21 -0
- data/lib/redox/models/visit.rb +31 -0
- data/lib/redox/query.rb +4 -1
- data/lib/redox/scheduling/booked.rb +26 -0
- data/lib/redox/source.rb +16 -3
- data/lib/redox/version.rb +1 -1
- data/redox-client.gemspec +1 -0
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d4299c12f9132415ab91ad2ffad342feac72cd08159f608844951831ab45cbf
|
4
|
+
data.tar.gz: 92888834d1ec14cc7b35f91767bfdb950331533bad8a88b8f6f08b9fef542909
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a9352e931af11b49722b5e86fd6fde9974198ba11dc39e1bb4bf26efd64166f31073be8eb057c6ef6173c95ba466fce99a99a1d286497f948977831032a00be
|
7
|
+
data.tar.gz: 12a7fb2890bfac558b8b46d578254aca9e6205341dbbac32c1f70126c77054e5c7dd7d0190668ac72a875369b2efa0a8ae22531a6a5b5205b32f6eabb26bd15f
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,11 @@
|
|
7
7
|
|
8
8
|
### Removed
|
9
9
|
|
10
|
+
## [0.3.0] - 2020-08-27
|
11
|
+
### Added
|
12
|
+
- _body attribute containing raw response text on query results
|
13
|
+
- SchedulingBooked.Query
|
14
|
+
|
10
15
|
## [0.2.0] - 2020-08-16
|
11
16
|
### Added
|
12
17
|
- improve release process
|
@@ -20,4 +25,5 @@
|
|
20
25
|
|
21
26
|
[0.1.0]: https://github.com/patient-discovery/redox-client/releases/tag/v0.1.0
|
22
27
|
[0.2.0]: https://github.com/patient-discovery/redox-client/releases/tag/v0.2.0
|
23
|
-
[
|
28
|
+
[0.3.0]: https://github.com/patient-discovery/redox-client/releases/tag/v0.3.0
|
29
|
+
[Unreleased]: https://github.com/patient-discovery/redox-client/compare/v0.3.0...HEAD
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
redox-client (0.
|
4
|
+
redox-client (0.3.0)
|
5
5
|
faraday (~> 1.0, >= 1.0.1)
|
6
6
|
hashie (~> 4.1)
|
7
7
|
|
@@ -26,6 +26,8 @@ GEM
|
|
26
26
|
rspec-core (~> 3.9.0)
|
27
27
|
rspec-expectations (~> 3.9.0)
|
28
28
|
rspec-mocks (~> 3.9.0)
|
29
|
+
rspec-collection_matchers (1.2.0)
|
30
|
+
rspec-expectations (>= 2.99.0.beta1)
|
29
31
|
rspec-core (3.9.2)
|
30
32
|
rspec-support (~> 3.9.3)
|
31
33
|
rspec-expectations (3.9.2)
|
@@ -66,6 +68,7 @@ DEPENDENCIES
|
|
66
68
|
rake (~> 12.0)
|
67
69
|
redox-client!
|
68
70
|
rspec (~> 3.9)
|
71
|
+
rspec-collection_matchers (~> 1.2)
|
69
72
|
simplecov (~> 0.18.5)
|
70
73
|
standard (~> 0.4.7)
|
71
74
|
vcr (~> 6.0)
|
data/README.md
CHANGED
@@ -77,6 +77,7 @@ Since `Redox::Source` has shared state, i.e., the access token and its expiratio
|
|
77
77
|
## Supported APIs
|
78
78
|
|
79
79
|
- PatientSearch.Query
|
80
|
+
- Scheduling.Booked
|
80
81
|
|
81
82
|
## Development
|
82
83
|
***Nota Bene**: This project uses [VCR](https://relishapp.com/vcr/vcr/docs) to record HTTP requests and responses and play them back during tests. Do NOT use Redox production credentials when developing tests.*
|
@@ -87,6 +88,14 @@ After checking out the repo, run `bin/setup` to install gem dependencies and a g
|
|
87
88
|
### Testing
|
88
89
|
This project uses `rspec` and [VCR](https://relishapp.com/vcr/vcr/docs). VCR provides fast deterministic testing of HTTP APIs. It also makes it possible to set up any server response you want to test by authoring the server responses directly. This comes in handy when trying to test edge cases that might occur but are hard to reproduce.
|
89
90
|
|
91
|
+
Some effort has been made to filter credentials from recorded HTTP interactions, but you should always carefully review all your changes before pushing them to avoid credential exposure.
|
92
|
+
|
93
|
+
To make a new test with a new recording:
|
94
|
+
|
95
|
+
```bash
|
96
|
+
env REDOX_API_KEY=my-key REDOX_SECRET=my-secret rspec
|
97
|
+
```
|
98
|
+
|
90
99
|
### Coding Style
|
91
100
|
This project adheres to [StandardRB](https://github.com/testdouble/standard/blob/master/README.md). Additionally
|
92
101
|
[# frozen_string_literal](https://bugs.ruby-lang.org/issues/8976#note-30) is required in Ruby source files, and is enforced by Rubocop.
|
@@ -96,7 +105,7 @@ Run `rake` to run the style checks. Run `rake fix` to fix violations.
|
|
96
105
|
### Useful commands
|
97
106
|
- `rake` - run all tests (lint, Redox cred scan, rspec)
|
98
107
|
- `rake fix` - Fix RuboCop and StandardRB violations
|
99
|
-
- `
|
108
|
+
- `rake vcr:fix` - attempt to replace real looking credentials in VCR cassettes with dummy test values.
|
100
109
|
- `rake -T` - see available rake tasks
|
101
110
|
- `bin/console` - get an interactive prompt for experimenting
|
102
111
|
|
data/Rakefile
CHANGED
@@ -15,15 +15,20 @@ desc "Run all checks and tests"
|
|
15
15
|
task default: :test
|
16
16
|
|
17
17
|
desc "Run all checks and tests"
|
18
|
-
task test: [:rubocop, :standard, :
|
18
|
+
task test: [:rubocop, :standard, :vcr, :spec]
|
19
19
|
|
20
20
|
desc "Fix RuboCop and StandardRB violations"
|
21
21
|
task fix: ["rubocop:auto_correct", "standard:fix"]
|
22
22
|
|
23
|
+
# TODO: Make these a proper lib/rake_tasks.rb task and avoid exec'ing out
|
23
24
|
desc "Check VCR cassettes for Redox credential leak"
|
24
|
-
task
|
25
|
-
|
26
|
-
|
25
|
+
task "vcr" do
|
26
|
+
raise "Possible credential leak, run rake vcr:fix" unless system "bin/check-vcr-cassettes"
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Scrub VCR cassettes, replacing suspected real creds with test ones"
|
30
|
+
task "vcr:fix" do
|
31
|
+
system "bin/check-vcr-cassettes --scrub"
|
27
32
|
end
|
28
33
|
|
29
34
|
task "prepare:changelog" do
|
@@ -55,6 +60,7 @@ task "prepare:tag" do
|
|
55
60
|
end
|
56
61
|
end
|
57
62
|
|
63
|
+
desc "Prepare a gem release"
|
58
64
|
task "prepare:release": [
|
59
65
|
"release:guard_clean", "test", "prepare:version", "prepare:changelog", "prepare:tag"
|
60
66
|
] do
|
data/lib/redox.rb
CHANGED
@@ -6,16 +6,33 @@ require_relative "redox/model"
|
|
6
6
|
require_relative "redox/models/address"
|
7
7
|
require_relative "redox/models/demographics"
|
8
8
|
require_relative "redox/models/destination"
|
9
|
+
require_relative "redox/models/error"
|
10
|
+
require_relative "redox/models/location"
|
9
11
|
require_relative "redox/models/message"
|
10
12
|
require_relative "redox/models/meta"
|
11
|
-
require_relative "redox/models/patient"
|
12
13
|
require_relative "redox/models/patient_identifier"
|
14
|
+
require_relative "redox/models/patient"
|
15
|
+
require_relative "redox/models/phone_number"
|
16
|
+
require_relative "redox/models/provider"
|
17
|
+
require_relative "redox/models/visit"
|
13
18
|
|
14
19
|
require_relative "redox/query"
|
15
20
|
require_relative "redox/source"
|
16
21
|
require_relative "redox/patient_search/query.rb"
|
22
|
+
require_relative "redox/scheduling/booked.rb"
|
17
23
|
|
18
24
|
module Redox
|
19
|
-
class Error < StandardError
|
25
|
+
class Error < StandardError
|
26
|
+
attr_accessor :status
|
27
|
+
attr_accessor :body
|
28
|
+
attr_accessor :message
|
29
|
+
|
30
|
+
def initialize(status: nil, body: nil, message: nil)
|
31
|
+
self.status = status
|
32
|
+
self.body = body
|
33
|
+
self.message = message
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
20
37
|
class AuthenticationError < Error; end
|
21
38
|
end
|
data/lib/redox/model.rb
CHANGED
@@ -55,7 +55,7 @@ class Redox::Model < Hashie::Trash
|
|
55
55
|
# rails `String.underscore` method with the following simplications:
|
56
56
|
#
|
57
57
|
# - any word in all caps is assumed to be an acronym (ZIP -> zip)
|
58
|
-
# - only alphabetic characters
|
58
|
+
# - only alphabetic characters are modified
|
59
59
|
#
|
60
60
|
# Note: this function does not have an inverse. Both "Zip" and "ZIP"
|
61
61
|
# map to "zip".
|
data/lib/redox/models/message.rb
CHANGED
data/lib/redox/models/meta.rb
CHANGED
data/lib/redox/models/patient.rb
CHANGED
@@ -3,7 +3,11 @@
|
|
3
3
|
require_relative "patient_identifier"
|
4
4
|
require_relative "demographics"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
module Redox
|
7
|
+
module Models
|
8
|
+
class Patient < Redox::Model
|
9
|
+
redox_property :Identifiers, coerce: Array[PatientIdentifier]
|
10
|
+
redox_property :Demographics, coerce: Demographics
|
11
|
+
end
|
12
|
+
end
|
9
13
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Redox
|
4
|
+
module Models
|
5
|
+
class PatientIdentifier < Redox::Model
|
6
|
+
redox_property :IDType
|
7
|
+
redox_property :ID
|
8
|
+
end
|
9
|
+
end
|
6
10
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "address"
|
4
|
+
require_relative "location"
|
5
|
+
require_relative "phone_number"
|
6
|
+
|
7
|
+
module Redox
|
8
|
+
module Models
|
9
|
+
class Provider < Redox::Model
|
10
|
+
redox_property :ID
|
11
|
+
redox_property :IDType
|
12
|
+
redox_property :FirstName
|
13
|
+
redox_property :LastName
|
14
|
+
redox_property :Credentials, coerce: Array[String]
|
15
|
+
redox_property :Address, coerce: Address
|
16
|
+
redox_property :EmailAddresses, coerce: Array[String]
|
17
|
+
redox_property :PhoneNumber, coerce: PhoneNumber
|
18
|
+
redox_property :Location, coerce: Location
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "location"
|
4
|
+
require_relative "patient"
|
5
|
+
require_relative "provider"
|
6
|
+
|
7
|
+
module Redox
|
8
|
+
module Models
|
9
|
+
class Visit < Redox::Model
|
10
|
+
redox_property :VisitNumber
|
11
|
+
redox_property :AccountNumber
|
12
|
+
redox_property :VisitDateTime
|
13
|
+
redox_property :PatientClass
|
14
|
+
redox_property :Status
|
15
|
+
redox_property :Duration
|
16
|
+
redox_property :Reason
|
17
|
+
redox_property :CancelReason
|
18
|
+
redox_property :LastUpdated
|
19
|
+
redox_property :ScheduledDateTime
|
20
|
+
redox_property :CancelDateTime
|
21
|
+
redox_property :Type
|
22
|
+
redox_property :Instructions
|
23
|
+
redox_property :Patient, coerce: Patient
|
24
|
+
redox_property :AttendingProvider, coerce: Provider
|
25
|
+
redox_property :ConsultingProvider, coerce: Provider
|
26
|
+
redox_property :ReferringProvider, coerce: Provider
|
27
|
+
redox_property :VisitProvider, coerce: Provider
|
28
|
+
redox_property :Location, coerce: Location
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/redox/query.rb
CHANGED
@@ -12,7 +12,10 @@ module Redox
|
|
12
12
|
event_date_time: DateTime.now.iso8601,
|
13
13
|
destinations: [Redox::Models::Destination.new(id: destination_id)]
|
14
14
|
}
|
15
|
-
|
15
|
+
result_body = source.execute_query self
|
16
|
+
response = response_type.from_redox_json result_body
|
17
|
+
response._body = result_body
|
18
|
+
response
|
16
19
|
end
|
17
20
|
end
|
18
21
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "redox"
|
4
|
+
|
5
|
+
module Redox
|
6
|
+
module Scheduling
|
7
|
+
class Booked < Redox::Query
|
8
|
+
redox_property :StartDateTime, coerce: ->(v) {
|
9
|
+
v.respond_to?(:iso8601) ? v.iso8601 : v.to_s
|
10
|
+
}
|
11
|
+
redox_property :EndDateTime, coerce: ->(v) {
|
12
|
+
v.respond_to?(:iso8601) ? v.iso8601 : v.to_s
|
13
|
+
}
|
14
|
+
|
15
|
+
redox_property :Patient, coerce: Models::Patient
|
16
|
+
|
17
|
+
def response_type
|
18
|
+
BookedResponse
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class BookedResponse < Models::Message
|
23
|
+
redox_property :Visits, coerce: Array[Models::Visit]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/redox/source.rb
CHANGED
@@ -28,8 +28,21 @@ class Redox::Source
|
|
28
28
|
def execute_query(model)
|
29
29
|
ensure_access_token
|
30
30
|
res = @connection.post("/endpoint", model.to_redox_json)
|
31
|
-
|
32
|
-
|
31
|
+
message =
|
32
|
+
begin
|
33
|
+
JSON.parse(res.body)
|
34
|
+
rescue
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
|
38
|
+
unless res.success?
|
39
|
+
raise Redox::Error.new(
|
40
|
+
status: res.status,
|
41
|
+
body: res.body,
|
42
|
+
message: Redox::Models::Message.from_redox_json(message)
|
43
|
+
)
|
44
|
+
end
|
45
|
+
message
|
33
46
|
end
|
34
47
|
|
35
48
|
def ensure_access_token
|
@@ -59,7 +72,7 @@ class Redox::Source
|
|
59
72
|
def authenticate
|
60
73
|
self.access_token = nil
|
61
74
|
res = @connection.post("/auth/authenticate", {apiKey: @api_key, secret: @secret}.to_json)
|
62
|
-
raise Redox::AuthenticationError.new
|
75
|
+
raise Redox::AuthenticationError.new status: res.status, body: res.body unless res.success?
|
63
76
|
data = JSON.parse(res.body)
|
64
77
|
self.access_token = data["accessToken"]
|
65
78
|
@access_token_expires_at = DateTime.parse(data["expires"])
|
data/lib/redox/version.rb
CHANGED
data/redox-client.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |gem|
|
|
22
22
|
|
23
23
|
gem.add_development_dependency "rake", "~> 12.0"
|
24
24
|
gem.add_development_dependency "rspec", "~> 3.9"
|
25
|
+
gem.add_development_dependency "rspec-collection_matchers", "~> 1.2"
|
25
26
|
gem.add_development_dependency "simplecov", "~> 0.18.5"
|
26
27
|
gem.add_development_dependency "standard", "~> 0.4.7"
|
27
28
|
gem.add_development_dependency "vcr", "~> 6.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redox-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Keirnan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-collection_matchers
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.2'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: simplecov
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,12 +146,18 @@ files:
|
|
132
146
|
- lib/redox/models/address.rb
|
133
147
|
- lib/redox/models/demographics.rb
|
134
148
|
- lib/redox/models/destination.rb
|
149
|
+
- lib/redox/models/error.rb
|
150
|
+
- lib/redox/models/location.rb
|
135
151
|
- lib/redox/models/message.rb
|
136
152
|
- lib/redox/models/meta.rb
|
137
153
|
- lib/redox/models/patient.rb
|
138
154
|
- lib/redox/models/patient_identifier.rb
|
155
|
+
- lib/redox/models/phone_number.rb
|
156
|
+
- lib/redox/models/provider.rb
|
157
|
+
- lib/redox/models/visit.rb
|
139
158
|
- lib/redox/patient_search/query.rb
|
140
159
|
- lib/redox/query.rb
|
160
|
+
- lib/redox/scheduling/booked.rb
|
141
161
|
- lib/redox/source.rb
|
142
162
|
- lib/redox/version.rb
|
143
163
|
- redox-client.gemspec
|