I'm exploring the InvoiceSearch API and need to pull all the Invoice data. So the plan is to do like kind of "first load" (all the data from the begging till today), after on daily basis just pull new data.
Here is a piece of code I use to pull invoices for one day. What is the minimal day do I need start ? I can start with minimal day and loop adding one day till today. Does that work ? Or there is another way to pull everything ?
Also I will need some description of the JSON result. Does you have any documentation on the JSON result for each API ?
Sabre.Trams.AppServer.Client.WebResponse loginResponse = await session.Login(new System.Net.NetworkCredential(username, password, alias), 1, "").ConfigureAwait(false);
loginResponse.Check();
Console.WriteLine($"Login Successful, Session ID = {session.SessionID}");
InvoiceSearch invoiceSearch = new InvoiceSearch(session);
await invoiceSearch.Search(
new JObject
{
{ InvoiceSearch.Param_IssueDateFrom, new JValue(new DateTime(2020, 1, 1)) },
{ InvoiceSearch.Param_IssueDateTo, new JValue(new DateTime(2020, 1, 2)) },
//{ InvoiceSearch.Param_InvoiceType,
// new JArray(Invoice.InvoiceType_Sale)
//},
//{ InvoiceSearch.Param_InvoiceGroup, "UCLA" },
//{ InvoiceSearch.Param_InvoiceRecNo, 1300000 },
//{ InvoiceSearch.Param_InvoiceNumberFrom, 0 },
//{ InvoiceSearch.Param_InvoiceNumberTo, 2200000 }
/*{
BaseSearchDataset.Param_IncludeCols,
new JArray(InvoiceSearch.Col_Invoice_InvoiceNo)
}*/
}
).ConfigureAwait(false);
Console.WriteLine("Invoice Search Dataset Result Count: " + invoiceSearch.ResultTable.Rows.Count);
Invoice invoice = new Invoice(session);
Payment payment = new Payment(session);
foreach (System.Data.DataRow invoiceSearchRow in invoiceSearch.ResultTable.Rows)
{
var invoiceNo = (long)invoiceSearchRow[InvoiceSearch.Col_Invoice_InvoiceNo];
await invoice.Load(invoiceNo).ConfigureAwait(false);
Console.WriteLine(invoiceNo);
File.WriteAllText(@"c:\temp\invoice_" + invoiceNo + ".txt", JsonConvert.SerializeObject(invoice));