9
10
11
12
13
14
15
16
17
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/binance/sdk/request.rb', line 9
def send!(api_key_type: :none, headers: {}, method: :get, path: "/", params: {}, security_type: :none, tld: Configuration.tld, api_key: nil, api_secret_key: nil, testnet: false, futures: false)
Configuration.validate_tld!(tld)
if Configuration.testnet?
self.base_uri 'https://testnet.binancefuture.com'
else
if Configuration.futures?
self.base_uri 'https://fapi.binance.com'
else
self.base_uri 'https://api.binance.com'
end
end
raise Error.new(message: "Invalid security type #{security_type}") unless SECURITY_TYPES.include?(security_type)
= (api_key_type: api_key_type, security_type: security_type, api_key: api_key)
params.delete_if { |k, v| v.nil? }
if %w(trade user_data).include?(security_type&.to_s)
signature = signed_request_signature(params: params, api_secret_key: api_secret_key)
params.merge!(signature: signature)
end
case method
when :get
response = get(path, headers: , query: params)
when :post
response = post(path, query: params, headers: )
when :put
response = put(path, query: params, headers: )
when :delete
response = delete(path, query: params, headers: )
else
raise Error.new(message: "invalid http method used: #{method}")
end
process!(response: response || "{}")
end
|