Xbase++
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL oHttp
LOCAL oSbResponseBody
LOCAL oJResp
LOCAL nRespStatusCode
LOCAL cId
LOCAL cSenderDescription
LOCAL cSenderCountryCode
LOCAL cSenderVatCode
LOCAL cSenderFiscalCode
LOCAL cReceiverDescription
LOCAL cReceiverCountryCode
LOCAL cReceiverVatCode
LOCAL cReceiverFiscalCode
LOCAL cInvoiceType
LOCAL cDocType
LOCAL cFile
LOCAL cFilename
LOCAL cUsername
LOCAL cLastUpdate
LOCAL cCreationDate
LOCAL cIdSdi
LOCAL nPddAvailable
LOCAL j
LOCAL nCount_j
LOCAL cInvoiceDate
LOCAL cNumber_str
LOCAL cStatus
LOCAL cStatusDescription
LOCAL cErrorCode
LOCAL cErrorDescription
LOCAL nLast
LOCAL nTotalElements
LOCAL nTotalPages
LOCAL nSize
LOCAL nNumber
LOCAL nFirst
LOCAL nNumberOfElements
LOCAL i
LOCAL nCount_i
nSuccess := 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oHttp := CreateObject("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 := CreateObject("Chilkat.StringBuilder")
nSuccess := oHttp:QuickGetSb("https://ws.fatturazioneelettronica.aruba.it/services/invoice/in/findByUsername?username=Username", oSbResponseBody)
IF (nSuccess == 0)
? oHttp:LastErrorText
oHttp:destroy()
oSbResponseBody:destroy()
RETURN
ENDIF
oJResp := CreateObject("Chilkat.JsonObject")
oJResp:LoadSb(oSbResponseBody)
oJResp:EmitCompact := 0
? "Response Body:"
? oJResp:Emit()
nRespStatusCode := oHttp:LastStatus
? "Response Status Code = " + Str(nRespStatusCode)
IF (nRespStatusCode >= 400)
? "Response Header:"
? oHttp:LastHeader
? "Failed."
oHttp:destroy()
oSbResponseBody:destroy()
oJResp:destroy()
RETURN
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
cErrorCode := oJResp:StringOf("errorCode")
cErrorDescription := oJResp:StringOf("errorDescription")
nLast := oJResp:BoolOf("last")
nTotalElements := oJResp:IntOf("totalElements")
nTotalPages := oJResp:IntOf("totalPages")
nSize := oJResp:IntOf("size")
nNumber := oJResp:IntOf("number")
nFirst := oJResp:BoolOf("first")
nNumberOfElements := oJResp:IntOf("numberOfElements")
i := 0
nCount_i := oJResp:SizeOfArray("content")
DO WHILE i < nCount_i
oJResp:I := i
cErrorCode := oJResp:StringOf("content[i].errorCode")
cErrorDescription := oJResp:StringOf("content[i].errorDescription")
cId := oJResp:StringOf("content[i].id")
cSenderDescription := oJResp:StringOf("content[i].sender.description")
cSenderCountryCode := oJResp:StringOf("content[i].sender.countryCode")
cSenderVatCode := oJResp:StringOf("content[i].sender.vatCode")
cSenderFiscalCode := oJResp:StringOf("content[i].sender.fiscalCode")
cReceiverDescription := oJResp:StringOf("content[i].receiver.description")
cReceiverCountryCode := oJResp:StringOf("content[i].receiver.countryCode")
cReceiverVatCode := oJResp:StringOf("content[i].receiver.vatCode")
cReceiverFiscalCode := oJResp:StringOf("content[i].receiver.fiscalCode")
cInvoiceType := oJResp:StringOf("content[i].invoiceType")
cDocType := oJResp:StringOf("content[i].docType")
cFile := oJResp:StringOf("content[i].file")
cFilename := oJResp:StringOf("content[i].filename")
cUsername := oJResp:StringOf("content[i].username")
cLastUpdate := oJResp:StringOf("content[i].lastUpdate")
cCreationDate := oJResp:StringOf("content[i].creationDate")
cIdSdi := oJResp:StringOf("content[i].idSdi")
nPddAvailable := oJResp:BoolOf("content[i].pddAvailable")
j := 0
nCount_j := oJResp:SizeOfArray("content[i].invoices")
DO WHILE j < nCount_j
oJResp:J := j
cInvoiceDate := oJResp:StringOf("content[i].invoices[j].invoiceDate")
cNumber_str := oJResp:StringOf("content[i].invoices[j].number")
cStatus := oJResp:StringOf("content[i].invoices[j].status")
cStatusDescription := oJResp:StringOf("content[i].invoices[j].statusDescription")
j := j + 1
ENDDO
i := i + 1
ENDDO
oHttp:destroy()
oSbResponseBody:destroy()
oJResp:destroy()