Method: Bitmex.signature

Defined in:
lib/bitmex.rb

.signature(api_secret, verb, path, expires, body, query) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/bitmex.rb', line 31

def self.signature(api_secret, verb, path, expires, body, query)
  body = '' if body.nil?
  body = body.to_s unless body.is_a? String

  if query != nil && query.is_a?(Hash) && !query.empty?
    path += "?#{URI.encode_www_form(query)}"
  end

  data = verb + path + expires.to_s + body
  OpenSSL::HMAC.hexdigest 'SHA256', api_secret, data
end