module MercadoBitcoin
Constants
- BASE_URL
- VERSION
Attributes
api_key[R]
api_secret[R]
pin[R]
Public Class Methods
authenticate!(credentials)
click to toggle source
# File lib/mercadobitcoin.rb, line 35 def authenticate!(credentials) credentials = credentials.with_indifferent_access @api_key = credentials[:api_key] @api_secret = credentials[:api_secret] @pin = credentials[:pin] end
balance()
click to toggle source
# File lib/mercadobitcoin.rb, line 12 def balance current_tonce = tonce method = "getInfo" headers = { "Content-type" => "application/x-www-form-urlencoded", "Key" => api_key, "Sign" => signature(method, current_tonce) } HTTParty.post(BASE_URL, { body: { method: method, tonce: current_tonce, }, headers: headers }) end
signature(method, current_tonce)
click to toggle source
# File lib/mercadobitcoin.rb, line 43 def signature(method, current_tonce) message = [method, pin, current_tonce].join(":") hash = HMAC::SHA512.hexdigest(api_secret, message) end
tonce()
click to toggle source
# File lib/mercadobitcoin.rb, line 31 def tonce Time.now.to_i end