Close #3 Добавил фильтр к нейтральным
This commit is contained in:
7
dm-cli/.vscode/launch.json
vendored
7
dm-cli/.vscode/launch.json
vendored
@@ -12,10 +12,11 @@
|
||||
"args": [ "--address",
|
||||
"https://testnet-dm2.bitdeals.org",
|
||||
"--debug",
|
||||
"deal",
|
||||
"account",
|
||||
"status",
|
||||
"--is-paid",
|
||||
"2NDkN9PWdvf8T3AFe57vDsQX9qeJG5Y5iJW"
|
||||
"-f",
|
||||
"n",
|
||||
"mraXx7JrmAmuKypdJ1vseQBXySsdRZE5AC"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
|
||||
@@ -27,13 +27,14 @@ void AccountHelp(bool isRussian)
|
||||
/// @param address адресс АПИ
|
||||
/// @param bkaddress номер кошелька
|
||||
/// @param isDebug флаг отладки
|
||||
int AccountStatus(const std::string address, const char* bkaddress, bool isDebug)
|
||||
int AccountStatus(const std::string address, const char *bkaddress, bool isDebug)
|
||||
{
|
||||
// curl "https://testnet-dm.bitdeals.org/api/v1/account/status?address=mnumHs9HQMrw2Q1iKLNnx9NzExS7nMLmyp"
|
||||
string url("curl -s ");
|
||||
url += address + "/api/v1/account/status?address=" + bkaddress ;
|
||||
url += address + "/api/v1/account/status?address=" + bkaddress;
|
||||
string result = ExecCommand(url.c_str());
|
||||
if (result.length() == 0) return NoResponse("");
|
||||
if (result.length() == 0)
|
||||
return NoResponse("");
|
||||
nlohmann::json jsonData = nlohmann::json::parse(result);
|
||||
|
||||
string payload("");
|
||||
@@ -43,16 +44,20 @@ int AccountStatus(const std::string address, const char* bkaddress, bool isDebug
|
||||
string decoded = base64_decode(payload);
|
||||
string cleaned = cleanup_html(decoded);
|
||||
cout << cleaned << endl;
|
||||
if (isDebug) ShowDebug(url, result, success, decoded);
|
||||
if (success) return 0; else return 1;
|
||||
if (isDebug)
|
||||
ShowDebug(url, result, success, decoded);
|
||||
if (success)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/// @brief Получение информации аккаунта
|
||||
/// @param address адресс АПИ
|
||||
/// @param bkaddress номер кошелька
|
||||
/// @param isDebug флаг отладки
|
||||
int AccountInfo(const std::string address, const char* bkaddress, bool isDebug) {
|
||||
int AccountInfo(const std::string address, const char *bkaddress, bool isDebug)
|
||||
{
|
||||
|
||||
// curl -H "Content-Type: application/json" -d "{ \"code\": \"mnumHs9HQMrw2Q1iKLNnx9NzExS7nMLmyp\"}" https://testnet-dm2.bitdeals.org/api/v1/user/profile
|
||||
string url("curl -s ");
|
||||
@@ -64,10 +69,10 @@ int AccountInfo(const std::string address, const char* bkaddress, bool isDebug)
|
||||
url.append("/api/v1/user/profile");
|
||||
|
||||
string result = ExecCommand(url.c_str());
|
||||
if (result.length() == 0) return NoResponse("");
|
||||
if (result.length() == 0)
|
||||
return NoResponse("");
|
||||
nlohmann::json jsonData = nlohmann::json::parse(result);
|
||||
|
||||
|
||||
string bitcoin("");
|
||||
string btckey("");
|
||||
string bitmessage("");
|
||||
@@ -78,9 +83,6 @@ int AccountInfo(const std::string address, const char* bkaddress, bool isDebug)
|
||||
bitmessage = jsonData["bitmessages"][0];
|
||||
pgpkey = jsonData["pgpkey"];
|
||||
|
||||
|
||||
|
||||
|
||||
string decoded("");
|
||||
decoded.append("bitcoin: ");
|
||||
decoded.append(bitcoin);
|
||||
@@ -90,20 +92,18 @@ int AccountInfo(const std::string address, const char* bkaddress, bool isDebug)
|
||||
decoded.append(btckey);
|
||||
decoded.append("\n");
|
||||
|
||||
|
||||
decoded.append("bitmessage: ");
|
||||
decoded.append(bitmessage);
|
||||
decoded.append("\n");
|
||||
|
||||
|
||||
decoded.append("pgpkey: ");
|
||||
decoded.append(pgpkey);
|
||||
decoded.append("\n");
|
||||
|
||||
cout << decoded << endl;
|
||||
|
||||
if (isDebug) ShowDebug(url, result, 1, decoded);
|
||||
|
||||
if (isDebug)
|
||||
ShowDebug(url, result, 1, decoded);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -112,7 +112,8 @@ int AccountInfo(const std::string address, const char* bkaddress, bool isDebug)
|
||||
/// @param address адресс АПИ
|
||||
/// @param bkaddress номер кошелька
|
||||
/// @param isDebug флаг отладки
|
||||
int AccountRaiting(const std::string address, const char* bkaddress, bool isDebug) {
|
||||
int AccountRaiting(const std::string address, const char *bkaddress, bool isDebug)
|
||||
{
|
||||
// curl -H "Content-Type: application/json" -d "{ \"code\": \"mnumHs9HQMrw2Q1iKLNnx9NzExS7nMLmyp\"}" https://testnet-dm2.bitdeals.org/api/v1/user/profile
|
||||
string url("curl -s ");
|
||||
url.append("-H \"Content-Type: application/json\" ");
|
||||
@@ -123,12 +124,10 @@ int AccountRaiting(const std::string address, const char* bkaddress, bool isDebu
|
||||
url.append("/api/v1/user/profile");
|
||||
|
||||
string result = ExecCommand(url.c_str());
|
||||
if (result.length() == 0) return NoResponse("");
|
||||
if (result.length() == 0)
|
||||
return NoResponse("");
|
||||
nlohmann::json jsonData = nlohmann::json::parse(result);
|
||||
|
||||
|
||||
|
||||
|
||||
std::ostringstream stream;
|
||||
|
||||
stream << "created: " << jsonData["created"] << endl;
|
||||
@@ -136,7 +135,6 @@ int AccountRaiting(const std::string address, const char* bkaddress, bool isDebu
|
||||
stream << " count: " << jsonData["seller"]["count"] << endl;
|
||||
stream << " positive: " << jsonData["seller"]["positive"] << endl;
|
||||
|
||||
|
||||
stream << "customer: " << endl;
|
||||
stream << " count: " << jsonData["customer"]["count"] << endl;
|
||||
stream << " positive: " << jsonData["customer"]["positive"] << endl;
|
||||
@@ -144,19 +142,19 @@ int AccountRaiting(const std::string address, const char* bkaddress, bool isDebu
|
||||
string decoded = stream.str();
|
||||
cout << decoded << endl;
|
||||
|
||||
if (isDebug) ShowDebug(url, result, 1, decoded);
|
||||
|
||||
if (isDebug)
|
||||
ShowDebug(url, result, 1, decoded);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/// @brief Получение Рейтинга аккаунта
|
||||
/// @param address адресс АПИ
|
||||
/// @param bkaddress номер кошелька
|
||||
/// @param isDebug флаг отладки
|
||||
/// @param fb - тип фидбэка 0- все p - 1(positive) n-2 (negative)
|
||||
int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDebug, int fb) {
|
||||
int AccountFeedbacks(const std::string address, const char *bkaddress, bool isDebug, int fb)
|
||||
{
|
||||
|
||||
/*
|
||||
curl -X POST "https://testnet-dm2.bitdeals.org/api/v1/deal/feedback/list" \
|
||||
@@ -172,12 +170,12 @@ int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDe
|
||||
url.append(bkaddress);
|
||||
url.append("\\\"}],\\\"orderby\\\":[\\\" date DESC\\\"],\\\"reclimit\\\":100,\\\"recoffset\\\":0} \" ");
|
||||
|
||||
|
||||
url.append(address);
|
||||
url.append("/api/v1/deal/feedback/list");
|
||||
|
||||
string result = ExecCommand(url.c_str());
|
||||
if (result.length() == 0) return NoResponse("");
|
||||
if (result.length() == 0)
|
||||
return NoResponse("");
|
||||
nlohmann::json jsonData = nlohmann::json::parse(result);
|
||||
|
||||
std::ostringstream stream;
|
||||
@@ -185,7 +183,8 @@ int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDe
|
||||
int positivefb = 0;
|
||||
int negativefb = 0;
|
||||
|
||||
for (size_t i = 0;i < size;++i) {
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
{
|
||||
// "positive"
|
||||
// "negative"
|
||||
// 0 - все p - 1(positive)n - 2 (negative)
|
||||
@@ -193,33 +192,35 @@ int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDe
|
||||
auto val = jsonData[i];
|
||||
string statustext = val["statustext"];
|
||||
|
||||
if (statustext.compare("positive") == 0) positivefb++;
|
||||
if (statustext.compare("negative") == 0) negativefb++;
|
||||
if (statustext.compare("positive") == 0)
|
||||
positivefb++;
|
||||
if (statustext.compare("negative") == 0)
|
||||
negativefb++;
|
||||
|
||||
|
||||
if (fb == 0) {
|
||||
if (fb == 0)
|
||||
{
|
||||
stream << "- deal: " << val["deal"] << endl;
|
||||
stream << " date: " << val["date"] << endl;
|
||||
stream << " statustext: " << val["statustext"] << endl;
|
||||
stream << " comments: " << val["comments"] << endl;
|
||||
}
|
||||
else {
|
||||
if (fb == 1 && statustext.compare("positive") == 0) {
|
||||
else
|
||||
{
|
||||
if (fb == 1 && statustext.compare("positive") == 0)
|
||||
{
|
||||
stream << "- deal: " << val["deal"] << endl;
|
||||
stream << " date: " << val["date"] << endl;
|
||||
stream << " statustext: " << val["statustext"] << endl;
|
||||
stream << " comments: " << val["comments"] << endl;
|
||||
}
|
||||
else if (fb == 2 && statustext.compare("negative") == 0) {
|
||||
else if (fb == 2 && statustext.compare("negative") == 0 || fb == 2 && statustext.compare("neutral") == 0)
|
||||
{
|
||||
stream << "- deal: " << val["deal"] << endl;
|
||||
stream << " date: " << val["date"] << endl;
|
||||
stream << " statustext: " << val["statustext"] << endl;
|
||||
stream << " comments: " << val["comments"] << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
stream << "------------Summary--------------" << endl;
|
||||
stream << "total: " << size << endl;
|
||||
@@ -229,11 +230,10 @@ int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDe
|
||||
string decoded = stream.str();
|
||||
cout << decoded << endl;
|
||||
|
||||
if (isDebug) ShowDebug(url, result, 1, decoded);
|
||||
|
||||
if (isDebug)
|
||||
ShowDebug(url, result, 1, decoded);
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user