dock_health_api 0.4.0 → 0.5.1

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: 7948e2eee630eae60b00389c067560a4db5400cca6ed56134619d95a97667bab
4
- data.tar.gz: aaba98419dd489685a6f88274b43eeaa28224f012f35725498777ed480b12a86
3
+ metadata.gz: e13712f9ae22b6eb2596f030be20bb2c893c5f6808911e715560e10444016606
4
+ data.tar.gz: 6f920ca3cba06475d053c4c8213e6a50c2112f3ae6eaa95b3475713bfb9973b3
5
5
  SHA512:
6
- metadata.gz: 96a369151547d0cfba4b61a0776013db3ccb63172ae51b948e5b52637ab9bf16fbde5d32654d29a4f4a16ea534aeace8353f1ae1f739141f6f2b8307604bf6f7
7
- data.tar.gz: 5c30bc833f4b9d5bf02d202aac2c1c29abd1b0ee5481cbc9a0ef3516318d8a51ca5f8c2da6740c029e93d16115904192add23d3e839719d025f3935e9a93a695
6
+ metadata.gz: 40905d8789ab5848e6903fca585678a8872318f6931e63fb1b90ddf72e03a70e063b88101bf214d2b83458fa9ce6f698b6155b74a8040c487e4ce0c18fa6e673
7
+ data.tar.gz: 0f0461e6cef1b1d1941b834ffb258dfdf8918a57f453c16fb4e8d24051a021bc6c4bf48c7e9c19b63124a88756d0e7fb6d1535b2b6ba0d69db30aaf1d3c3a15c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dock_health_api (0.4.0)
4
+ dock_health_api (0.5.0)
5
5
  oauth2 (~> 1.4)
6
6
  ostruct
7
7
  rspec (~> 3.0)
data/README.md CHANGED
@@ -94,7 +94,7 @@ DockHealthApi::TaskList.delete(id: "<tasklist ID>")
94
94
  params = { taskList: { type: "tasklist type", id: "<tasklist id>" }, user: { type: "user type", id: "<user id>" } }
95
95
  DockHealthApi::TaskList::User.put(params)
96
96
  # Update role for existing user in tasklist
97
- params = { taskList: { type: "tasklist type", id: "<tasklist id>" }, user: { type: "user type", id: "<user id>", userRole: "user role"} }
97
+ params = { taskList: { type: "tasklist type", id: "<tasklist id>" }, user: { type: "user type", id: "<user id>" }, userRole: "user role" }
98
98
  DockHealthApi::TaskList::User.update(params)
99
99
  # Delete existing user from tasklist
100
100
  params = { taskList: { type: "tasklist type", id: "<tasklist id>" }, user: { type: "user type", id: "<user id>" } }
@@ -114,15 +114,18 @@ DockHealthApi::Webhook.put(params)
114
114
  DockHealthApi::Webhook.delete(id: "<webhook id>")
115
115
 
116
116
  # Get Specific Organization
117
- DockHealthApi::Organization.get('id of user')
117
+ DockHealthApi::Organization.get('id of organization')
118
118
  # Create Organization
119
119
  DockHealthApi::Organization.create(organization_data)
120
120
  # Update Specific Organization
121
121
  DockHealthApi::Organization.update(updated_organization_data)
122
122
  # Delete Specific Organization (can't be an active Organization)
123
123
  DockHealthApi::Organization.delete({id: "id of organization"})
