Sha256: 9a1512be72409079a3cadd943083ece503fa1c0f711bb2af3ac37e4c2cb49c58

Contents?: true

Size: 951 Bytes

Versions: 3

Compression:

Stored size: 951 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)
      client.token_connection.send(method, url, params: params, headers: headers, body: body_params.to_json)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dock_health_api-0.4.1 lib/dock_health_api/resource.rb
dock_health_api-0.4.0 lib/dock_health_api/resource.rb
dock_health_api-0.3.6 lib/dock_health_api/resource.rb