Cancel method

This commit is contained in:
Vladimir N. Korotenko
2025-11-15 19:26:57 +03:00
parent 3585739fe6
commit 3544a61089

View File

@@ -312,7 +312,55 @@ int Deals::Complite() {
ShowDebug(data, decoded, 0, result); ShowDebug(data, decoded, 0, result);
return 0; return 0;
} }
int Deals::Cancel() { return 0; } int Deals::Cancel() {
string data = CommonStatus();
string result = ExecCommand(data.c_str());
if (result.length() == 0)
return NoResponse("");
nlohmann::json jsonData = nlohmann::json::parse(result);
nlohmann::json deal = jsonData["deal"];
string message;
string sign;
if (parser.cmdOptionExists("-m") || parser.cmdOptionExists("--message"))
{
message = GetVal("-m", "--message");
}
if (parser.cmdOptionExists("-s") || parser.cmdOptionExists("--signature"))
{
sign = GetVal("-s", "--signature");
}
deal["seller"]["signature"] = sign;
deal["feedback"]["comments"] = message;
string jsf = deal.dump();
jsf = ReplaceAll(jsf, "\"", "\\\"");
data = "curl -X POST \"";
data.append(address);
data.append("/api/v1/deal/cancel\" -H \"Content-Type: application/json\" ");
data.append("-d \"");
data.append(jsf);
data.append("\"");
result = ExecCommand(data.c_str());
if (result.length() == 0)
return NoResponse("");
std::ostringstream stream;
stream << "success: " << jsonData["result"]["success"] << endl;
stream << "message: " << jsonData["result"]["message"] << endl;
string decoded = stream.str();
std::cout << decoded << endl;
if (isDebug)
ShowDebug(data, decoded, 0, result);
return 0;
}
int Deals::Negative() { return 0; } int Deals::Negative() { return 0; }
string Deals::GetVal(const string first, const string second) string Deals::GetVal(const string first, const string second)