Module: Bitso::Net

Defined in:
lib/bitso/net.rb

Class Method Summary collapse

Class Method Details

.bitso_options(options = {}) ⇒ Object



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

def self.bitso_options(options={})
  if Bitso.configured?
    options[:key] = Bitso.key
    options[:nonce] = (Time.now.to_f*10000).to_i.to_s
    joint_string = (options[:nonce] + Bitso.client_id.to_s + options[:key])
    options[:signature] = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), Bitso.secret, joint_string).upcase
  end

  options
end

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



19
20
21
# File 'lib/bitso/net.rb', line 19

def self.delete(path, options={})
  RestClient.delete(self.to_uri(path), self.bitso_options(options))
end

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



7
8
9
# File 'lib/bitso/net.rb', line 7

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

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



15
16
17
# File 'lib/bitso/net.rb', line 15

def self.patch(path, options={})
  RestClient.put(self.to_uri(path), self.bitso_options(options))
end

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



11
12
13
# File 'lib/bitso/net.rb', line 11

def self.post(path, options={})
  RestClient.post(self.to_uri(path), self.bitso_options(options))
end

.to_uri(path) ⇒ Object



3
4
5
# File 'lib/bitso/net.rb', line 3

def self.to_uri(path)
  return "https://api.bitso.com/v2#{path}/"
end