Visual FoxPro Fatturazione Elettronica Aruba IT: Get by Invoice ID (Sent)

Back to Index

Ricerca una singola fattura per Id

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

CURL Command

curl -X GET  https://demows.fatturazioneelettronica.aruba.it/services/invoice/out/{invoiceId} \
-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 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 lcIdSdi
LOCAL i
LOCAL lnCount_i
LOCAL lcInvoiceDate
LOCAL lcNumber
LOCAL lcStatus

loRest = CreateObject('Chilkat_9_5_0.Rest')

*  URL: https://demows.fatturazioneelettronica.aruba.it/services/invoice/out/{invoiceId}
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/{invoiceId}",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

lcId = loJsonResponse.StringOf("id")
lcSenderDescription = loJsonResponse.StringOf("sender.description")
lcSenderCountryCode = loJsonResponse.StringOf("sender.countryCode")
lcSenderVatCode = loJsonResponse.StringOf("sender.vatCode")
lcSenderFiscalCode = loJsonResponse.StringOf("sender.fiscalCode")
lcReceiverDescription = loJsonResponse.StringOf("receiver.description")
lcReceiverCountryCode = loJsonResponse.StringOf("receiver.countryCode")
lcReceiverVatCode = loJsonResponse.StringOf("receiver.vatCode")
lcReceiverFiscalCode = loJsonResponse.StringOf("receiver.fiscalCode")
lcInvoiceType = loJsonResponse.StringOf("invoiceType")
lcDocType = loJsonResponse.StringOf("docType")
lcFile = loJsonResponse.StringOf("file")
lcFilename = loJsonResponse.StringOf("filename")
lcUsername = loJsonResponse.StringOf("username")
lcLastUpdate = loJsonResponse.StringOf("lastUpdate")
lcIdSdi = loJsonResponse.StringOf("idSdi")
i = 0
lnCount_i = loJsonResponse.SizeOfArray("invoices")
DO WHILE i < lnCount_i
    loJsonResponse.I = i
    lcInvoiceDate = loJsonResponse.StringOf("invoices[i].invoiceDate")
    lcNumber = loJsonResponse.StringOf("invoices[i].number")
    lcStatus = loJsonResponse.StringOf("invoices[i].status")
    i = i + 1
ENDDO

RELEASE loRest
RELEASE loSbResponseBody
RELEASE loJsonResponse

Sample JSON Response Body

{
  "id": "1",
  "sender": {
    "description": "Aruba SPA",
    "countryCode": "ITA",
    "vatCode": "6372762541",
    "fiscalCode": "N5Hnt9vvMZ"
  },
  "receiver": {
    "description": "Aruba SPA",
    "countryCode": "ITA",
    "vatCode": "8767263441",
    "fiscalCode": "LVZTeOJ8BN"
  },
  "invoiceType": "FPA12",
  "docType": "in",
  "file": "ZEdWemRBPT0=",
  "filename": "IT07026037883_jtlkl.xml.p7m",
  "invoices": [
    {
      "invoiceDate": "2019-01-21T17:36:21.289+01:00",
      "number": "1",
      "status": "Inviata"
    },
    {
      "invoiceDate": "2019-01-21T17:36:21.289+01:00",
      "number": "2",
      "status": "Consegnata"
    }
  ],
  "username": "Utente",
  "lastUpdate": "2019-01-21T17:36:21.289+01:00",
  "idSdi": null
}