Sample code for 30+ languages & platforms
DataFlex

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

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoHttp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sId
    String sSenderDescription
    String sSenderCountryCode
    String sSenderVatCode
    String sSenderFiscalCode
    String sReceiverDescription
    String sReceiverCountryCode
    String sReceiverVatCode
    String sReceiverFiscalCode
    String sInvoiceType
    String sDocType
    String sFile
    String sFilename
    String sUsername
    String sLastUpdate
    String sCreationDate
    String sIdSdi
    Boolean iPddAvailable
    Integer j
    Integer iCount_j
    String sInvoiceDate
    String sNumber_str
    String sStatus
    String sStatusDescription
    String sErrorCode
    String sErrorDescription
    Boolean iLast
    Integer iTotalElements
    Integer iTotalPages
    Integer iSize
    Integer iNumber
    Boolean iFirst
    Integer iNumberOfElements
    Integer i
    Integer iCount_i
    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://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.
    Set ComAuthToken Of hoHttp To "NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE="
    Send ComSetRequestHeader To hoHttp "Accept" "application/json"

    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://ws.fatturazioneelettronica.aruba.it/services/invoice/in/findByUsername?username=Username" 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)

    // {
    //   "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

    Get ComStringOf Of hoJResp "errorCode" To sErrorCode
    Get ComStringOf Of hoJResp "errorDescription" To sErrorDescription
    Get ComBoolOf Of hoJResp "last" To iLast
    Get ComIntOf Of hoJResp "totalElements" To iTotalElements
    Get ComIntOf Of hoJResp "totalPages" To iTotalPages
    Get ComIntOf Of hoJResp "size" To iSize
    Get ComIntOf Of hoJResp "number" To iNumber
    Get ComBoolOf Of hoJResp "first" To iFirst
    Get ComIntOf Of hoJResp "numberOfElements" To iNumberOfElements
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "content" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "content[i].errorCode" To sErrorCode
        Get ComStringOf Of hoJResp "content[i].errorDescription" To sErrorDescription
        Get ComStringOf Of hoJResp "content[i].id" To sId
        Get ComStringOf Of hoJResp "content[i].sender.description" To sSenderDescription
        Get ComStringOf Of hoJResp "content[i].sender.countryCode" To sSenderCountryCode
        Get ComStringOf Of hoJResp "content[i].sender.vatCode" To sSenderVatCode
        Get ComStringOf Of hoJResp "content[i].sender.fiscalCode" To sSenderFiscalCode
        Get ComStringOf Of hoJResp "content[i].receiver.description" To sReceiverDescription
        Get ComStringOf Of hoJResp "content[i].receiver.countryCode" To sReceiverCountryCode
        Get ComStringOf Of hoJResp "content[i].receiver.vatCode" To sReceiverVatCode
        Get ComStringOf Of hoJResp "content[i].receiver.fiscalCode" To sReceiverFiscalCode
        Get ComStringOf Of hoJResp "content[i].invoiceType" To sInvoiceType
        Get ComStringOf Of hoJResp "content[i].docType" To sDocType
        Get ComStringOf Of hoJResp "content[i].file" To sFile
        Get ComStringOf Of hoJResp "content[i].filename" To sFilename
        Get ComStringOf Of hoJResp "content[i].username" To sUsername
        Get ComStringOf Of hoJResp "content[i].lastUpdate" To sLastUpdate
        Get ComStringOf Of hoJResp "content[i].creationDate" To sCreationDate
        Get ComStringOf Of hoJResp "content[i].idSdi" To sIdSdi
        Get ComBoolOf Of hoJResp "content[i].pddAvailable" To iPddAvailable
        Move 0 To j
        Get ComSizeOfArray Of hoJResp "content[i].invoices" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "content[i].invoices[j].invoiceDate" To sInvoiceDate
            Get ComStringOf Of hoJResp "content[i].invoices[j].number" To sNumber_str
            Get ComStringOf Of hoJResp "content[i].invoices[j].status" To sStatus
            Get ComStringOf Of hoJResp "content[i].invoices[j].statusDescription" To sStatusDescription
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop



End_Procedure