Class: DockHealthApi::Resource
- Inherits:
-
Object
- Object
- OpenStruct
- Object
- DockHealthApi::Resource
show all
- Defined in:
- lib/dock_health_api/resource.rb
Class Method Summary
collapse
Methods inherited from Object
#initialize, #to_ostruct
Class Method Details
.class_name ⇒ Object
3
4
5
|
# File 'lib/dock_health_api/resource.rb', line 3
def self.class_name
name.split("::")[-1]
end
|
11
12
13
|
# File 'lib/dock_health_api/resource.rb', line 11
def self.client
DockHealthApi::Client.instance
end
|
.execute_request(method, url, params: {}, headers: {}, body_params: nil) ⇒ Object
29
30
31
32
|
# File 'lib/dock_health_api/resource.rb', line 29
def self.execute_request(method, url, params: {}, headers: {}, body_params: nil)
response = client.token_connection.send(method, url, params: params, headers: , body: body_params.to_json)
client.config.debug ? response : response.parsed
end
|
25
26
27
|
# File 'lib/dock_health_api/resource.rb', line 25
def self.
{"Content-Type": "application/json", "x-api-key": client.config.api, "x-user-id": client.config.user_id, "x-organization-id": client.config.org_id}
end
|
.resource_url ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/dock_health_api/resource.rb', line 15
def self.resource_url
if self == Resource
raise NotImplementedError,
"Resource is an abstract class. You should perform actions " \
"on its subclasses (e.g. Patient)"
end
"#{client.config.resource_url}/api/#{url_version}/#{class_name.downcase}"
end
|
.url_version ⇒ Object
7
8
9
|
# File 'lib/dock_health_api/resource.rb', line 7
def self.url_version
return "v1"
end
|