Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Xero Get InvoicesGet Xero company invoices. For more information, see https://developer.xero.com/documentation/api/invoices
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp Handle hoJsonToken Boolean iSuccess Variant vResp Handle hoResp Handle hoJsonResponse String sType String sInvoiceID String sInvoiceNumber String sReference String sAmountDue String sAmountPaid String sAmountCredited Boolean iIsDiscounted Boolean iHasAttachments Boolean iHasErrors String sContactContactID String sContactName Boolean iContactHasValidationErrors String sDateString String sDate String sDueDateString String sDueDate String sLineAmountTypes String sSubTotal String sTotalTax String sTotal String sUpdatedDateUTC String sCurrencyCode String sFullyPaidOnDate String sCurrencyRate Integer j Integer iCount_j String sPaymentID String sAmount Boolean iHasAccount Boolean iHasValidationErrors String sCreditNoteID String sCreditNoteNumber String sID String sAppliedAmount Integer k Integer iCount_k String sId String sStatus String sProviderName String sDateTimeUTC Integer i Integer iCount_i String sTemp1 Integer iTemp1 Boolean bTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End Get Create (RefClass(cComChilkatJsonObject)) To hoJsonToken If (Not(IsComObjectCreated(hoJsonToken))) Begin Send CreateComObject of hoJsonToken End Get ComLoadFile Of hoJsonToken "qa_data/tokens/xero-access-token.json" To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoJsonToken To sTemp1 Showln sTemp1 Procedure_Return End Get ComStringOf Of hoJsonToken "access_token" To sTemp1 Set ComAuthToken Of hoHttp To sTemp1 // Replace the value here with an actual tenant ID obtained from this example: // Get Xero Tenant IDs Send ComSetRequestHeader To hoHttp "Xero-tenant-id" "83299b9e-5747-4a14-a18a-a6c94f824eb7" Set ComAccept Of hoHttp To "application/json" Get ComQuickRequest Of hoHttp "GET" "https://api.xero.com/api.xro/2.0/Invoices" To vResp If (IsComObject(vResp)) Begin Get Create (RefClass(cComChilkatHttpResponse)) To hoResp Set pvComObject Of hoResp To vResp End Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Get ComStatusCode Of hoResp To iTemp1 Showln "Response Status Code: " iTemp1 Get Create (RefClass(cComChilkatJsonObject)) To hoJsonResponse If (Not(IsComObjectCreated(hoJsonResponse))) Begin Send CreateComObject of hoJsonResponse End Get ComBodyStr Of hoResp To sTemp1 Get ComLoad Of hoJsonResponse sTemp1 To iSuccess Set ComEmitCompact Of hoJsonResponse To False Get ComEmit Of hoJsonResponse To sTemp1 Showln sTemp1 Get ComStatusCode Of hoResp To iTemp1 If (iTemp1 <> 200) Begin Showln "Failed." Send Destroy of hoResp Procedure_Return End Send Destroy of hoResp // Sample output... // (See the parsing code below..) // // Use the this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON // { // "Id": "bda1f62f-0d63-4178-8d54-e91fd226987a", // "Status": "OK", // "ProviderName": "Chilkat2222", // "DateTimeUTC": "\/Date(1587210234493)\/", // "Invoices": [ // { // "Type": "ACCPAY", // "InvoiceID": "0032f627-3156-4d30-9b1c-4d3b994dc921", // "InvoiceNumber": "9871", // "Reference": "", // "Payments": [ // { // "PaymentID": "22974891-3689-4694-9ee7-fd2ba917af55", // "Date": "\/Date(1579737600000+0000)\/", // "Amount": 148.50, // "Reference": "Chq 409", // "HasAccount": false, // "HasValidationErrors": false // } // ], // "CreditNotes": [ // ], // "Prepayments": [ // ], // "Overpayments": [ // ], // "AmountDue": 0.00, // "AmountPaid": 148.50, // "AmountCredited": 0.00, // "IsDiscounted": false, // "HasAttachments": false, // "HasErrors": false, // "Contact": { // "ContactID": "d6a384fb-f46f-41a3-8ac7-b7bc9e0b5efa", // "Name": "Melrose Parking", // "Addresses": [ // ], // "Phones": [ // ], // "ContactGroups": [ // ], // "ContactPersons": [ // ], // "HasValidationErrors": false // }, // "DateString": "2020-01-15T00:00:00", // "Date": "\/Date(1579046400000+0000)\/", // "DueDateString": "2020-01-24T00:00:00", // "DueDate": "\/Date(1579824000000+0000)\/", // "Status": "PAID", // "LineAmountTypes": "Exclusive", // "LineItems": [ // ], // "SubTotal": 135.00, // "TotalTax": 13.50, // "Total": 148.50, // "UpdatedDateUTC": "\/Date(1221560931500+0000)\/", // "CurrencyCode": "AUD", // "FullyPaidOnDate": "\/Date(1579737600000+0000)\/" // }, // { // "Type": "ACCPAY", // "InvoiceID": "673dd7cc-beb7-4697-83d4-0c47cb400cc2", // "InvoiceNumber": "", // "Reference": "", // "Payments": [ // { // "PaymentID": "4d06f609-5200-4364-9c8b-d4379a945252", // "Date": "\/Date(1580688000000+0000)\/", // "Amount": 974.60, // "Reference": "DD # 96013", // "HasAccount": false, // "HasValidationErrors": false // } // ], // "CreditNotes": [ // { // "CreditNoteID": "7df8949c-b71f-40c0-bbcf-39f2f450f286", // "CreditNoteNumber": "03391", // "ID": "7df8949c-b71f-40c0-bbcf-39f2f450f286", // "HasErrors": false, // "AppliedAmount": 218.90, // "DateString": "2020-01-29T00:00:00", // "Date": "\/Date(1580256000000+0000)\/", // "LineItems": [ // ], // "Total": 218.90 // } // ], // "Prepayments": [ // ], // "Overpayments": [ // ], // "AmountDue": 0.00, // "AmountPaid": 974.60, // "AmountCredited": 218.90, // "IsDiscounted": false, // "HasAttachments": false, // "HasErrors": false, // "Contact": { // "ContactID": "d0cd2c4f-18a0-4f7c-a32a-2db00f29d298", // "Name": "PC Complete", // "Addresses": [ // ], // "Phones": [ // ], // "ContactGroups": [ // ], // "ContactPersons": [ // ], // "HasValidationErrors": false // }, // "DateString": "2020-01-28T00:00:00", // "Date": "\/Date(1580169600000+0000)\/", // "DueDateString": "2020-02-04T00:00:00", // "DueDate": "\/Date(1580774400000+0000)\/", // "Status": "PAID", // "LineAmountTypes": "Exclusive", // "LineItems": [ // ], // "SubTotal": 1085.00, // "TotalTax": 108.50, // "Total": 1193.50, // "UpdatedDateUTC": "\/Date(1221561913790+0000)\/", // "CurrencyCode": "AUD", // "FullyPaidOnDate": "\/Date(1580688000000+0000)\/" // }, // { // "Type": "ACCPAY", // "InvoiceID": "c12aff7e-12bf-4185-8702-460929f19674", // "InvoiceNumber": "", // "Reference": "", // "Payments": [ // ], // "CreditNotes": [ // ], // "Prepayments": [ // ], // "Overpayments": [ // ], // "AmountDue": 2166.99, // "AmountPaid": 0.00, // "AmountCredited": 0.00, // "CurrencyRate": 1.000000, // "IsDiscounted": false, // "HasAttachments": false, // "HasErrors": false, // "Contact": { // "ContactID": "d0cd2c4f-18a0-4f7c-a32a-2db00f29d298", // "Name": "PC Complete", // "Addresses": [ // ], // "Phones": [ // ], // "ContactGroups": [ // ], // "ContactPersons": [ // ], // "HasValidationErrors": false // }, // "DateString": "2020-04-10T00:00:00", // "Date": "\/Date(1586476800000+0000)\/", // "DueDateString": "2020-05-05T00:00:00", // "DueDate": "\/Date(1588636800000+0000)\/", // "Status": "AUTHORISED", // "LineAmountTypes": "Exclusive", // "LineItems": [ // ], // "SubTotal": 1969.99, // "TotalTax": 197.00, // "Total": 2166.99, // "UpdatedDateUTC": "\/Date(1497965301980+0000)\/", // "CurrencyCode": "AUD" // } // ] // } // Get ComStringOf Of hoJsonResponse "Id" To sId Get ComStringOf Of hoJsonResponse "Status" To sStatus Get ComStringOf Of hoJsonResponse "ProviderName" To sProviderName Get ComStringOf Of hoJsonResponse "DateTimeUTC" To sDateTimeUTC Move 0 To i Get ComSizeOfArray Of hoJsonResponse "Invoices" To iCount_i While (i < iCount_i) Set ComI Of hoJsonResponse To i Get ComStringOf Of hoJsonResponse "Invoices[i].Type" To sType Get ComStringOf Of hoJsonResponse "Invoices[i].InvoiceID" To sInvoiceID Get ComStringOf Of hoJsonResponse "Invoices[i].InvoiceNumber" To sInvoiceNumber Get ComStringOf Of hoJsonResponse "Invoices[i].Reference" To sReference Get ComStringOf Of hoJsonResponse "Invoices[i].AmountDue" To sAmountDue Get ComStringOf Of hoJsonResponse "Invoices[i].AmountPaid" To sAmountPaid Get ComStringOf Of hoJsonResponse "Invoices[i].AmountCredited" To sAmountCredited Get ComBoolOf Of hoJsonResponse "Invoices[i].IsDiscounted" To iIsDiscounted Get ComBoolOf Of hoJsonResponse "Invoices[i].HasAttachments" To iHasAttachments Get ComBoolOf Of hoJsonResponse "Invoices[i].HasErrors" To iHasErrors Get ComStringOf Of hoJsonResponse "Invoices[i].Contact.ContactID" To sContactContactID Get ComStringOf Of hoJsonResponse "Invoices[i].Contact.Name" To sContactName Get ComBoolOf Of hoJsonResponse "Invoices[i].Contact.HasValidationErrors" To iContactHasValidationErrors Get ComStringOf Of hoJsonResponse "Invoices[i].DateString" To sDateString Get ComStringOf Of hoJsonResponse "Invoices[i].Date" To sDate Get ComStringOf Of hoJsonResponse "Invoices[i].DueDateString" To sDueDateString Get ComStringOf Of hoJsonResponse "Invoices[i].DueDate" To sDueDate Get ComStringOf Of hoJsonResponse "Invoices[i].Status" To sStatus Get ComStringOf Of hoJsonResponse "Invoices[i].LineAmountTypes" To sLineAmountTypes Get ComStringOf Of hoJsonResponse "Invoices[i].SubTotal" To sSubTotal Get ComStringOf Of hoJsonResponse "Invoices[i].TotalTax" To sTotalTax Get ComStringOf Of hoJsonResponse "Invoices[i].Total" To sTotal Get ComStringOf Of hoJsonResponse "Invoices[i].UpdatedDateUTC" To sUpdatedDateUTC Get ComStringOf Of hoJsonResponse "Invoices[i].CurrencyCode" To sCurrencyCode Get ComStringOf Of hoJsonResponse "Invoices[i].FullyPaidOnDate" To sFullyPaidOnDate Get ComStringOf Of hoJsonResponse "Invoices[i].CurrencyRate" To sCurrencyRate Move 0 To j Get ComSizeOfArray Of hoJsonResponse "Invoices[i].Payments" To iCount_j While (j < iCount_j) Set ComJ Of hoJsonResponse To j Get ComStringOf Of hoJsonResponse "Invoices[i].Payments[j].PaymentID" To sPaymentID Get ComStringOf Of hoJsonResponse "Invoices[i].Payments[j].Date" To sDate Get ComStringOf Of hoJsonResponse "Invoices[i].Payments[j].Amount" To sAmount Get ComStringOf Of hoJsonResponse "Invoices[i].Payments[j].Reference" To sReference Get ComBoolOf Of hoJsonResponse "Invoices[i].Payments[j].HasAccount" To iHasAccount Get ComBoolOf Of hoJsonResponse "Invoices[i].Payments[j].HasValidationErrors" To iHasValidationErrors Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJsonResponse "Invoices[i].CreditNotes" To iCount_j While (j < iCount_j) Set ComJ Of hoJsonResponse To j Get ComStringOf Of hoJsonResponse "Invoices[i].CreditNotes[j].CreditNoteID" To sCreditNoteID Get ComStringOf Of hoJsonResponse "Invoices[i].CreditNotes[j].CreditNoteNumber" To sCreditNoteNumber Get ComStringOf Of hoJsonResponse "Invoices[i].CreditNotes[j].ID" To sID Get ComBoolOf Of hoJsonResponse "Invoices[i].CreditNotes[j].HasErrors" To iHasErrors Get ComStringOf Of hoJsonResponse "Invoices[i].CreditNotes[j].AppliedAmount" To sAppliedAmount Get ComStringOf Of hoJsonResponse "Invoices[i].CreditNotes[j].DateString" To sDateString Get ComStringOf Of hoJsonResponse "Invoices[i].CreditNotes[j].Date" To sDate Get ComStringOf Of hoJsonResponse "Invoices[i].CreditNotes[j].Total" To sTotal Move 0 To k Get ComSizeOfArray Of hoJsonResponse "Invoices[i].CreditNotes[j].LineItems" To iCount_k While (k < iCount_k) Set ComK Of hoJsonResponse To k Move (k + 1) To k Loop Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJsonResponse "Invoices[i].Prepayments" To iCount_j While (j < iCount_j) Set ComJ Of hoJsonResponse To j Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJsonResponse "Invoices[i].Overpayments" To iCount_j While (j < iCount_j) Set ComJ Of hoJsonResponse To j Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJsonResponse "Invoices[i].Contact.Addresses" To iCount_j While (j < iCount_j) Set ComJ Of hoJsonResponse To j Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJsonResponse "Invoices[i].Contact.Phones" To iCount_j While (j < iCount_j) Set ComJ Of hoJsonResponse To j Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJsonResponse "Invoices[i].Contact.ContactGroups" To iCount_j While (j < iCount_j) Set ComJ Of hoJsonResponse To j Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJsonResponse "Invoices[i].Contact.ContactPersons" To iCount_j While (j < iCount_j) Set ComJ Of hoJsonResponse To j Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJsonResponse "Invoices[i].LineItems" To iCount_j While (j < iCount_j) Set ComJ Of hoJsonResponse To j Move (j + 1) To j Loop Move (i + 1) To i Loop End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.