Lua
Lua
Aruba Fatturazione Elettronica getByIdSdi
See more Aruba Fatturazione Examples
This method returns the complete status detail of an electronic invoice. Search for a single invoice by SdI identifier.Chilkat Lua Downloads
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/out/getByIdSdi?idSdi=11110&includePdf=true \
-- -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/out/getByIdSdi?idSdi=11110&includePdf=true", sbResponseBody)
if not success then
print(http.last_error_text)
return
end
local respStatusCode = http.last_status
print("response status code = " .. respStatusCode)
local json = chilkat.JsonObject.new()
json:load_sb(sbResponseBody)
json.emit_compact = true
print("Response JSON:")
print(json:emit())
if respStatusCode ~= 200 then
print("Failed.")
return
end
-- Sample response:
-- Use this online tool to generate parsing code from sample JSON:
-- Generate Parsing Code from JSON
-- {
-- "errorCode" : "0000",
-- "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" : "dGVzdA==",
-- "filename" : "IT01879020517_jtlk0.xml.p7m",
-- "invoices" : [ {
-- "invoiceDate" : "2021-08-24T12:35:45.363+02:00",
-- "number" : "2021/0001",
-- "status" : "Inviata",
-- "statusDescription" : ""
-- } ],
-- "username" : "Utente",
-- "lastUpdate" : "2021-08-24T10:35:45.363+0000",
-- "creationDate" : "2021-08-24T10:35:45.363+0000",
-- "idSdi" : "11110",
-- "pdfFile" : "ZEdWemRGQmtaZz09",
-- "pddAvailable" : true
-- }
--
local invoiceDate = ""
local number = ""
local status = ""
local statusDescription = ""
local errorCode = json:string_of("errorCode")
local errorDescription = json:string_of("errorDescription")
local id = json:string_of("id")
local senderDescription = json:string_of("sender.description")
local senderCountryCode = json:string_of("sender.countryCode")
local senderVatCode = json:string_of("sender.vatCode")
local senderFiscalCode = json:string_of("sender.fiscalCode")
local receiverDescription = json:string_of("receiver.description")
local receiverCountryCode = json:string_of("receiver.countryCode")
local receiverVatCode = json:string_of("receiver.vatCode")
local receiverFiscalCode = json:string_of("receiver.fiscalCode")
local invoiceType = json:string_of("invoiceType")
local docType = json:string_of("docType")
local file = json:string_of("file")
local filename = json:string_of("filename")
local username = json:string_of("username")
local lastUpdate = json:string_of("lastUpdate")
local creationDate = json:string_of("creationDate")
local idSdi = json:string_of("idSdi")
local pdfFile = json:string_of("pdfFile")
local pddAvailable = json:bool_of("pddAvailable")
local i = 0
local count_i = json:size_of_array("invoices")
while i < count_i do
json.i = i
invoiceDate = json:string_of("invoices[i].invoiceDate")
number = json:string_of("invoices[i].number")
status = json:string_of("invoices[i].status")
statusDescription = json:string_of("invoices[i].statusDescription")
i = i + 1
end