mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-18 14:16:12 -06:00
41 lines
780 B
C++
41 lines
780 B
C++
#include <XmlRpc/XmlRpc.h>
|
|
|
|
using namespace Upp;
|
|
|
|
struct FoxResult {
|
|
bool flerror;
|
|
double amount;
|
|
String message;
|
|
|
|
void Map(ValueMapper& m) {
|
|
m("flerror", flerror)("amount", amount)("message", message);
|
|
}
|
|
};
|
|
|
|
XMLRPC_STRUCT(FoxResult)
|
|
|
|
CONSOLE_APP_MAIN
|
|
{
|
|
StdLogSetup(LOG_COUT|LOG_FILE);
|
|
XmlRpcRequest xr("http://foxrate.org/rpc");
|
|
xr.Method("foxrate.currencyConvert") << "USD" << "GBP" << 120;
|
|
Value v = xr.Execute();
|
|
if(v.IsError())
|
|
LOG("Error: " << v);
|
|
else
|
|
if(v["flerror"] == 0)
|
|
LOG(v["amount"]);
|
|
else
|
|
LOG("Failed.");
|
|
|
|
FoxResult r;
|
|
if(XmlRpcRequest("http://foxrate.org/rpc").Method("foxrate.currencyConvert")
|
|
<< "USD" << "GBP" << 120
|
|
>> r)
|
|
if(r.flerror)
|
|
LOG("Server reported erro");
|
|
else
|
|
LOG(r.amount);
|
|
else
|
|
LOG("Failed.");
|
|
}
|