class Bitstamp::Client
Constants
- BASE_URI
- CONNECTTIMEOUT
- TIMEOUT
Public Class Methods
call(request_uri, method, body)
click to toggle source
# File lib/bitstamp/client.rb, line 44 def call(request_uri, method, body) request_hash = { method: method, body: body, headers: { 'User-Agent' => "Bitstamp::Client Ruby v#{::Bitstamp::VERSION}" }, connecttimeout: CONNECTTIMEOUT, timeout: TIMEOUT } request = ::Typhoeus::Request.new(request_uri, request_hash) response = request.run return handle_body(response.body) end
new(customer_id:, api_key:, secret:)
click to toggle source
# File lib/bitstamp/client.rb, line 19 def initialize(customer_id:, api_key:, secret:) @customer_id = customer_id @api_key = api_key @secret = secret end
request_uri(*parts)
click to toggle source
# File lib/bitstamp/client.rb, line 33 def request_uri(*parts) uri = BASE_URI parts.each do |part| uri += "/" uri += part end return uri + "/" end
Public Instance Methods
build_signature(nonce)
click to toggle source
# File lib/bitstamp/client.rb, line 88 def build_signature(nonce) message = nonce + @customer_id + @api_key return OpenSSL::HMAC.hexdigest("SHA256", @secret, message).upcase end
call(request_uri, method, body)
click to toggle source
# File lib/bitstamp/client.rb, line 71 def call(request_uri, method, body) body = params_with_signature(body) ::Bitstamp::Client.call(request_uri, method, body) end
params_with_signature(params = {})
click to toggle source
# File lib/bitstamp/client.rb, line 77 def params_with_signature(params = {}) if params[:nonce] == nil params[:nonce] = (Time.now.to_f * 1000000).to_i.to_s # Microseconds end params[:key] = @api_key params[:signature] = build_signature(params[:nonce]) return params end