Unicode C
Unicode C
Aruba Fatturazione Elettronica getByIdSdi
See more Aruba Fatturazione Examples
This method returns the complete status detail of an electronic invoice. Search for a single invoice by SdI identifier.Chilkat Unicode C Downloads
#include <C_CkHttpW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttpW http;
HCkStringBuilderW sbResponseBody;
int respStatusCode;
HCkJsonObjectW json;
const wchar_t *invoiceDate;
const wchar_t *number;
const wchar_t *status;
const wchar_t *statusDescription;
const wchar_t *errorCode;
const wchar_t *errorDescription;
const wchar_t *id;
const wchar_t *senderDescription;
const wchar_t *senderCountryCode;
const wchar_t *senderVatCode;
const wchar_t *senderFiscalCode;
const wchar_t *receiverDescription;
const wchar_t *receiverCountryCode;
const wchar_t *receiverVatCode;
const wchar_t *receiverFiscalCode;
const wchar_t *invoiceType;
const wchar_t *docType;
const wchar_t *file;
const wchar_t *filename;
const wchar_t *username;
const wchar_t *lastUpdate;
const wchar_t *creationDate;
const wchar_t *idSdi;
const wchar_t *pdfFile;
BOOL pddAvailable;
int i;
int count_i;
success = FALSE;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_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.
CkHttpW_putAuthToken(http,L"NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=");
CkHttpW_SetRequestHeader(http,L"Accept",L"application/json");
sbResponseBody = CkStringBuilderW_Create();
success = CkHttpW_QuickGetSb(http,L"https://ws.fatturazioneelettronica.aruba.it/services/invoice/out/getByIdSdi?idSdi=11110&includePdf=true",sbResponseBody);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
respStatusCode = CkHttpW_getLastStatus(http);
wprintf(L"response status code = %d\n",respStatusCode);
json = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(json,sbResponseBody);
CkJsonObjectW_putEmitCompact(json,TRUE);
wprintf(L"Response JSON:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(json));
if (respStatusCode != 200) {
wprintf(L"Failed.\n");
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(json);
return;
}
// 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
// }
//
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
// See this example explaining how this memory should be used: const char * functions.
errorCode = CkJsonObjectW_stringOf(json,L"errorCode");
errorDescription = CkJsonObjectW_stringOf(json,L"errorDescription");
id = CkJsonObjectW_stringOf(json,L"id");
senderDescription = CkJsonObjectW_stringOf(json,L"sender.description");
senderCountryCode = CkJsonObjectW_stringOf(json,L"sender.countryCode");
senderVatCode = CkJsonObjectW_stringOf(json,L"sender.vatCode");
senderFiscalCode = CkJsonObjectW_stringOf(json,L"sender.fiscalCode");
receiverDescription = CkJsonObjectW_stringOf(json,L"receiver.description");
receiverCountryCode = CkJsonObjectW_stringOf(json,L"receiver.countryCode");
receiverVatCode = CkJsonObjectW_stringOf(json,L"receiver.vatCode");
receiverFiscalCode = CkJsonObjectW_stringOf(json,L"receiver.fiscalCode");
invoiceType = CkJsonObjectW_stringOf(json,L"invoiceType");
docType = CkJsonObjectW_stringOf(json,L"docType");
file = CkJsonObjectW_stringOf(json,L"file");
filename = CkJsonObjectW_stringOf(json,L"filename");
username = CkJsonObjectW_stringOf(json,L"username");
lastUpdate = CkJsonObjectW_stringOf(json,L"lastUpdate");
creationDate = CkJsonObjectW_stringOf(json,L"creationDate");
idSdi = CkJsonObjectW_stringOf(json,L"idSdi");
pdfFile = CkJsonObjectW_stringOf(json,L"pdfFile");
pddAvailable = CkJsonObjectW_BoolOf(json,L"pddAvailable");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(json,L"invoices");
while (i < count_i) {
CkJsonObjectW_putI(json,i);
invoiceDate = CkJsonObjectW_stringOf(json,L"invoices[i].invoiceDate");
number = CkJsonObjectW_stringOf(json,L"invoices[i].number");
status = CkJsonObjectW_stringOf(json,L"invoices[i].status");
statusDescription = CkJsonObjectW_stringOf(json,L"invoices[i].statusDescription");
i = i + 1;
}
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(json);
}