Sha256: 157822bc0c88aa7631d3e3e28c313c4156ace0e93c7130531c6d87be8bda54d8

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

module Bitstamp
  module Net
    def self.to_uri(path)
      return "https://www.bitstamp.net/api#{path}/"
    end

    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_f*10000).to_i.to_s
        options[:signature] = HMAC::SHA256.hexdigest(Bitstamp.secret, options[:nonce]+Bitstamp.client_id.to_s+options[:key]).upcase
      end

      c.post_body = options.to_query

      c.http(verb)

      return c
    end

    def self.get(path, options={})
      request = self.curl(:GET, path, options)

      return request
    end

    def self.post(path, options={})
      request = self.curl(:POST, path, options)

      return request
    end

    def self.patch(path, options={})
      request = self.curl(:PATCH, path, options)

      return request
    end

    def self.delete(path, options={})
      request = self.curl(:DELETE, path, options)

      return request
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
bitstamp-rbtc-arbitrage-0.4.0 lib/bitstamp/net.rb
rbtc_arbitrage-2.3.0 bitstamp/lib/bitstamp/net.rb
rbtc_arbitrage-2.2.1 bitstamp/lib/bitstamp/net.rb
rbtc_arbitrage-2.2.0 bitstamp/lib/bitstamp/net.rb
rbtc_arbitrage-2.1.2 bitstamp/lib/bitstamp/net.rb
rbtc_arbitrage-2.1.1 bitstamp/lib/bitstamp/net.rb
rbtc_arbitrage-2.1.0 bitstamp/lib/bitstamp/net.rb