Skip to content

Commit 119b7f1

Browse files
committed
add C2C and FIAT
1 parent b736121 commit 119b7f1

File tree

2 files changed

+219
-1
lines changed

2 files changed

+219
-1
lines changed

include/Exchange_Client.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ class Client
173173
Json::Value asset_dividend_records(const Params* params_ptr = nullptr);
174174
Json::Value make_user_transfer_universal(const Params* params_ptr);
175175
Json::Value query_user_transfer_universal(const Params* params_ptr);
176+
Json::Value funding_wallet(const Params* params_ptr = nullptr);
177+
Json::Value get_api_key_permission(const Params* params_ptr = nullptr);
176178

177179
};
178180

@@ -378,6 +380,28 @@ class Client
378380
Json::Value request_quote(const Params* params_ptr);
379381
Json::Value make_swap(const Params* params_ptr);
380382
Json::Value get_swap_history(const Params* params_ptr);
383+
384+
};
385+
386+
struct Fiat
387+
{
388+
const Client<T>* user_client;
389+
explicit Fiat(Client<T>& client);
390+
explicit Fiat(const Client<T>& client);
391+
~Fiat();
392+
393+
Json::Value get_fiat_deposit_withdrawal_history(const Params* params_ptr);
394+
Json::Value get_fiat_payments_history(const Params* params_ptr);
395+
};
396+
397+
struct C2C
398+
{
399+
const Client<T>* user_client;
400+
explicit C2C(Client<T>& client);
401+
explicit C2C(const Client<T>& client);
402+
~C2C();
403+
404+
Json::Value get_c2c_trades_history(const Params* params_ptr);
381405
};
382406

383407
Json::Value custom_get_req(const std::string& base, const std::string& endpoint, const Params* params_ptr, const bool& signature = 0);

src/Binance_Client.cpp

Lines changed: 195 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,52 @@ Json::Value Client<T>::Wallet::query_user_transfer_universal(const Params* param
10931093
}
10941094
};
10951095

1096+
/**
1097+
Funding Wallet
1098+
@param params_ptr - a pointer to the request Params object
1099+
@return the json returned by the request
1100+
*/
1101+
template <typename T>
1102+
Json::Value Client<T>::Wallet::funding_wallet(const Params* params_ptr)
1103+
{
1104+
try
1105+
{
1106+
std::string full_path = _BASE_REST_SPOT + "/sapi/v1/asset/get-funding-asset";
1107+
std::string query = user_client->_generate_query(params_ptr, 1);
1108+
Json::Value response = (user_client->_rest_client)->_postreq(full_path + query);
1109+
1110+
return response;
1111+
}
1112+
catch (ClientException e)
1113+
{
1114+
e.append_to_traceback(std::string(__FUNCTION__));
1115+
throw(e);
1116+
}
1117+
};
1118+
1119+
/**
1120+
Get API Key Permission
1121+
@param params_ptr - a pointer to the request Params object
1122+
@return the json returned by the request
1123+
*/
1124+
template <typename T>
1125+
Json::Value Client<T>::Wallet::get_api_key_permission(const Params* params_ptr)
1126+
{
1127+
try
1128+
{
1129+
std::string full_path = _BASE_REST_SPOT + "/sapi/v1/account/apiRestrictions";
1130+
std::string query = user_client->_generate_query(params_ptr, 1);
1131+
Json::Value response = (user_client->_rest_client)->_getreq(full_path + query);
1132+
1133+
return response;
1134+
}
1135+
catch (ClientException e)
1136+
{
1137+
e.append_to_traceback(std::string(__FUNCTION__));
1138+
throw(e);
1139+
}
1140+
};
1141+
10961142
// ------------------------------ End | Client Wallet - User Wallet Endpoints
10971143

10981144
// ***************************************************************************
@@ -4406,7 +4452,155 @@ Json::Value Client<T>::BSwap::get_swap_history(const Params* params_ptr)
44064452
}
44074453
};
44084454

