Sha256: 7f91c8da62e1ae45e8013a8167a277fc8b8c05cd3b5e3c78ba6c1279bf029a0a

Contents?: true

Size: 892 Bytes

Versions: 2

Compression:

Stored size: 892 Bytes

Contents

require 'active_support/inflector'
require 'base64'
require 'securerandom'
require 'addressabler'
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

2 entries across 2 versions & 1 rubygems

Version Path
kraken_client-1.1.2 lib/kraken_client/application.rb
kraken_client-1.1.1 lib/kraken_client/application.rb