Sha256: cfe8f5391a8cc1e491ecb142d13579679b68859c5f891031e1b19c5cd18de1f8

Contents?: true

Size: 724 Bytes

Versions: 1

Compression:

Stored size: 724 Bytes

Contents

require "oauth2"

module DockHealthApi
  class Client
    attr_reader :config

    def initialize(config = {})
      @config = config
    end

    def self.active_client
      new(DockHealthApi.config)
    end

    def connection
      @connection ||= OAuth2::Client.new(config.api_key, config.api_secret, token_url: config.token_url, raise_errors: false)
    end

    def token_connection
      @token_connection ||= connection.client_credentials.get_token(scope:"dockhealth/system.developer.read dockhealth/user.all.write dockhealth/user.all.read dockhealth/system.developer.write dockhealth/patient.all.read dockhealth/patient.all.write") 
    end

    def token
      @token ||= token_connection.token
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dock_health_api-0.3.6 lib/dock_health_api/client.rb