React Native
React Native
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 React Native Downloads
import { Http, JsonObject, StringBuilder } from '@chilkat/react-native'
async function chilkatExample() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const http = new Http();
// 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.
http.authToken = 'NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=';
http.setRequestHeader('Accept', 'application/json');
const sbResponseBody = new StringBuilder();
try {
await http.quickGetSbAsync('https://ws.fatturazioneelettronica.aruba.it/services/invoice/out/getByIdSdi?idSdi=11110&includePdf=true', sbResponseBody);
} catch {
console.log(http.lastErrorText);
return;
}
const respStatusCode = http.lastStatus;
console.log(`response status code = ${respStatusCode}`);
const json = new JsonObject();
json.loadSb(sbResponseBody);
json.emitCompact = true;
console.log('Response JSON:');
console.log(json.emit());
if (respStatusCode !== 200) {
console.log('Failed.');
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
// }
//
let invoiceDate = '';
let numberArg = '';
let status = '';
let statusDescription = '';
const errorCode = json.stringOf('errorCode');
const errorDescription = json.stringOf('errorDescription');
const id = json.stringOf('id');
const senderDescription = json.stringOf('sender.description');
const senderCountryCode = json.stringOf('sender.countryCode');
const senderVatCode = json.stringOf('sender.vatCode');
const senderFiscalCode = json.stringOf('sender.fiscalCode');
const receiverDescription = json.stringOf('receiver.description');
const receiverCountryCode = json.stringOf('receiver.countryCode');
const receiverVatCode = json.stringOf('receiver.vatCode');
const receiverFiscalCode = json.stringOf('receiver.fiscalCode');
const invoiceType = json.stringOf('invoiceType');
const docType = json.stringOf('docType');
const file = json.stringOf('file');
const filename = json.stringOf('filename');
const username = json.stringOf('username');
const lastUpdate = json.stringOf('lastUpdate');
const creationDate = json.stringOf('creationDate');
const idSdi = json.stringOf('idSdi');
const pdfFile = json.stringOf('pdfFile');
let i = 0;
const countI = json.sizeOfArray('invoices');
while (i < countI) {
json.i = i;
invoiceDate = json.stringOf('invoices[i].invoiceDate');
numberArg = json.stringOf('invoices[i].number');
status = json.stringOf('invoices[i].status');
statusDescription = json.stringOf('invoices[i].statusDescription');
i++;
}
}