18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/it_bit_sdk/base.rb', line 18
def send_request(verb, path, options = {})
timestamp = (Time.now.to_f * 1000).round.to_s
nonce = next_nonce
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", "")}"
signature = ::ItBitSDK::MessageSigner.new.sign_message(verb, url, payload, nonce, timestamp)
= {
authorization: "#{ItBitSDK.client_key}:#{signature}",
x_auth_timestamp: timestamp,
x_auth_nonce: nonce,
content_type: 'application/json'
}
begin
response = RestClient::Request.execute(
:method => verb,
:url => url,
:payload => payload,
:headers => ,
:ssl_version => 'SSLv23')
rescue => e
response = e.response.body
end
JSON.parse(response.to_str) if response.to_s
end
|