InvoiceSearch

65 views
Skip to first unread message

gda.d...@gmail.com

unread,
Oct 9, 2020, 11:04:21 AM10/9/20
to Trams API
Hi Dan, 

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));

Thanks
Dima

Jeremiah Sellars

unread,
Oct 9, 2020, 11:21:54 AM10/9/20
to Trams API
Good morning Dima,

Can you please email me directly, jeremiah...@sabre.com, and include which agency you're doing this API work for? The API is in general release and we are no longer using the beta forum for support, but leaving it active as a resource for sample code.

Thank you,
Jeremiah

Reply all
Reply to author
Forward
0 new messages