Genericized QB response.
This commit is contained in:
@@ -18,15 +18,15 @@ namespace BodyshopPartner.Utils
|
|||||||
private static HttpLogger hlog;
|
private static HttpLogger hlog;
|
||||||
public static void InitHttpServer(HttpLogger HttpLogger)
|
public static void InitHttpServer(HttpLogger HttpLogger)
|
||||||
{
|
{
|
||||||
Route.Add("/qb/receivables", (req, res, props) =>
|
Route.Add("/qb/", (req, res, props) =>
|
||||||
{
|
{
|
||||||
res.WithCORS();
|
res.WithCORS();
|
||||||
//res.AddHeader("Access-Control-Allow-Origin", "http://localhost:3000 https://localhost:3000 http://localhost:5000 https://localhost:5000 https://*.imex.online,imex.online");
|
//res.AddHeader("Access-Control-Allow-Origin", "http://localhost:3000 https://localhost:3000 http://localhost:5000 https://localhost:5000 https://*.imex.online,imex.online");
|
||||||
res.Close();
|
res.Close();
|
||||||
}, "OPTIONS");
|
}, "OPTIONS");
|
||||||
|
|
||||||
Route.Add("/qb/receivables",
|
Route.Add("/qb/",
|
||||||
(req, res, props) => { HandleQbReceivables(req, res); }
|
(req, res, props) => { HandleQbPost(req, res); }
|
||||||
, "POST");
|
, "POST");
|
||||||
|
|
||||||
logger.Trace("Starting HTTP server...");
|
logger.Trace("Starting HTTP server...");
|
||||||
@@ -36,9 +36,9 @@ namespace BodyshopPartner.Utils
|
|||||||
HttpServer.ListenAsync(1337, System.Threading.CancellationToken.None, Route.OnHttpRequestAsync).Wait();
|
HttpServer.ListenAsync(1337, System.Threading.CancellationToken.None, Route.OnHttpRequestAsync).Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void HandleQbReceivables(System.Net.HttpListenerRequest req, System.Net.HttpListenerResponse res)
|
private static void HandleQbPost(System.Net.HttpListenerRequest req, System.Net.HttpListenerResponse res)
|
||||||
{
|
{
|
||||||
logger.Debug("/qb/receivables - POST");
|
logger.Debug("/qb/ - POST");
|
||||||
//Input will be an array of XMLs.
|
//Input will be an array of XMLs.
|
||||||
|
|
||||||
string[] requestXMLstrings = ParseBodyToArray(req);
|
string[] requestXMLstrings = ParseBodyToArray(req);
|
||||||
@@ -50,20 +50,13 @@ namespace BodyshopPartner.Utils
|
|||||||
XDocument requestXMLdoc = ParseStringToXml(requestXMLstring);
|
XDocument requestXMLdoc = ParseStringToXml(requestXMLstring);
|
||||||
XDocument response = XDocument.Parse(QuickBooksInterop.ProcessQBXmlRequest(requestXMLstring));
|
XDocument response = XDocument.Parse(QuickBooksInterop.ProcessQBXmlRequest(requestXMLstring));
|
||||||
Models.QbXmlResponse ResponseStatus = QuickBooksInterop.ParseResponseXml(response);
|
Models.QbXmlResponse ResponseStatus = QuickBooksInterop.ParseResponseXml(response);
|
||||||
|
logger.Info(response.ToString());
|
||||||
|
|
||||||
logger.Info(response.ToString());
|
|
||||||
logger.Info(ResponseStatus.ToString());
|
logger.Info(ResponseStatus.ToString());
|
||||||
hlog(ResponseStatus.ToString());
|
hlog(ResponseStatus.ToString());
|
||||||
//string[] status = new string[3];
|
|
||||||
//if (InvoiceAddResponse != null) status = QuickBooksInterop.parseInvoiceAddRs(InvoiceAddResponse);
|
|
||||||
//if (InvoiceAddResponse != null && status[0] == "0")
|
|
||||||
//{ logger.Debug("Invoice added successfully."); res.StatusCode = 200; }
|
|
||||||
//else
|
|
||||||
//{ logger.Error("Error adding Invoice.\nStatus Code: {0} \nSeverity: {1} \nMessage {2}", status[0], status[1], status[2]); res.StatusCode = 400; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
hlog("Completed QuickBooks Receivable request.");
|
|
||||||
|
hlog("Completed QuickBooks request.");
|
||||||
res.WithCORS().Close();
|
res.WithCORS().Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user