Sample code for 30+ languages & platforms
AutoIt

Aruba Fatturazione Elettronica Find Invoice by Username

See more Aruba Fatturazione Examples

Finds a list of invoices. Returns invoices without content in base64 (lazy loading)

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

;  This example assumes the Chilkat API to have been previously unlocked.
;  See Global Unlock Sample for sample code.

$oHttp = ObjCreate("Chilkat.Http")

;  Implements the following CURL command:

;  curl -X GET https://ws.fatturazioneelettronica.aruba.it/services/invoice/in/findByUsername?username=Username \
;    -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.
$oHttp.AuthToken = "NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE="
$oHttp.SetRequestHeader "Accept","application/json"

$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oHttp.QuickGetSb("https://ws.fatturazioneelettronica.aruba.it/services/invoice/in/findByUsername?username=Username",$oSbResponseBody)
If ($bSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False

ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)

Local $iRespStatusCode = $oHttp.LastStatus
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oHttp.LastHeader & @CRLF)
    ConsoleWrite("Failed." & @CRLF)
    Exit
EndIf

;  Sample JSON response:
;  (Sample code for parsing the JSON response is shown below)

;  {
;    "errorCode": "0000",
;    "errorDescription": null,
;    "content": [
;      {
;        "errorCode": null,
;        "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": null,
;        "filename": "IT01879020517_jtlk0.xml.p7m",
;        "invoices": [
;          {
;            "invoiceDate": "2020-07-10T09:19:56.948+02:00",
;            "number": "2020/0001",
;            "status": "Inviata",
;            "statusDescription": ""
;          }
;        ],
;        "username": "Utente",
;        "lastUpdate": "2020-07-10T07:19:56.948+0000",
;        "creationDate": "2020-07-10T07:19:56.948+0000",
;        "idSdi": "11110",
;        "pddAvailable": true
;      },
;      {
;        "errorCode": null,
;        "errorDescription": null,
;        "id": "2",
;        "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": null,
;        "filename": "IT01879020517_jtlk1.xml.p7m",
;        "invoices": [
;          {
;            "invoiceDate": "2020-07-10T09:19:56.948+02:00",
;            "number": "2020/0002",
;            "status": "Inviata",
;            "statusDescription": ""
;          }
;        ],
;        "username": "Utente",
;        "lastUpdate": "2020-07-10T07:19:56.948+0000",
;        "creationDate": "2020-07-10T07:19:56.948+0000",
;        "idSdi": "11111",
;        "pddAvailable": true
;      },
;      {
;        "errorCode": null,
;        "errorDescription": null,
;        "id": "3",
;        "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": null,
;        "filename": "IT01879020517_jtlk2.xml.p7m",
;        "invoices": [
;          {
;            "invoiceDate": "2020-07-10T09:19:56.948+02:00",
;            "number": "2020/0003",
;            "status": "Inviata",
;            "statusDescription": ""
;          }
;        ],
;        "username": "Utente",
;        "lastUpdate": "2020-07-10T07:19:56.948+0000",
;        "creationDate": "2020-07-10T07:19:56.948+0000",
;        "idSdi": "11112",
;        "pddAvailable": true
;      },
;      {
;        "errorCode": null,
;        "errorDescription": null,
;        "id": "4",
;        "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": null,
;        "filename": "IT01879020517_jtlk3.xml.p7m",
;        "invoices": [
;          {
;            "invoiceDate": "2020-07-10T09:19:56.948+02:00",
;            "number": "2020/0004",
;            "status": "Inviata",
;            "statusDescription": ""
;          }
;        ],
;        "username": "Utente",
;        "lastUpdate": "2020-07-10T07:19:56.948+0000",
;        "creationDate": "2020-07-10T07:19:56.948+0000",
;        "idSdi": "11113",
;        "pddAvailable": true
;      }
;    ],
;    "last": true,
;    "totalElements": 4,
;    "totalPages": 1,
;    "size": 10,
;    "number": 1,
;    "first": true,
;    "numberOfElements": 4
;  }

;  Sample code for parsing the JSON response...
;  Use the following online tool to generate parsing code from sample JSON:
;  Generate Parsing Code from JSON

Local $sId
Local $senderDescription
Local $senderCountryCode
Local $senderVatCode
Local $senderFiscalCode
Local $sReceiverDescription
Local $sReceiverCountryCode
Local $sReceiverVatCode
Local $sReceiverFiscalCode
Local $sInvoiceType
Local $sDocType
Local $sFile
Local $sFilename
Local $sUsername
Local $sLastUpdate
Local $sCreationDate
Local $sIdSdi
Local $bPddAvailable
Local $iJ
Local $iCount_j
Local $sInvoiceDate
Local $sNumber_str
Local $status
Local $statusDescription

Local $sErrorCode = $oJResp.StringOf("errorCode")
Local $sErrorDescription = $oJResp.StringOf("errorDescription")
Local $bLast = $oJResp.BoolOf("last")
Local $iTotalElements = $oJResp.IntOf("totalElements")
Local $iTotalPages = $oJResp.IntOf("totalPages")
Local $iSize = $oJResp.IntOf("size")
Local $iNumber = $oJResp.IntOf("number")
Local $bFirst = $oJResp.BoolOf("first")
Local $iNumberOfElements = $oJResp.IntOf("numberOfElements")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("content")
While $i < $iCount_i
    $oJResp.I = $i
    $sErrorCode = $oJResp.StringOf("content[i].errorCode")
    $sErrorDescription = $oJResp.StringOf("content[i].errorDescription")
    $sId = $oJResp.StringOf("content[i].id")
    $senderDescription = $oJResp.StringOf("content[i].sender.description")
    $senderCountryCode = $oJResp.StringOf("content[i].sender.countryCode")
    $senderVatCode = $oJResp.StringOf("content[i].sender.vatCode")
    $senderFiscalCode = $oJResp.StringOf("content[i].sender.fiscalCode")
    $sReceiverDescription = $oJResp.StringOf("content[i].receiver.description")
    $sReceiverCountryCode = $oJResp.StringOf("content[i].receiver.countryCode")
    $sReceiverVatCode = $oJResp.StringOf("content[i].receiver.vatCode")
    $sReceiverFiscalCode = $oJResp.StringOf("content[i].receiver.fiscalCode")
    $sInvoiceType = $oJResp.StringOf("content[i].invoiceType")
    $sDocType = $oJResp.StringOf("content[i].docType")
    $sFile = $oJResp.StringOf("content[i].file")
    $sFilename = $oJResp.StringOf("content[i].filename")
    $sUsername = $oJResp.StringOf("content[i].username")
    $sLastUpdate = $oJResp.StringOf("content[i].lastUpdate")
    $sCreationDate = $oJResp.StringOf("content[i].creationDate")
    $sIdSdi = $oJResp.StringOf("content[i].idSdi")
    $bPddAvailable = $oJResp.BoolOf("content[i].pddAvailable")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("content[i].invoices")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $sInvoiceDate = $oJResp.StringOf("content[i].invoices[j].invoiceDate")
        $sNumber_str = $oJResp.StringOf("content[i].invoices[j].number")
        $status = $oJResp.StringOf("content[i].invoices[j].status")
        $statusDescription = $oJResp.StringOf("content[i].invoices[j].statusDescription")
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend