Visual FoxPro 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='

Visual FoxPro Example

LOCAL loRest
LOCAL lnSuccess
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJsonResponse
LOCAL lnLast
LOCAL lnTotalElements
LOCAL lnTotalPages
LOCAL lnSize
LOCAL lnNumber
LOCAL lnFirst
LOCAL lnNumberOfElements
LOCAL i
LOCAL lnCount_i
LOCAL lcId
LOCAL lcSenderDescription
LOCAL lcSenderCountryCode
LOCAL lcSenderVatCode
LOCAL lcSenderFiscalCode
LOCAL lcReceiverDescription
LOCAL lcReceiverCountryCode
LOCAL lcReceiverVatCode
LOCAL lcReceiverFiscalCode
LOCAL lcInvoiceType
LOCAL lcDocType
LOCAL lcFile
LOCAL lcFilename
LOCAL lcUsername
LOCAL lcLastUpdate
LOCAL lnIdSdi
LOCAL j
LOCAL lnCount_j
LOCAL lcInvoiceDate
LOCAL lcNumber_str
LOCAL lcStatus

loRest = CreateObject('Chilkat_9_5_0.Rest')

*  URL: https://demows.fatturazioneelettronica.aruba.it/services/invoice/out/findByUsername?username=Utente
lnBTls = 1
lnPort = 443
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("demows.fatturazioneelettronica.aruba.it",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1) THEN
    ? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
    ? loRest.LastErrorText
    RELEASE loRest
    CANCEL
ENDIF

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

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("GET","/services/invoice/out/findByUsername?username=Utente",loSbResponseBody)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loSbResponseBody
    CANCEL
ENDIF

lnRespStatusCode = loRest.ResponseStatusCode
IF (lnRespStatusCode >= 400) THEN
    ? "Response Status Code = " + STR(lnRespStatusCode)
    ? "Response Header:"
    ? loRest.ResponseHeader
    ? "Response Body:"
    ? loSbResponseBody.GetAsString()
    RELEASE loRest
    RELEASE loSbResponseBody
    CANCEL
ENDIF

loJsonResponse = CreateObject('Chilkat_9_5_0.JsonObject')
loJsonResponse.LoadSb(loSbResponseBody)

*  See the Online Tool for Generating JSON Parse Code

lnLast = loJsonResponse.BoolOf("last")
lnTotalElements = loJsonResponse.IntOf("totalElements")
lnTotalPages = loJsonResponse.IntOf("totalPages")
lnSize = loJsonResponse.IntOf("size")
lnNumber = loJsonResponse.IntOf("number")
lnFirst = loJsonResponse.BoolOf("first")
lnNumberOfElements = loJsonResponse.IntOf("numberOfElements")
i = 0
lnCount_i = loJsonResponse.SizeOfArray("content")
DO WHILE i < lnCount_i
    loJsonResponse.I = i
    lcId = loJsonResponse.StringOf("content[i].id")
    lcSenderDescription = loJsonResponse.StringOf("content[i].sender.description")
    lcSenderCountryCode = loJsonResponse.StringOf("content[i].sender.countryCode")
    lcSenderVatCode = loJsonResponse.StringOf("content[i].sender.vatCode")
    lcSenderFiscalCode = loJsonResponse.StringOf("content[i].sender.fiscalCode")
    lcReceiverDescription = loJsonResponse.StringOf("content[i].receiver.description")
    lcReceiverCountryCode = loJsonResponse.StringOf("content[i].receiver.countryCode")
    lcReceiverVatCode = loJsonResponse.StringOf("content[i].receiver.vatCode")
    lcReceiverFiscalCode = loJsonResponse.StringOf("content[i].receiver.fiscalCode")
    lcInvoiceType = loJsonResponse.StringOf("content[i].invoiceType")
    lcDocType = loJsonResponse.StringOf("content[i].docType")
    lcFile = loJsonResponse.StringOf("content[i].file")
    lcFilename = loJsonResponse.StringOf("content[i].filename")
    lcUsername = loJsonResponse.StringOf("content[i].username")
    lcLastUpdate = loJsonResponse.StringOf("content[i].lastUpdate")
    lnIdSdi = loJsonResponse.IntOf("content[i].idSdi")
    j = 0
    lnCount_j = loJsonResponse.SizeOfArray("content[i].invoices")
    DO WHILE j < lnCount_j
        loJsonResponse.J = j
        lcInvoiceDate = loJsonResponse.StringOf("content[i].invoices[j].invoiceDate")
        lcNumber_str = loJsonResponse.StringOf("content[i].invoices[j].number")
        lcStatus = loJsonResponse.StringOf("content[i].invoices[j].status")
        j = j + 1
    ENDDO
    i = i + 1
ENDDO

RELEASE loRest
RELEASE loSbResponseBody
RELEASE loJsonResponse

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
}