dock_health_api 0.5.7 → 0.5.9
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/Gemfile.lock +1 -1
- data/README.md +13 -0
- data/lib/dock_health_api/client.rb +12 -8
- data/lib/dock_health_api/config.rb +0 -4
- data/lib/dock_health_api/resources/task.rb +6 -0
- data/lib/dock_health_api/version.rb +1 -1
- data/lib/dock_health_api.rb +4 -9
- data/spec/task_comment_spec.rb +72 -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: 3d1832a40bbc54875371a1f819afe18ea48072ba29254aac0fbf4d535cbbf25d
|
4
|
+
data.tar.gz: faa6758f0cd9b27186921934898640fa7833360d47106a4b2d740d94aef26106
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49846f61f1b202289521fbacc162e63f976378692f7152c496c37ddff66b87cf9b1bdc2e26f32b251d7db619f84b2dfddbbfa3a9c4042846577f9c95fea78e20
|
7
|
+
data.tar.gz: 7e79857806c080d7f5bf156a1438befead22c8ee3f07984ca0f73357bdb94ec36071815c251039c3543b101da27cfa3a4b8142fdbd607acce0580adf4de92b4a
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -126,6 +126,19 @@ params = { userId: "<user id>", organizationId: "<organization id>" }
|
|
126
126
|
DockHealthApi::Organization::User.update(params)
|
127
127
|
# Delete User from Organization
|
128
128
|
DockHealthApi::Organization::User.delete({id: "< user id >"})
|
129
|
+
|
130
|
+
# Get Specific Comment
|
131
|
+
DockHealthApi::Task::Comment.get("<comment id>")
|
132
|
+
# List comments for a specific task
|
133
|
+
DockHealthApi::Task::Comment.list(taskIdentifier: "<task id>")
|
134
|
+
# Create comment for a specific task
|
135
|
+
params = { comment: "comment text here", task: { type: "TASK", id: "<task id>" }}
|
136
|
+
DockHealthApi::Task::Comment.create(params)
|
137
|
+
# Update specific comment
|
138
|
+
params = { comment: "comment text here", id: "<comment id>" }
|
139
|
+
DockHealthApi::Task::Comment.update(params)
|
140
|
+
# Delete a specific comment
|
141
|
+
DockHealthApi::Task::Comment.delete(id: "<comment id>")
|
129
142
|
```
|
130
143
|
|
131
144
|
# Patient Data Format
|
@@ -6,17 +6,13 @@ module DockHealthApi
|
|
6
6
|
BUFFER = 120
|
7
7
|
|
8
8
|
include Singleton
|
9
|
-
|
9
|
+
|
10
10
|
attr_reader :config
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
@config = DockHealthApi.config
|
14
14
|
end
|
15
15
|
|
16
|
-
def active_client
|
17
|
-
instance
|
18
|
-
end
|
19
|
-
|
20
16
|
def connection
|
21
17
|
@connection ||= OAuth2::Client.new(config.api_key, config.api_secret, token_url: config.token_url, raise_errors: false)
|
22
18
|
end
|
@@ -35,10 +31,18 @@ module DockHealthApi
|
|
35
31
|
end
|
36
32
|
|
37
33
|
def iframe_token_connection
|
38
|
-
get_iframe_token
|
34
|
+
get_iframe_token if @iframe_token_connection.nil? || iframe_token_about_to_expire?
|
39
35
|
@iframe_token_connection
|
40
36
|
end
|
41
37
|
|
38
|
+
def iframe_token_expiration_time
|
39
|
+
@iframe_token_expiration_time ||= Time.now + @iframe_token_connection.expires_in
|
40
|
+
end
|
41
|
+
|
42
|
+
def iframe_token_about_to_expire?
|
43
|
+
Time.now + BUFFER > iframe_token_expiration_time
|
44
|
+
end
|
45
|
+
|
42
46
|
def token
|
43
47
|
@token ||= token_connection.token
|
44
48
|
end
|
@@ -56,8 +60,8 @@ module DockHealthApi
|
|
56
60
|
def get_iframe_token
|
57
61
|
@iframe_token_connection = connection.client_credentials.get_token(scope:"dockhealth/system.embedded.launch")
|
58
62
|
return @iframe_token_connection if @iframe_token_connection.nil?
|
59
|
-
|
60
|
-
|
63
|
+
@iframe_token_expiration_time = Time.now + @iframe_token_connection.expires_in
|
64
|
+
@iframe_token_connection
|
61
65
|
end
|
62
66
|
end
|
63
67
|
end
|
data/lib/dock_health_api.rb
CHANGED
@@ -45,24 +45,19 @@ module DockHealthApi
|
|
45
45
|
def_delegators :@config, :org_id, :org_id=
|
46
46
|
def_delegators :@config, :user_id, :user_id=
|
47
47
|
def_delegators :@config, :api, :api=
|
48
|
-
def_delegators :@config, :iframe_token, :iframe_token=
|
49
|
-
def_delegators :@config, :iframe_token_expires_at, :iframe_token_expires_at=
|
50
|
-
def_delegators :@config, :token, :token=
|
51
|
-
def_delegators :@config, :token_expires_at, :token_expires_at=
|
52
48
|
def_delegators :@config, :debug, :debug=
|
53
49
|
def_delegators :@config, :iframe_base_url, :iframe_base_url=
|
54
50
|
|
55
51
|
def receive_iframe_token
|
56
|
-
Client.instance.iframe_token_connection
|
52
|
+
@receive_iframe_token ||= Client.instance.iframe_token_connection
|
57
53
|
end
|
58
54
|
|
59
|
-
def
|
60
|
-
|
61
|
-
true
|
55
|
+
def iframe_token
|
56
|
+
receive_iframe_token.token
|
62
57
|
end
|
63
58
|
|
64
59
|
def iframe_url(arg={})
|
65
|
-
|
60
|
+
receive_iframe_token
|
66
61
|
dock_user_id = arg[:user_id]
|
67
62
|
view_type = arg[:view_type]
|
68
63
|
target_type = arg[:target_type]
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'dock_health_api'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
RSpec.describe DockHealthApi::Task::Comment do
|
5
|
+
let(:tasklistid) {DockHealthApi::TaskList.list.last["id"]}
|
6
|
+
let(:task) { DockHealthApi::Task.create({ description: "test foobar", taskList: { type: "DEVELOPER", id: tasklistid } }) }
|
7
|
+
let(:params) { { comment: "initial comment", task: { type: "TASK", id: task["id"] }} }
|
8
|
+
let!(:comment) { DockHealthApi::Task::Comment.create(params) }
|
9
|
+
|
10
|
+
describe "#create" do
|
11
|
+
context "create new task comment" do
|
12
|
+
let(:new_comment_params) { { comment: "new comment", task: { type: "TASK", id: task["id"] }} }
|
13
|
+
|
14
|
+
it "should create new task comment" do
|
15
|
+
initial_count = DockHealthApi::Task::Comment.list(taskIdentifier: task["id"]).count
|
16
|
+
response = DockHealthApi::Task::Comment.create(new_comment_params)
|
17
|
+
final_count = DockHealthApi::Task::Comment.list(taskIdentifier: task["id"]).count
|
18
|
+
expect(response["comment"]).to eq(new_comment_params[:comment])
|
19
|
+
expect(final_count - initial_count).to eq(1)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#list" do
|
25
|
+
context "list task comment by criteria" do
|
26
|
+
it "should list all task comments by criteria" do
|
27
|
+
response = DockHealthApi::Task::Comment.list(taskIdentifier: task["id"])
|
28
|
+
expect(response.last.is_a?(DockHealthApi::Task::Comment))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#get" do
|
34
|
+
context "get a specific task comment" do
|
35
|
+
it "should get the correct task comment" do
|
36
|
+
response = DockHealthApi::Task::Comment.get(comment["id"])
|
37
|
+
expect(response["comment"]).to eq(params[:comment])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "get task comment with wrong id" do
|
42
|
+
it "should return 404" do
|
43
|
+
wrong_id = "a" * 36
|
44
|
+
response = DockHealthApi::Task::Comment.get(wrong_id)
|
45
|
+
expect(response["status"]).to eq(500)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#update" do
|
51
|
+
context "update existing task comment" do
|
52
|
+
it "should update existing task comment" do
|
53
|
+
update_params = { comment: "updated text", id: comment["id"] }
|
54
|
+
response = DockHealthApi::Task::Comment.update(update_params)
|
55
|
+
expect(response["comment"]).to eq(update_params[:comment])
|
56
|
+
updated_task = DockHealthApi::Task::Comment.get(comment["id"])
|
57
|
+
expect(updated_task["comment"]).to eq(update_params[:comment])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#delete" do
|
63
|
+
context "Delete existing task comment" do
|
64
|
+
it "should delete existing task comment" do
|
65
|
+
initial_count = DockHealthApi::Task::Comment.list(taskIdentifier: task["id"]).count
|
66
|
+
response = DockHealthApi::Task::Comment.delete(id: comment["id"])
|
67
|
+
final_count = DockHealthApi::Task::Comment.list(taskIdentifier: task["id"]).count
|
68
|
+
expect(initial_count - final_count).to eq(1)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dock_health_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Magomero
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth2
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- spec/organization.rb
|
128
128
|
- spec/patient_spec.rb
|
129
129
|
- spec/spec_helper.rb
|
130
|
+
- spec/task_comment_spec.rb
|
130
131
|
- spec/task_group_spec.rb
|
131
132
|
- spec/task_spec.rb
|
132
133
|
- spec/tasklist_spec.rb
|