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
(Delphi DLL) Aruba Fatturazione Elettronica getByIdSdiSee more Aruba Fatturazione ExamplesThis method returns the complete status detail of an electronic invoice. Search for a single invoice by SdI identifier. For more information, see https://fatturazioneelettronica.aruba.it/apidoc/docs.html#services-invoice-out-getByIdSdi
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Http, StringBuilder, JsonObject; ... procedure TForm1.Button1Click(Sender: TObject); var http: HCkHttp; success: Boolean; sbResponseBody: HCkStringBuilder; respStatusCode: Integer; json: HCkJsonObject; invoiceDate: PWideChar; number: PWideChar; status: PWideChar; statusDescription: PWideChar; errorCode: PWideChar; errorDescription: PWideChar; id: PWideChar; senderDescription: PWideChar; senderCountryCode: PWideChar; senderVatCode: PWideChar; senderFiscalCode: PWideChar; receiverDescription: PWideChar; receiverCountryCode: PWideChar; receiverVatCode: PWideChar; receiverFiscalCode: PWideChar; invoiceType: PWideChar; docType: PWideChar; file: PWideChar; filename: PWideChar; username: PWideChar; lastUpdate: PWideChar; creationDate: PWideChar; idSdi: PWideChar; pdfFile: PWideChar; pddAvailable: Boolean; i: Integer; count_i: Integer; begin // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http := CkHttp_Create(); // Implements the following CURL command: // curl -X GET https://ws.fatturazioneelettronica.aruba.it/services/invoice/out/getByIdSdi?idSdi=11110&includePdf=true \ // -H "Accept: application/json" \ // -H "Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=" // Use the following online tool to generate HTTP code from a CURL command // Convert a cURL Command to HTTP Source Code // Adds the "Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=" header. CkHttp_putAuthToken(http,'NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE='); CkHttp_SetRequestHeader(http,'Accept','application/json'); sbResponseBody := CkStringBuilder_Create(); success := CkHttp_QuickGetSb(http,'https://ws.fatturazioneelettronica.aruba.it/services/invoice/out/getByIdSdi?idSdi=11110&includePdf=true',sbResponseBody); if (success = False) then begin Memo1.Lines.Add(CkHttp__lastErrorText(http)); Exit; end; respStatusCode := CkHttp_getLastStatus(http); Memo1.Lines.Add('response status code = ' + IntToStr(respStatusCode)); json := CkJsonObject_Create(); CkJsonObject_LoadSb(json,sbResponseBody); CkJsonObject_putEmitCompact(json,True); Memo1.Lines.Add('Response JSON:'); Memo1.Lines.Add(CkJsonObject__emit(json)); if (respStatusCode <> 200) then begin Memo1.Lines.Add('Failed.'); Exit; end; // Sample response: // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON // { // "errorCode" : "0000", // "errorDescription" : null, // "id" : "1", // "sender" : { // "description" : "Aruba SPA", // "countryCode" : "IT", // "vatCode" : "22222222", // "fiscalCode" : "11111111111" // }, // "receiver" : { // "description" : "Aruba SPA", // "countryCode" : "IT", // "vatCode" : "4444444", // "fiscalCode" : "333333333" // }, // "invoiceType" : "FPR12", // "docType" : "in", // "file" : "dGVzdA==", // "filename" : "IT01879020517_jtlk0.xml.p7m", // "invoices" : [ { // "invoiceDate" : "2021-08-24T12:35:45.363+02:00", // "number" : "2021/0001", // "status" : "Inviata", // "statusDescription" : "" // } ], // "username" : "Utente", // "lastUpdate" : "2021-08-24T10:35:45.363+0000", // "creationDate" : "2021-08-24T10:35:45.363+0000", // "idSdi" : "11110", // "pdfFile" : "ZEdWemRGQmtaZz09", // "pddAvailable" : true // } // errorCode := CkJsonObject__stringOf(json,'errorCode'); errorDescription := CkJsonObject__stringOf(json,'errorDescription'); id := CkJsonObject__stringOf(json,'id'); senderDescription := CkJsonObject__stringOf(json,'sender.description'); senderCountryCode := CkJsonObject__stringOf(json,'sender.countryCode'); senderVatCode := CkJsonObject__stringOf(json,'sender.vatCode'); senderFiscalCode := CkJsonObject__stringOf(json,'sender.fiscalCode'); receiverDescription := CkJsonObject__stringOf(json,'receiver.description'); receiverCountryCode := CkJsonObject__stringOf(json,'receiver.countryCode'); receiverVatCode := CkJsonObject__stringOf(json,'receiver.vatCode'); receiverFiscalCode := CkJsonObject__stringOf(json,'receiver.fiscalCode'); invoiceType := CkJsonObject__stringOf(json,'invoiceType'); docType := CkJsonObject__stringOf(json,'docType'); file := CkJsonObject__stringOf(json,'file'); filename := CkJsonObject__stringOf(json,'filename'); username := CkJsonObject__stringOf(json,'username'); lastUpdate := CkJsonObject__stringOf(json,'lastUpdate'); creationDate := CkJsonObject__stringOf(json,'creationDate'); idSdi := CkJsonObject__stringOf(json,'idSdi'); pdfFile := CkJsonObject__stringOf(json,'pdfFile'); pddAvailable := CkJsonObject_BoolOf(json,'pddAvailable'); i := 0; count_i := CkJsonObject_SizeOfArray(json,'invoices'); while i < count_i do begin CkJsonObject_putI(json,i); invoiceDate := CkJsonObject__stringOf(json,'invoices[i].invoiceDate'); number := CkJsonObject__stringOf(json,'invoices[i].number'); status := CkJsonObject__stringOf(json,'invoices[i].status'); statusDescription := CkJsonObject__stringOf(json,'invoices[i].statusDescription'); i := i + 1; end; CkHttp_Dispose(http); CkStringBuilder_Dispose(sbResponseBody); CkJsonObject_Dispose(json); end; |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.