Lua
Lua
Aruba Fatturazione Elettronica userinfo
See more Aruba Fatturazione Examples
This method lets you retrieve user information relating to the authentication token.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://auth.fatturazioneelettronica.aruba.it/auth/userInfo \
-- -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="
local sbResponseBody = chilkat.StringBuilder.new()
local success = http:quick_get_sb("https://auth.fatturazioneelettronica.aruba.it/auth/userInfo", 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)
-- {
-- "username": "ARUBA0000",
-- "pec": "pec@pec.it",
-- "userDescription": "Aruba PEC S.p.A.",
-- "countryCode": "IT",
-- "vatCode": "01879020517",
-- "fiscalCode": "01879020517",
-- "accountStatus": {
-- "expired": false,
-- "expirationDate": "2020-10-10"
-- },
-- "usageStatus": {
-- "usedSpaceKB": 262144,
-- "maxSpaceKB": 1048576
-- }
-- }
-- 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 username = jResp:string_of("username")
local pec = jResp:string_of("pec")
local userDescription = jResp:string_of("userDescription")
local countryCode = jResp:string_of("countryCode")
local vatCode = jResp:string_of("vatCode")
local fiscalCode = jResp:string_of("fiscalCode")
local accountStatusExpired = jResp:bool_of("accountStatus.expired")
local accountStatusExpirationDate = jResp:string_of("accountStatus.expirationDate")
local usageStatusUsedSpaceKB = jResp:int_of("usageStatus.usedSpaceKB")
local usageStatusMaxSpaceKB = jResp:int_of("usageStatus.maxSpaceKB")