class BitcointradeSDK::Base
Constants
- BASE_URL
Public Instance Methods
send_request(verb, path, options = {}, public_response = false)
click to toggle source
# File lib/bitcointrade_sdk/base.rb, line 9 def send_request(verb, path, options = {}, public_response = false) timestamp = (Time.now.to_f * 1000).round.to_s payload = options.empty? || verb == :get ? nil : JSON.dump(options) query = options.any? && verb == :get ? "?#{URI.encode_www_form(options)}" : '' url = "#{BASE_URL}#{path}#{query.gsub("%E2%80%8B", "")}" headers = { content_type: 'application/json' } headers[:authorization] = "ApiToken #{BitcointradeSDK.api_token}" unless public_response begin response = RestClient::Request.execute( :method => verb, :url => url, :payload => payload, :headers => headers) rescue => e response = e.response.body end JSON.parse(response.to_str) if response.to_s end