diff --git a/lib/binance/client/rest.rb b/lib/binance/client/rest.rb index e3a9a59..169baf0 100644 --- a/lib/binance/client/rest.rb +++ b/lib/binance/client/rest.rb @@ -9,18 +9,21 @@ module Binance module Client class REST - BASE_URL = 'https://api.binance.com'.freeze - def initialize(api_key: '', secret_key: '', - adapter: Faraday.default_adapter) + adapter: Faraday.default_adapter, + api_url: '') @clients = {} @clients[:public] = public_client adapter @clients[:verified] = verified_client api_key, adapter @clients[:signed] = signed_client api_key, secret_key, adapter @clients[:withdraw] = withdraw_client api_key, secret_key, adapter + @clients[:withdraw_sapi] = withdraw_sapi_client api_key, secret_key, adapter @clients[:public_withdraw] = public_withdraw_client adapter + @api_url = api_url end + BASE_URL = @api_url.freeze + METHODS.each do |method| define_method(method[:name]) do |options = {}| response = @clients[method[:client]].send(method[:action]) do |req| diff --git a/lib/binance/client/rest/clients.rb b/lib/binance/client/rest/clients.rb index 7831998..1c20737 100644 --- a/lib/binance/client/rest/clients.rb +++ b/lib/binance/client/rest/clients.rb @@ -48,6 +48,17 @@ def withdraw_client(api_key, secret_key, adapter) conn.adapter adapter end end + + def withdraw_sapi_client(api_key, secret_key, adapter) + Faraday.new(url: "#{BASE_URL}/sapi") do |conn| + conn.request :url_encoded + conn.response :json, content_type: /\bjson$/ + conn.headers['X-MBX-APIKEY'] = api_key + conn.use TimestampRequestMiddleware + conn.use SignRequestMiddleware, secret_key + conn.adapter adapter + end + end end end -end \ No newline at end of file +end diff --git a/lib/binance/client/rest/endpoints.rb b/lib/binance/client/rest/endpoints.rb index 7595e89..93d57d7 100644 --- a/lib/binance/client/rest/endpoints.rb +++ b/lib/binance/client/rest/endpoints.rb @@ -26,13 +26,15 @@ class REST # Withdraw API Endpoints withdraw: 'v3/withdraw.html', + withdraw_sapi: 'v1/capital/withdraw/apply', deposit_history: 'v3/depositHistory.html', withdraw_history: 'v3/withdrawHistory.html', deposit_address: 'v3/depositAddress.html', account_status: 'v3/accountStatus.html', system_status: 'v3/systemStatus.html', withdraw_fee: 'v3/withdrawFee.html', - dust_log: 'v3/userAssetDribbletLog.html' + dust_log: 'v3/userAssetDribbletLog.html', + all_coin_info: 'v1/capital/config/getall' }.freeze end end diff --git a/lib/binance/client/rest/methods.rb b/lib/binance/client/rest/methods.rb index 6ff72ed..fae5f27 100644 --- a/lib/binance/client/rest/methods.rb +++ b/lib/binance/client/rest/methods.rb @@ -79,6 +79,9 @@ class REST # #withdraw! { name: :withdraw!, client: :withdraw, action: :post, endpoint: :withdraw }, + # #withdraw_sapi! + { name: :withdraw_sapi!, client: :withdraw_sapi, + action: :post, endpoint: :withdraw_sapi }, # #deposit_history { name: :deposit_history, client: :withdraw, action: :get, endpoint: :deposit_history }, @@ -99,7 +102,10 @@ class REST action: :get, endpoint: :withdraw_fee }, # dust_log { name: :dust_log, client: :withdraw, - action: :get, endpoint: :dust_log } + action: :get, endpoint: :dust_log }, + # all_coin_info + { name: :all_coin_info, client: :withdraw_sapi, + action: :get, endpoint: :all_coin_info } ].freeze end end