Sample code for 30+ languages & platforms
Lua

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

Lua
local chilkat = require("chilkat")

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

local http = chilkat.Http.new()

-- 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.
http.auth_token = "NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE="
http:set_request_header("Accept", "application/json")

local sbResponseBody = chilkat.StringBuilder.new()
local success = http:quick_get_sb("https://ws.fatturazioneelettronica.aruba.it/services/invoice/in/findByUsername?username=Username", sbResponseBody)
if not success then
    print(http.last_error_text)
    return
end

local jResp = chilkat.JsonObject.new()
jResp:load_sb(sbResponseBody)
jResp.emit_compact = false

print("Response Body:")
print(jResp:emit())

local respStatusCode = http.last_status
print("Response Status Code = " .. respStatusCode)
if respStatusCode >= 400 then
    print("Response Header:")
    print(http.last_header)
    print("Failed.")
    return
end

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

local id = ""
local senderDescription = ""
local senderCountryCode = ""
local senderVatCode = ""
local senderFiscalCode = ""
local receiverDescription = ""
local receiverCountryCode = ""
local receiverVatCode = ""
local receiverFiscalCode = ""
local invoiceType = ""
local docType = ""
local file = ""
local filename = ""
local username = ""
local lastUpdate = ""
local creationDate = ""
local idSdi = ""
local pddAvailable = false
local j = 0
local count_j = 0
local invoiceDate = ""
local number_str = ""
local status = ""
local statusDescription = ""

local errorCode = jResp:string_of("errorCode")
local errorDescription = jResp:string_of("errorDescription")
local last = jResp:bool_of("last")
local totalElements = jResp:int_of("totalElements")
local totalPages = jResp:int_of("totalPages")
local size = jResp:int_of("size")
local number = jResp:int_of("number")
local first = jResp:bool_of("first")
local numberOfElements = jResp:int_of("numberOfElements")
local i = 0
local count_i = jResp:size_of_array("content")
while i < count_i do
    jResp.i = i
    errorCode = jResp:string_of("content[i].errorCode")
    errorDescription = jResp:string_of("content[i].errorDescription")
    id = jResp:string_of("content[i].id")
    senderDescription = jResp:string_of("content[i].sender.description")
    senderCountryCode = jResp:string_of("content[i].sender.countryCode")
    senderVatCode = jResp:string_of("content[i].sender.vatCode")
    senderFiscalCode = jResp:string_of("content[i].sender.fiscalCode")
    receiverDescription = jResp:string_of("content[i].receiver.description")
    receiverCountryCode = jResp:string_of("content[i].receiver.countryCode")
    receiverVatCode = jResp:string_of("content[i].receiver.vatCode")
    receiverFiscalCode = jResp:string_of("content[i].receiver.fiscalCode")
    invoiceType = jResp:string_of("content[i].invoiceType")
    docType = jResp:string_of("content[i].docType")
    file = jResp:string_of("content[i].file")
    filename = jResp:string_of("content[i].filename")
    username = jResp:string_of("content[i].username")
    lastUpdate = jResp:string_of("content[i].lastUpdate")
    creationDate = jResp:string_of("content[i].creationDate")
    idSdi = jResp:string_of("content[i].idSdi")
    pddAvailable = jResp:bool_of("content[i].pddAvailable")
    j = 0
    count_j = jResp:size_of_array("content[i].invoices")
    while j < count_j do
        jResp.j = j
        invoiceDate = jResp:string_of("content[i].invoices[j].invoiceDate")
        number_str = jResp:string_of("content[i].invoices[j].number")
        status = jResp:string_of("content[i].invoices[j].status")
        statusDescription = jResp:string_of("content[i].invoices[j].statusDescription")
        j = j + 1
    end

    i = i + 1
end