PowerBuilder Fatturazione Elettronica Aruba IT: Find by Username (Sent)

Back to Index

Questo metodo restituisce l’elenco delle fatture elettroniche inviate dall’utente e prese in carico dal sistema. La lista di Fatture ritorna senza il contenuto in base64 (lazy loading)

Documentation: https://fatturazioneelettronica.aruba.it/apidoc/docs.html#_findbyusername

CURL Command

curl -X GET  https://demows.fatturazioneelettronica.aruba.it/services/invoice/out/findByUsername?username=Utente \
-H 'Accept: application/json' \
-H 'Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE='

PowerBuilder Example

integer li_rc
oleobject loo_Rest
integer li_Success
integer li_BTls
integer li_Port
integer li_BAutoReconnect
oleobject loo_SbResponseBody
integer li_RespStatusCode
oleobject loo_JsonResponse
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
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
integer li_IdSdi
integer j
integer li_Count_j
string ls_InvoiceDate
string ls_Number_str
string ls_Status

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

//  URL: https://demows.fatturazioneelettronica.aruba.it/services/invoice/out/findByUsername?username=Utente
li_BTls = 1
li_Port = 443
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("demows.fatturazioneelettronica.aruba.it",li_Port,li_BTls,li_BAutoReconnect)
if li_Success <> 1 then
    Write-Debug "ConnectFailReason: " + string(loo_Rest.ConnectFailReason)
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    return
end if

loo_Rest.AddHeader("Authorization","Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=")
loo_Rest.AddHeader("Accept","application/json")

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

li_Success = loo_Rest.FullRequestNoBodySb("GET","/services/invoice/out/findByUsername?username=Utente",loo_SbResponseBody)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_SbResponseBody
    return
end if

li_RespStatusCode = loo_Rest.ResponseStatusCode
if li_RespStatusCode >= 400 then
    Write-Debug "Response Status Code = " + string(li_RespStatusCode)
    Write-Debug "Response Header:"
    Write-Debug loo_Rest.ResponseHeader
    Write-Debug "Response Body:"
    Write-Debug loo_SbResponseBody.GetAsString()
    destroy loo_Rest
    destroy loo_SbResponseBody
    return
end if

loo_JsonResponse = create oleobject
li_rc = loo_JsonResponse.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JsonResponse.LoadSb(loo_SbResponseBody)

//  See the Online Tool for Generating JSON Parse Code

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


destroy loo_Rest
destroy loo_SbResponseBody
destroy loo_JsonResponse

Sample JSON Response Body

{
  "content": [
    {
      "id": "1",
      "sender": {
        "description": "Aruba SPA",
        "countryCode": "ITA",
        "vatCode": "6372762541",
        "fiscalCode": "N5Hnt9vvMZ"
      },
      "receiver": {
        "description": "Rossi SRL",
        "countryCode": "ITA",
        "vatCode": "8767263441",
        "fiscalCode": "LVZTeOJ8BN"
      },
      "invoiceType": "FPA12",
      "docType": "in",
      "file": null,
      "filename": "IT07026037883_jtlkl.xml.p7m",
      "invoices": [
        {
          "invoiceDate": "2019-01-21T17:36:20.835+01:00",
          "number": "1",
          "status": "Inviata"
        }
      ],
      "username": "Utente",
      "lastUpdate": "2019-01-21T17:36:20.835+01:00",
      "idSdi": 7895
    },
    {
      "id": "2",
      "sender": {
        "description": "Aruba SPA",
        "countryCode": "fKo",
        "vatCode": "0845927294",
        "fiscalCode": "1dzZUPwfhO"
      },
      "receiver": {
        "description": "Rossi SRL",
        "countryCode": "WGf",
        "vatCode": "7188186772",
        "fiscalCode": "p46bxpoQgx"
      },
      "invoiceType": "FPA12",
      "docType": "in",
      "file": null,
      "filename": "IT00499202641_kwefc.xml.p7m",
      "invoices": [
        {
          "invoiceDate": "2019-01-21T17:36:20.835+01:00",
          "number": "1",
          "status": "Inviata"
        }
      ],
      "username": "Utente",
      "lastUpdate": "2019-01-21T17:36:20.835+01:00",
      "idSdi": 7895
    },
    {
      "id": "3",
      "sender": {
        "description": "Aruba SPA",
        "countryCode": "IT",
        "vatCode": "56215678997",
        "fiscalCode": "94170917594"
      },
      "receiver": {
        "description": "Rossi SRL",
        "countryCode": "IT",
        "vatCode": "27446044667",
        "fiscalCode": "13591589640"
      },
      "invoiceType": "FPA12",
      "docType": "in",
      "file": null,
      "filename": "IT01787589930_bkemy.xml.p7m",
      "invoices": [
        {
          "invoiceDate": "2019-01-21T17:36:20.835+01:00",
          "number": "1",
          "status": "Inviata"
        }
      ],
      "username": "Utente",
      "lastUpdate": "2019-01-21T17:36:20.835+01:00",
      "idSdi": 7895
    },
    {
      "id": "4",
      "sender": {
        "description": "Aruba SPA",
        "countryCode": "IT",
        "vatCode": "51878525587",
        "fiscalCode": "37556497667"
      },
      "receiver": {
        "description": "Rossi SRL",
        "countryCode": "IT",
        "vatCode": "95708696901",
        "fiscalCode": "69989572913"
      },
      "invoiceType": "FPA12",
      "docType": "in",
      "file": null,
      "filename": "IT06620176401_pdrjw.xml.p7m",
      "invoices": [
        {
          "invoiceDate": "2019-01-21T17:36:20.835+01:00",
          "number": "1",
          "status": "Inviata"
        }
      ],
      "username": "Utente",
      "lastUpdate": "2019-01-21T17:36:20.835+01:00",
      "idSdi": 7895
    }
  ],
  "last": true,
  "totalElements": 4,
  "totalPages": 1,
  "size": 10,
  "number": 0,
  "first": true,
  "numberOfElements": 4
}