Module: Coinstats

Defined in:
lib/coinstats.rb,
lib/coinstats/version.rb

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add(a, b) ⇒ Object



4
5
6
# File 'lib/coinstats.rb', line 4

def self.add(a,b)
   a + b
end

Instance Method Details

#get_http(url, body = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/coinstats.rb', line 7

def get_http(url, body=nil)
nonce = (Time.now.to_f * 1e6).to_i
message = nonce.to_s + url + body.to_s
signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new('sha256'), API_SECRET, message)
headers = {"ACCESS_KEY" => API_KEY,
           "ACCESS_SIGNATURE" => signature,
           "ACCESS_NONCE" => nonce}
begin
  if body.nil?
    RestClient.get(url, headers)
  else
    RestClient.post(url, body, headers)
  end
rescue => e
  puts e
  e.response
end
end