Sha256: 6fff77941bc1b494352f2f00a9b3206e70d0a3bc4204fc4fbb5cad140a53aa55

Contents?: true

Size: 859 Bytes

Versions: 5

Compression:

Stored size: 859 Bytes

Contents

require 'base64'
require 'securerandom'
require 'addressable/uri'
require 'httparty'
require 'hashie'
require 'pry'

module KrakenClient
  class Application

    def initialize(params)
      set_config(params)
    end

    def public(options = {})
      ::KrakenClient::Endpoints::Public.new(config, options)
    end

    def private(options = {})
      requires_api_keys

      ::KrakenClient::Endpoints::Private.new(config, options)
    end

    def config
      @config ||= ::KrakenClient.config.dup
    end

    private

    def requires_api_keys
      return unless api_keys_missing?

      fail KrakenClient::MissingApiKeys, 'This feature requires API credentials.'
    end

    def api_keys_missing?
      !(config.api_key && config.api_secret)
    end

    def set_config(params)
      params.each { |k, v| config.send("#{k}=", v) }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kraken_client-1.0.2 lib/kraken_client/application.rb
kraken_client-1.0.1 lib/kraken_client/application.rb
kraken_client-1.0.0 lib/kraken_client/application.rb
kraken_client-0.2.1 lib/kraken_client/application.rb
kraken_client-0.2.0 lib/kraken_client/application.rb