Sha256: ca287f5b5083a2d2dfbf504ac0828d99dd64bd8df1d1c9a26e6a117c5d009136

Contents?: true

Size: 1017 Bytes

Versions: 4

Compression:

Stored size: 1017 Bytes

Contents

module DockHealthApi
  class Resource < Object
    def self.class_name
      name.split("::")[-1]
    end

    def self.url_version
      return "v1"
    end

    def self.client
      @client ||= DockHealthApi::Client.active_client
    end

    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

    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

    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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dock_health_api-0.5.5 lib/dock_health_api/resource.rb
dock_health_api-0.5.4 lib/dock_health_api/resource.rb
dock_health_api-0.5.3 lib/dock_health_api/resource.rb
dock_health_api-0.5.1 lib/dock_health_api/resource.rb