Class: DockHealthApi::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/dock_health_api/resource.rb

Class Method Summary collapse

Methods inherited from Object

#initialize, #to_ostruct

Constructor Details

This class inherits a constructor from DockHealthApi::Object

Class Method Details

.class_nameObject



3
4
5
# File 'lib/dock_health_api/resource.rb', line 3

def self.class_name
  name.split("::")[-1]
end

.clientObject



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: headers, body: body_params.to_json)
  client.config.debug ? response : response.parsed
end

.headersObject



25
26
27
# File 'lib/dock_health_api/resource.rb', line 25

def self.headers
  {"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_urlObject



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_versionObject



7
8
9
# File 'lib/dock_health_api/resource.rb', line 7

def self.url_version
  return "v1"
end