Xbase++
Xbase++
Aruba Fatturazione Elettronica userinfo
See more Aruba Fatturazione Examples
This method lets you retrieve user information relating to the authentication token.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oHttp
LOCAL oSbResponseBody
LOCAL oJResp
LOCAL nRespStatusCode
LOCAL cUsername
LOCAL cPec
LOCAL cUserDescription
LOCAL cCountryCode
LOCAL cVatCode
LOCAL cFiscalCode
LOCAL nAccountStatusExpired
LOCAL cAccountStatusExpirationDate
LOCAL nUsageStatusUsedSpaceKB
LOCAL nUsageStatusMaxSpaceKB
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://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.
oHttp:AuthToken := "NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE="
oSbResponseBody := CreateObject("Chilkat.StringBuilder")
nSuccess := oHttp:QuickGetSb("https://auth.fatturazioneelettronica.aruba.it/auth/userInfo", 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)
// {
// "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
cUsername := oJResp:StringOf("username")
cPec := oJResp:StringOf("pec")
cUserDescription := oJResp:StringOf("userDescription")
cCountryCode := oJResp:StringOf("countryCode")
cVatCode := oJResp:StringOf("vatCode")
cFiscalCode := oJResp:StringOf("fiscalCode")
nAccountStatusExpired := oJResp:BoolOf("accountStatus.expired")
cAccountStatusExpirationDate := oJResp:StringOf("accountStatus.expirationDate")
nUsageStatusUsedSpaceKB := oJResp:IntOf("usageStatus.usedSpaceKB")
nUsageStatusMaxSpaceKB := oJResp:IntOf("usageStatus.maxSpaceKB")
oHttp:destroy()
oSbResponseBody:destroy()
oJResp:destroy()