Sample code for 30+ languages & platforms
Dart

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 Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  // This example assumes the Chilkat API to have been previously unlocked.
  // See Global Unlock Sample for sample code.

  final http = CkHttp();

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

  final sbResponseBody = CkStringBuilder();
  try {
    http.quickGetSb('https://ws.fatturazioneelettronica.aruba.it/services/invoice/out/getByIdSdi?idSdi=11110&includePdf=true', sbResponseBody);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  final respStatusCode = http.lastStatus;
  print('response status code = $respStatusCode');

  final json = CkJsonObject();
  json.loadSb(sbResponseBody);
  json.emitCompact = true;

  print('Response JSON:');
  print(json.emit());

  if (respStatusCode != 200) {
    print('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
  // }
  // 

  var invoiceDate = '';
  var number = '';
  var status = '';
  var statusDescription = '';

  final errorCode = json.stringOf('errorCode');
  final errorDescription = json.stringOf('errorDescription');
  final id = json.stringOf('id');
  final senderDescription = json.stringOf('sender.description');
  final senderCountryCode = json.stringOf('sender.countryCode');
  final senderVatCode = json.stringOf('sender.vatCode');
  final senderFiscalCode = json.stringOf('sender.fiscalCode');
  final receiverDescription = json.stringOf('receiver.description');
  final receiverCountryCode = json.stringOf('receiver.countryCode');
  final receiverVatCode = json.stringOf('receiver.vatCode');
  final receiverFiscalCode = json.stringOf('receiver.fiscalCode');
  final invoiceType = json.stringOf('invoiceType');
  final docType = json.stringOf('docType');
  final file = json.stringOf('file');
  final filename = json.stringOf('filename');
  final username = json.stringOf('username');
  final lastUpdate = json.stringOf('lastUpdate');
  final creationDate = json.stringOf('creationDate');
  final idSdi = json.stringOf('idSdi');
  final pdfFile = json.stringOf('pdfFile');
  var i = 0;
  final countI = json.sizeOfArray('invoices');
  while (i < countI) {
    json.i = i;
    invoiceDate = json.stringOf('invoices[i].invoiceDate');
    number = json.stringOf('invoices[i].number');
    status = json.stringOf('invoices[i].status');
    statusDescription = json.stringOf('invoices[i].statusDescription');
    i++;
  }
}