Sample code for 30+ languages & platforms
DataFlex

Aruba Fatturazione Elettronica userinfo

See more Aruba Fatturazione Examples

This method lets you retrieve user information relating to the authentication token.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoHttp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sUsername
    String sPec
    String sUserDescription
    String sCountryCode
    String sVatCode
    String sFiscalCode
    Boolean iAccountStatusExpired
    String sAccountStatusExpirationDate
    Integer iUsageStatusUsedSpaceKB
    Integer iUsageStatusMaxSpaceKB
    String sTemp1

    Move False To iSuccess

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // 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.
    Set ComAuthToken Of hoHttp To "NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE="

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComQuickGetSb Of hoHttp "https://auth.fatturazioneelettronica.aruba.it/auth/userInfo" vSbResponseBody To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComLastStatus Of hoHttp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComLastHeader Of hoHttp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Procedure_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

    Get ComStringOf Of hoJResp "username" To sUsername
    Get ComStringOf Of hoJResp "pec" To sPec
    Get ComStringOf Of hoJResp "userDescription" To sUserDescription
    Get ComStringOf Of hoJResp "countryCode" To sCountryCode
    Get ComStringOf Of hoJResp "vatCode" To sVatCode
    Get ComStringOf Of hoJResp "fiscalCode" To sFiscalCode
    Get ComBoolOf Of hoJResp "accountStatus.expired" To iAccountStatusExpired
    Get ComStringOf Of hoJResp "accountStatus.expirationDate" To sAccountStatusExpirationDate
    Get ComIntOf Of hoJResp "usageStatus.usedSpaceKB" To iUsageStatusUsedSpaceKB
    Get ComIntOf Of hoJResp "usageStatus.maxSpaceKB" To iUsageStatusMaxSpaceKB


End_Procedure