Class: BitcointradeSDK::Base
- Inherits:
-
Object
- Object
- BitcointradeSDK::Base
- Defined in:
- lib/bitcointrade_sdk/base.rb
Direct Known Subclasses
BitcointradeSDK::Bitcoin::Deposit, BitcointradeSDK::Bitcoin::Withdraw, Market, Public, Wallets
Constant Summary collapse
- BASE_URL =
'https://api.bitcointrade.com.br/v1'
Instance Method Summary collapse
Instance Method Details
#send_request(verb, path, options = {}, public_response = false) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bitcointrade_sdk/base.rb', line 9 def send_request(verb, path, = {}, public_response = false) = (Time.now.to_f * 1000).round.to_s payload = .empty? || verb == :get ? nil : JSON.dump() query = .any? && verb == :get ? "?#{URI.encode_www_form()}" : '' 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 |