module Bitstamp::Net

Public Class Methods

curl(verb, path, options={}) click to toggle source
# File lib/bitstamp/net.rb, line 7
def self.curl(verb, path, options={})
  verb = verb.upcase.to_sym

  c = Curl::Easy.new(self.to_uri(path))

  if Bitstamp.configured?
    options[:key] = Bitstamp.key
    options[:nonce] = Time.now.to_i.to_s
    options[:signature] = HMAC::SHA256.hexdigest(Bitstamp.secret, options[:nonce]+Bitstamp.client_id+options[:key]).upcase
  end

  c.post_body = options.to_query

  c.http(verb)

  return c
end
delete(path, options={}) click to toggle source
# File lib/bitstamp/net.rb, line 43
def self.delete(path, options={})
  request = self.curl(:DELETE, path, options)

  return request
end
get(path, options={}) click to toggle source
# File lib/bitstamp/net.rb, line 25
def self.get(path, options={})
  request = self.curl(:GET, path, options)

  return request
end
patch(path, options={}) click to toggle source
# File lib/bitstamp/net.rb, line 37
def self.patch(path, options={})
  request = self.curl(:PATCH, path, options)

  return request
end
post(path, options={}) click to toggle source
# File lib/bitstamp/net.rb, line 31
def self.post(path, options={})
  request = self.curl(:POST, path, options)

  return request
end
to_uri(path) click to toggle source
# File lib/bitstamp/net.rb, line 3
def self.to_uri(path)
  return "https://www.bitstamp.net/api#{path}/"
end