4409-
// ------------------------------ End | Client BLVT - User Mining Endpoints
4455+
// ------------------------------ End | Client BSwap - User Mining Endpoints
4456+
4457+
4458+
// ------------------------------ Start | Client Fiat - User Mining Endpoints
4459+
4460+
4461+
/**
4462+
A constructor - called directly by the user
4463+
@param client_obj - the exchange client object
4464+
*/
4465+
template <typename T>
4466+
Client<T>::Fiat::Fiat(Client<T>& client_obj)
4467+
: user_client{ &client_obj }
4468+
{
4469+
if (user_client->_public_client)
4470+
{
4471+
MissingCredentials e{};
4472+
e.append_to_traceback(std::string(__FUNCTION__));
4473+
throw(e);
4474+
};
4475+
}
4476+
4477+
/**
4478+
A constructor - called directly by the user
4479+
@param client_obj - the exchange client object (constant)
4480+
*/
4481+
template <typename T>
4482+
Client<T>::Fiat::Fiat(const Client<T>& client_obj)
4483+
: user_client{ &client_obj } // snatching pointer and releasing later on to avoid deleting this reference
4484+
{
4485+
if (user_client->_public_client)
4486+
{
4487+
MissingCredentials e{};
4488+
e.append_to_traceback(std::string(__FUNCTION__));
4489+
throw(e);
4490+
};
4491+
}
4492+
4493+
/**
4494+
Destructor
4495+
set 'user_client' as nullptr to avoid deleting the exchange client
4496+
object passed from outside the class (reference)
4497+
*/
4498+
template <typename T>
4499+
Client<T>::Fiat::~Fiat()
4500+
{
4501+
user_client = nullptr;
4502+
}
4503+
4504+
// ------ Endpoint methods
4505+
4506+
/**
4507+
Get Fiat Deposit/Withdraw History
4508+
@param params_ptr - a pointer to the request Params object
4509+
@return json returned by the request
4510+
*/
4511+
template <typename T>
4512+
Json::Value Client<T>::Fiat::get_fiat_deposit_withdrawal_history(const Params* params_ptr)
4513+
{
4514+
try
4515+
{
4516+
std::string full_path = _BASE_REST_SPOT + "/sapi/v1/fiat/order";
4517+
std::string query = user_client->_generate_query(params_ptr, 1);
4518+
Json::Value response = (user_client->_rest_client)->_getreq(full_path + query);
4519+
4520+
return response;
4521+
}
4522+
catch (ClientException e)
4523+
{
4524+
e.append_to_traceback(std::string(__FUNCTION__));
4525+
throw(e);
4526+
}
4527+
};
4528+
4529+
// ------------------------------ End | Client Fiat - User Mining Endpoints
4530+
4531+
4532+
// ------------------------------ Start | Client C2C - User Mining Endpoints
4533+
4534+
4535+
/**
4536+
A constructor - called directly by the user
4537+
@param client_obj - the exchange client object
4538+
*/
4539+
template <typename T>
4540+
Client<T>::C2C::C2C(Client<T>& client_obj)
4541+
: user_client{ &client_obj }
4542+
{
4543+
if (user_client->_public_client)
4544+
{
4545+
MissingCredentials e{};
4546+
e.append_to_traceback(std::string(__FUNCTION__));
4547+
throw(e);
4548+
};
4549+
}
4550+
4551+
/**
4552+
A constructor - called directly by the user
4553+
@param client_obj - the exchange client object (constant)
4554+
*/
4555+
template <typename T>
4556+
Client<T>::C2C::C2C(const Client<T>& client_obj)
4557+
: user_client{ &client_obj } // snatching pointer and releasing later on to avoid deleting this reference
4558+
{
4559+
if (user_client->_public_client)
4560+
{
4561+
MissingCredentials e{};
4562+
e.append_to_traceback(std::string(__FUNCTION__));
4563+
throw(e);
4564+
};
4565+
}
4566+
4567+
/**
4568+
Destructor
4569+
set 'user_client' as nullptr to avoid deleting the exchange client
4570+
object passed from outside the class (reference)
4571+
*/
4572+
template <typename T>
4573+
Client<T>::C2C::~C2C()
4574+
{
4575+
user_client = nullptr;
4576+
}
4577+
4578+
// ------ Endpoint methods
4579+
4580+
/**
4581+
Get C2C Trade History
4582+
@param params_ptr - a pointer to the request Params object
4583+
@return json returned by the request
4584+
*/
4585+
template <typename T>
4586+
Json::Value Client<T>::C2C::get_c2c_trades_history(const Params* params_ptr)
4587+
{
4588+
try
4589+
{
4590+
std::string full_path = _BASE_REST_SPOT + "/sapi/v1/c2c/orderMatch/listUserOrderHistory";
4591+
std::string query = user_client->_generate_query(params_ptr, 1);
4592+
Json::Value response = (user_client->_rest_client)->_getreq(full_path + query);
4593+
4594+
return response;
4595+
}
4596+
catch (ClientException e)
4597+
{
4598+
e.append_to_traceback(std::string(__FUNCTION__));
4599+
throw(e);
4600+
}
4601+
};
4602+
4603+
// ------------------------------ End | Client C2C - User Mining Endpoints
44104604

44114605

44124606
// =======================================================================================================

0 commit comments

Comments
 (0)