Class: Bittrex::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/bittrex/client.rb

Constant Summary collapse

HOST =
'https://bittrex.com/api/v1.1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Client

Returns a new instance of Client.



10
11
12
13
# File 'lib/bittrex/client.rb', line 10

def initialize(attrs = {})
  @key    = attrs[:key]
  @secret = attrs[:secret]
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



8
9
10
# File 'lib/bittrex/client.rb', line 8

def key
  @key
end

#secretObject (readonly)

Returns the value of attribute secret.



8
9
10
# File 'lib/bittrex/client.rb', line 8

def secret
  @secret
end

Instance Method Details

#get(path, params = {}, headers = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/bittrex/client.rb', line 15

def get(path, params = {}, headers = {})
  nonce = Time.now.to_i
  response = connection.get do |req|
    url = "#{HOST}/#{path}"
    req.params.merge!(params)
    req.url(url)

    if key
      req.params[:apikey]   = key
      req.params[:nonce]    = nonce
      req.headers[:apisign] = signature(url, nonce)
    end
  end

  JSON.parse(response.body)['result']
end