124
-
125
-
124
+ # Add User to Organization
125
+ params = { userId: "<user id>", organizationId: "<organization id>" }
126
+ DockHealthApi::Organization::User.update(params)
127
+ # Delete User from Organization
128
+ DockHealthApi::Organization::User.delete({id: "< user id >"})
126
129
  ```
127
130
 
128
131
  # Patient Data Format
data/bin/console CHANGED
@@ -17,6 +17,7 @@ DockHealthApi.resource_url = ENV["DOCK_HEALTH_URL"]
17
17
  DockHealthApi.org_id = ENV["DOCK_ORG"]
18
18
  DockHealthApi.user_id = ENV["DOCK_USER"]
19
19
  DockHealthApi.api = ENV["DOCK_HEALTH_API"]
20
+ DockHealthApi.token_url = ENV["DOCK_HEALTH_AUTH_URL"]
20
21
 
21
22
  require "irb"
22
23
  IRB.start(__FILE__)
@@ -1,9 +1,6 @@
1
1
  module DockHealthApi
2
2
  class Config
3
- attr_accessor :api_key, :api_secret, :api_base, :token_url, :resource_url, :org_id, :user_id, :api, :iframe_token, :token, :iframe_token_expires_at, :token_expires_at
3
+ attr_accessor :api_key, :api_secret, :api_base, :token_url, :resource_url, :org_id, :user_id, :api, :iframe_token, :token, :iframe_token_expires_at, :token_expires_at, :debug
4
4
 
5
- def initialize
6
- @token_url = "https://dock-health-dev.auth.us-east-1.amazoncognito.com/oauth2/token"
7
- end
8
5
  end
9
6
  end
@@ -2,12 +2,7 @@ module DockHealthApi
2
2
  module Crud
3
3
  module Create
4
4
  def create(**params)
5
- response = execute_request(:post,
6
- resource_url,
7
- headers: headers,
8
- body_params: params)
9
- return response.parsed
10
- new(response.parsed)
5
+ execute_request(:post, resource_url, headers: headers, body_params: params)
11
6
  end
12
7
  end
13
8
  end
@@ -3,9 +3,7 @@ module DockHealthApi
3
3
  module Delete
4
4
  def delete(**params)
5
5
  id = params.delete(:id)
6
- response = execute_request(:delete, "#{resource_url}/#{id}", headers: headers, body_params: params)
7
- return response.parsed
8
- new(response.parsed)
6
+ execute_request(:delete, "#{resource_url}/#{id}", headers: headers, body_params: params)
9
7
  end
10
8
  end
11
9
  end
@@ -2,9 +2,7 @@ module DockHealthApi
2
2
  module Crud
3
3
  module Get
4
4
  def get(id)
5
- response = execute_request(:get, "#{resource_url}/#{id}", headers: headers )
6
- return response.parsed
7
- new(response.parsed)
5
+ execute_request(:get, "#{resource_url}/#{id}", headers: headers )
8
6
  end
9
7
  end
10
8
  end
@@ -3,16 +3,12 @@ module DockHealthApi
3
3
  module List
4
4
  def list(**params)
5
5
  response = execute_request(:get, "#{resource_url}", headers: headers)
6
- if params.empty?
7
- return response.parsed
8
- else
9
- search_result = response.parsed
10
- params.each do |p|
11
- search_result = search_result.select { |list| list[p[0].to_s] == p[1] }
12
- end
13
- return search_result
6
+ return response if client.config.debug || params.empty?
7
+ search_result = response
8
+ params.each do |p|
9
+ search_result = response.select { |list| list[p[0].to_s] == p[1] }
14
10
  end
15
- new(response.parsed)
11
+ return search_result
16
12
  end
17
13
  end
18
14
  end
@@ -3,12 +3,7 @@ module DockHealthApi
3
3
  module Put
4
4
  def put(**params)
5
5
  id = params.delete(:id)
6
- response = execute_request(:put,
7
- "#{resource_url}/#{id}",
8
- headers: headers,
9
- body_params: params)
10
- return response.parsed
11
- new(response.parsed)
6
+ response = execute_request(:put, "#{resource_url}/#{id}", headers: headers, body_params: params)
12
7
  end
13
8
  end
14
9
  end
@@ -9,12 +9,7 @@ module DockHealthApi
9
9
  resource_url_fixed = resource_url
10
10
  end
11
11
  id = params.delete(:id)
12
- response = execute_request(:patch,
13
- "#{resource_url_fixed}/#{id}",
14
- headers: headers,
15
- body_params: params)
16
- return response.parsed
17
- new(response.parsed)
12
+ execute_request(:patch, "#{resource_url_fixed}/#{id}", headers: headers, body_params: params)
18
13
  end
19
14
  end
20
15
  end
@@ -27,7 +27,8 @@ module DockHealthApi
27
27
  end
28
28
 
29
29
  def self.execute_request(method, url, params: {}, headers: {}, body_params: nil)
30
- client.token_connection.send(method, url, params: params, headers: headers, body: body_params.to_json)
30
+ response = client.token_connection.send(method, url, params: params, headers: headers, body: body_params.to_json)
31
+ client.config.debug ? response : response.parsed
31
32
  end
32
33
  end
33
34
  end
@@ -11,10 +11,8 @@ module DockHealthApi
11
11
  end
12
12
 
13
13
  def self.list(**params)
14
- headers = {"x-api-key": "#{ENV["DOCK_HEALTH_API"]}", "x-user-id": "#{ENV["DOCK_USER"]}", "x-organization-id": "#{ENV["DOCK_ORG"]}"}
15
- response = execute_request(:get, "#{resource_url}", headers: headers, params: params)
16
- return response.parsed
17
- new(response.parsed)
14
+ headers = {"x-api-key": "#{ENV["DOCK_HEALTH_API"]}", "x-user-id": "#{ENV["DOCK_USER"]}", "x-organization-id": client.config.org_id}
15
+ execute_request(:get, "#{resource_url}", headers: headers, params: params)
18
16
  end
19
17
  end
20
18
  end
@@ -7,10 +7,8 @@ module DockHealthApi
7
7
  extend DockHealthApi::Crud::List
8
8
 
9
9
  def self.list(**params)
10
- headers = {"x-api-key": "#{ENV["DOCK_HEALTH_API"]}", "x-user-id": "#{ENV["DOCK_USER"]}", "x-organization-id": "#{ENV["DOCK_ORG"]}"}
11
- response = execute_request(:get, "#{resource_url}", headers: headers, params: params)
12
- return response.parsed
13
- new(response.parsed)
10
+ headers = {"x-api-key": "#{ENV["DOCK_HEALTH_API"]}", "x-user-id": "#{ENV["DOCK_USER"]}", "x-organization-id": client.config.org_id}
11
+ execute_request(:get, "#{resource_url}", headers: headers, params: params)
14
12
  end
15
13
 
16
14
  class Group < Task
@@ -1,3 +1,3 @@
1
1
  module DockHealthApi
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -48,6 +48,7 @@ module DockHealthApi
48
48
  def_delegators :@config, :iframe_token_expires_at, :iframe_token_expires_at=
49
49
  def_delegators :@config, :token, :token=
50
50
  def_delegators :@config, :token_expires_at, :token_expires_at=
51
+ def_delegators :@config, :debug, :debug=
51
52
 
52
53
  def receive_iframe_token
53
54
  Client.active_client.iframe_token_connection if iframe_token_expired?
data/spec/spec_helper.rb CHANGED
@@ -23,4 +23,5 @@ RSpec.configure do |config|
23
23
  DockHealthApi.org_id = ENV["DOCK_ORG"]
24
24
  DockHealthApi.user_id = ENV["DOCK_USER"]
25
25
  DockHealthApi.api = ENV["DOCK_HEALTH_API"]
26
+ DockHealthApi.token_url = ENV["DOCK_HEALTH_AUTH_URL"]
26
27
  end
data/spec/user_spec.rb CHANGED
@@ -57,4 +57,4 @@ RSpec.describe DockHealthApi::User do
57
57
  end
58
58
  end
59
59
  end
60
- end
60
+ 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.4.0
4
+ version: 0.5.1
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: 2022-09-27 00:00:00.000000000 Z
12
+ date: 2022-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2