33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/cryptsy/api2.rb', line 33
def self.send(path, query={}, public_key=nil, private_key=nil, method="GET")
auth = !public_key.nil? && !private_key.nil?
url = "https://api.cryptsy.com/api/v2/#{path}"
query[:nonce] = nonce if auth
options = URI.encode_www_form(query) unless query.empty?
= {}
["Sign"] = sign(query, private_key) if auth
["Key"] = public_key if auth
case method
when "POST"
response = HTTParty.post(url, headers: , body: query)
when "DELETE"
response = HTTParty.delete(url, headers: , body: query)
else
response = HTTParty.get(url, headers: , query: query)
end
return JSON.parse(response.body)
rescue JSON::ParserError => e
return response.body
end
|