Module: Bitstamp::Net

Defined in:
lib/bitstamp/net.rb

Class Method Summary collapse

Class Method Details

.bitstamp_options(options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/bitstamp/net.rb', line 24

def self.bitstamp_options(options={})
  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

  options
end

.delete(path, options = {}) ⇒ Object



20
21
22
# File 'lib/bitstamp/net.rb', line 20

def self.delete(path, options={})
  rest path, :delete, bitstamp_options(options)
end

.get(path, options = {}) ⇒ Object



8
9
10
# File 'lib/bitstamp/net.rb', line 8

def self.get(path, options={})
  rest path
end

.patch(path, options = {}) ⇒ Object



16
17
18
# File 'lib/bitstamp/net.rb', line 16

def self.patch(path, options={})
  rest path, :put, bitstamp_options(options)
end

.post(path, options = {}) ⇒ Object



12
13
14
# File 'lib/bitstamp/net.rb', line 12

def self.post(path, options={})
  rest path, :post, bitstamp_options(options)
end

.rest(path, method = :get, options = {}) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/bitstamp/net.rb', line 34

def self.rest(path, method=:get, options={})
  RestClient::Request.execute(
    method: method,
    url: to_uri(path),
    payload: options,
    ssl_version: 'SSLv23'
  )
end

.to_uri(path) ⇒ Object



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

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