public AsmoneyAPIError GetTransaction(int TransActionID, out TransAction details) { TransAction o = new TransAction(); details = o; string str = m_client.InvokeVargs("gettransaction", m_username, m_apiname, m_password, TransActionID).ToString(); if (str == "Invalid user") { return(AsmoneyAPIError.AME_InvalidUser); } if (str == "Invalid api data") { return(AsmoneyAPIError.AME_InvalidAPIData); } if (str == "Invalid IP") { return(AsmoneyAPIError.AME_InvalidIP); } if (str == "Invalid IP setup") { return(AsmoneyAPIError.AME_InvalidIPSetup); } if (str == "Invalid") { return(AsmoneyAPIError.AME_Invalid); } JsonObject b = (JsonObject)JsonConvert.Import(str); ReadTransaction(b, ref o); details = o; return(AsmoneyAPIError.AME_OK); } // GetTransaction
void ReadTransaction(JsonObject b, ref TransAction o) { o.value = Convert.ToDouble(b["value"]); o.batchno = Convert.ToInt32(b["batchno"]); o.cur = b["cur"].ToString(); //2014-05-23T16:05:00.0000000-0,:00 string date = b["logtime"].ToString(); int year = Convert.ToInt32(date.Substring(0, 4)); int mon = Convert.ToInt32(date.Substring(5, 2)); int day = Convert.ToInt32(date.Substring(8, 2)); int h = Convert.ToInt32(date.Substring(11, 2)); int m = Convert.ToInt32(date.Substring(14, 2)); int s = Convert.ToInt32(date.Substring(17, 2)); o.logtime = new DateTime(year, mon, day, h, m, s); o.payer = b["payer"].ToString(); o.action = b["action"].ToString(); o.fee = Convert.ToDouble(b["fee"]); }
} // GetHistory public AsmoneyAPIError GetNewTransActions(ref List <TransAction> transactions) { transactions.Clear(); string str = m_client.InvokeVargs("getnewtransactions", m_username, m_apiname, m_password).ToString(); if (str == "Invalid user") { return(AsmoneyAPIError.AME_InvalidUser); } if (str == "Invalid api data") { return(AsmoneyAPIError.AME_InvalidAPIData); } if (str == "Invalid IP") { return(AsmoneyAPIError.AME_InvalidIP); } if (str == "Invalid IP setup") { return(AsmoneyAPIError.AME_InvalidIPSetup); } if (str == "Updated") { return(AsmoneyAPIError.AME_OK); } if (str == "0") { return(AsmoneyAPIError.AME_OK); } JsonArray a = (JsonArray)JsonConvert.Import(str); foreach (JsonObject b in a) { TransAction o = new TransAction(); ReadTransaction(b, ref o); transactions.Add(o); } return(AsmoneyAPIError.AME_OK); } // GetNewTransActions