Sha256: 0086cde4517fb5f2b7b51f4428a30066511cd3c1141dfa9925e7ad14b9f1459d

Contents?: true

Size: 993 Bytes

Versions: 1

Compression:

Stored size: 993 Bytes

Contents

require 'active_support/inflector'
require 'active_support/core_ext/hash'
require 'base64'
require 'securerandom'
require 'addressabler'
require 'httparty'
require 'hashie'

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) }
      config.limiter_interface = KrakenClient::Requests::Limiter.new(config)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kraken_client-1.2 lib/kraken_client/application.rb