6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/binance/api/request.rb', line 6
def send!(api_key_type: :none, headers: {}, method: :get, path: "/", params: {}, security_type: :none, tld: Configuration.tld, api_key: nil, api_secret_key: nil)
Configuration.validate_tld!(tld)
binance_uri = ENV['BINANCE_TEST_NET_ENABLE'] ? "https://testnet.binance.vision" : "https://api.binance.#{tld}"
self.base_uri binance_uri
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
|