Sample code for 30+ languages & platforms
PowerBuilder

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

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Id
string ls_SenderDescription
string ls_SenderCountryCode
string ls_SenderVatCode
string ls_SenderFiscalCode
string ls_ReceiverDescription
string ls_ReceiverCountryCode
string ls_ReceiverVatCode
string ls_ReceiverFiscalCode
string ls_InvoiceType
string ls_DocType
string ls_File
string ls_Filename
string ls_Username
string ls_LastUpdate
string ls_CreationDate
string ls_IdSdi
integer li_PddAvailable
integer j
integer li_Count_j
string ls_InvoiceDate
string ls_Number_str
string ls_Status
string ls_StatusDescription
string ls_ErrorCode
string ls_ErrorDescription
integer li_Last
integer li_TotalElements
integer li_TotalPages
integer li_Size
integer li_Number
integer li_First
integer li_NumberOfElements
integer i
integer li_Count_i

li_Success = 0

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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// 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.
loo_Http.AuthToken = "NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE="
loo_Http.SetRequestHeader("Accept","application/json")

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

li_Success = loo_Http.QuickGetSb("https://ws.fatturazioneelettronica.aruba.it/services/invoice/in/findByUsername?username=Username",loo_SbResponseBody)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Http.LastHeader
    Write-Debug "Failed."
    destroy loo_Http
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

// 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

ls_ErrorCode = loo_JResp.StringOf("errorCode")
ls_ErrorDescription = loo_JResp.StringOf("errorDescription")
li_Last = loo_JResp.BoolOf("last")
li_TotalElements = loo_JResp.IntOf("totalElements")
li_TotalPages = loo_JResp.IntOf("totalPages")
li_Size = loo_JResp.IntOf("size")
li_Number = loo_JResp.IntOf("number")
li_First = loo_JResp.BoolOf("first")
li_NumberOfElements = loo_JResp.IntOf("numberOfElements")
i = 0
li_Count_i = loo_JResp.SizeOfArray("content")
do while i < li_Count_i
    loo_JResp.I = i
    ls_ErrorCode = loo_JResp.StringOf("content[i].errorCode")
    ls_ErrorDescription = loo_JResp.StringOf("content[i].errorDescription")
    ls_Id = loo_JResp.StringOf("content[i].id")
    ls_SenderDescription = loo_JResp.StringOf("content[i].sender.description")
    ls_SenderCountryCode = loo_JResp.StringOf("content[i].sender.countryCode")
    ls_SenderVatCode = loo_JResp.StringOf("content[i].sender.vatCode")
    ls_SenderFiscalCode = loo_JResp.StringOf("content[i].sender.fiscalCode")
    ls_ReceiverDescription = loo_JResp.StringOf("content[i].receiver.description")
    ls_ReceiverCountryCode = loo_JResp.StringOf("content[i].receiver.countryCode")
    ls_ReceiverVatCode = loo_JResp.StringOf("content[i].receiver.vatCode")
    ls_ReceiverFiscalCode = loo_JResp.StringOf("content[i].receiver.fiscalCode")
    ls_InvoiceType = loo_JResp.StringOf("content[i].invoiceType")
    ls_DocType = loo_JResp.StringOf("content[i].docType")
    ls_File = loo_JResp.StringOf("content[i].file")
    ls_Filename = loo_JResp.StringOf("content[i].filename")
    ls_Username = loo_JResp.StringOf("content[i].username")
    ls_LastUpdate = loo_JResp.StringOf("content[i].lastUpdate")
    ls_CreationDate = loo_JResp.StringOf("content[i].creationDate")
    ls_IdSdi = loo_JResp.StringOf("content[i].idSdi")
    li_PddAvailable = loo_JResp.BoolOf("content[i].pddAvailable")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("content[i].invoices")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_InvoiceDate = loo_JResp.StringOf("content[i].invoices[j].invoiceDate")
        ls_Number_str = loo_JResp.StringOf("content[i].invoices[j].number")
        ls_Status = loo_JResp.StringOf("content[i].invoices[j].status")
        ls_StatusDescription = loo_JResp.StringOf("content[i].invoices[j].statusDescription")
        j = j + 1
    loop
    i = i + 1
loop


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp