SQL Server Fatturazione Elettronica Aruba IT: Find by Username (Sent)

Back to Index

Questo metodo restituisce l’elenco delle fatture elettroniche inviate dall’utente e prese in carico dal sistema. La lista di Fatture ritorna senza il contenuto in base64 (lazy loading)

Documentation: https://fatturazioneelettronica.aruba.it/apidoc/docs.html#_findbyusername

CURL Command

curl -X GET  https://demows.fatturazioneelettronica.aruba.it/services/invoice/out/findByUsername?username=Utente \
-H 'Accept: application/json' \
-H 'Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE='

SQL Server Example

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @rest int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Rest', @rest OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    --  URL: https://demows.fatturazioneelettronica.aruba.it/services/invoice/out/findByUsername?username=Utente
    DECLARE @bTls int
    SELECT @bTls = 1
    DECLARE @port int
    SELECT @port = 443
    DECLARE @bAutoReconnect int
    SELECT @bAutoReconnect = 1
    EXEC sp_OAMethod @rest, 'Connect', @success OUT, 'demows.fatturazioneelettronica.aruba.it', @port, @bTls, @bAutoReconnect
    IF @success <> 1
      BEGIN

        EXEC sp_OAGetProperty @rest, 'ConnectFailReason', @iTmp0 OUT
        PRINT 'ConnectFailReason: ' + @iTmp0
        EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @rest
        RETURN
      END

    EXEC sp_OAMethod @rest, 'AddHeader', @success OUT, 'Authorization', 'Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE='
    EXEC sp_OAMethod @rest, 'AddHeader', @success OUT, 'Accept', 'application/json'

    DECLARE @sbResponseBody int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @rest, 'FullRequestNoBodySb', @success OUT, 'GET', '/services/invoice/out/findByUsername?username=Utente', @sbResponseBody
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @rest
        EXEC @hr = sp_OADestroy @sbResponseBody
        RETURN
      END
    DECLARE @respStatusCode int
    EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @respStatusCode OUT
    IF @respStatusCode >= 400
      BEGIN

        PRINT 'Response Status Code = ' + @respStatusCode

        PRINT 'Response Header:'
        EXEC sp_OAGetProperty @rest, 'ResponseHeader', @sTmp0 OUT
        PRINT @sTmp0

        PRINT 'Response Body:'
        EXEC sp_OAMethod @sbResponseBody, 'GetAsString', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @rest
        EXEC @hr = sp_OADestroy @sbResponseBody
        RETURN
      END

    DECLARE @jsonResponse int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @jsonResponse OUT

    EXEC sp_OAMethod @jsonResponse, 'LoadSb', @success OUT, @sbResponseBody

    --  See the Online Tool for Generating JSON Parse Code
    DECLARE @last int

    DECLARE @totalElements int

    DECLARE @totalPages int

    DECLARE @size int

    DECLARE @number int

    DECLARE @first int

    DECLARE @numberOfElements int

    DECLARE @i int

    DECLARE @count_i int

    DECLARE @id nvarchar(4000)

    DECLARE @senderDescription nvarchar(4000)

    DECLARE @senderCountryCode nvarchar(4000)

    DECLARE @senderVatCode nvarchar(4000)

    DECLARE @senderFiscalCode nvarchar(4000)

    DECLARE @receiverDescription nvarchar(4000)

    DECLARE @receiverCountryCode nvarchar(4000)

    DECLARE @receiverVatCode nvarchar(4000)

    DECLARE @receiverFiscalCode nvarchar(4000)

    DECLARE @invoiceType nvarchar(4000)

    DECLARE @docType nvarchar(4000)

    DECLARE @file nvarchar(4000)

    DECLARE @filename nvarchar(4000)

    DECLARE @username nvarchar(4000)

    DECLARE @lastUpdate nvarchar(4000)

    DECLARE @idSdi int

    DECLARE @j int

    DECLARE @count_j int

    DECLARE @invoiceDate nvarchar(4000)

    DECLARE @number_str nvarchar(4000)

    DECLARE @status nvarchar(4000)

    EXEC sp_OAMethod @jsonResponse, 'BoolOf', @last OUT, 'last'
    EXEC sp_OAMethod @jsonResponse, 'IntOf', @totalElements OUT, 'totalElements'
    EXEC sp_OAMethod @jsonResponse, 'IntOf', @totalPages OUT, 'totalPages'
    EXEC sp_OAMethod @jsonResponse, 'IntOf', @size OUT, 'size'
    EXEC sp_OAMethod @jsonResponse, 'IntOf', @number OUT, 'number'
    EXEC sp_OAMethod @jsonResponse, 'BoolOf', @first OUT, 'first'
    EXEC sp_OAMethod @jsonResponse, 'IntOf', @numberOfElements OUT, 'numberOfElements'
    SELECT @i = 0
    EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_i OUT, 'content'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jsonResponse, 'I', @i
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @id OUT, 'content[i].id'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @senderDescription OUT, 'content[i].sender.description'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @senderCountryCode OUT, 'content[i].sender.countryCode'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @senderVatCode OUT, 'content[i].sender.vatCode'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @senderFiscalCode OUT, 'content[i].sender.fiscalCode'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @receiverDescription OUT, 'content[i].receiver.description'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @receiverCountryCode OUT, 'content[i].receiver.countryCode'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @receiverVatCode OUT, 'content[i].receiver.vatCode'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @receiverFiscalCode OUT, 'content[i].receiver.fiscalCode'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @invoiceType OUT, 'content[i].invoiceType'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @docType OUT, 'content[i].docType'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @file OUT, 'content[i].file'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @filename OUT, 'content[i].filename'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @username OUT, 'content[i].username'
        EXEC sp_OAMethod @jsonResponse, 'StringOf', @lastUpdate OUT, 'content[i].lastUpdate'
        EXEC sp_OAMethod @jsonResponse, 'IntOf', @idSdi OUT, 'content[i].idSdi'
        SELECT @j = 0
        EXEC sp_OAMethod @jsonResponse, 'SizeOfArray', @count_j OUT, 'content[i].invoices'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jsonResponse, 'J', @j
            EXEC sp_OAMethod @jsonResponse, 'StringOf', @invoiceDate OUT, 'content[i].invoices[j].invoiceDate'
            EXEC sp_OAMethod @jsonResponse, 'StringOf', @number_str OUT, 'content[i].invoices[j].number'
            EXEC sp_OAMethod @jsonResponse, 'StringOf', @status OUT, 'content[i].invoices[j].status'
            SELECT @j = @j + 1
          END
        SELECT @i = @i + 1
      END

    EXEC @hr = sp_OADestroy @rest
    EXEC @hr = sp_OADestroy @sbResponseBody
    EXEC @hr = sp_OADestroy @jsonResponse


END
GO

Sample JSON Response Body

{
  "content": [
    {
      "id": "1",
      "sender": {
        "description": "Aruba SPA",
        "countryCode": "ITA",
        "vatCode": "6372762541",
        "fiscalCode": "N5Hnt9vvMZ"
      },
      "receiver": {
        "description": "Rossi SRL",
        "countryCode": "ITA",
        "vatCode": "8767263441",
        "fiscalCode": "LVZTeOJ8BN"
      },
      "invoiceType": "FPA12",
      "docType": "in",
      "file": null,
      "filename": "IT07026037883_jtlkl.xml.p7m",
      "invoices": [
        {
          "invoiceDate": "2019-01-21T17:36:20.835+01:00",
          "number": "1",
          "status": "Inviata"
        }
      ],
      "username": "Utente",
      "lastUpdate": "2019-01-21T17:36:20.835+01:00",
      "idSdi": 7895
    },
    {
      "id": "2",
      "sender": {
        "description": "Aruba SPA",
        "countryCode": "fKo",
        "vatCode": "0845927294",
        "fiscalCode": "1dzZUPwfhO"
      },
      "receiver": {
        "description": "Rossi SRL",
        "countryCode": "WGf",
        "vatCode": "7188186772",
        "fiscalCode": "p46bxpoQgx"
      },
      "invoiceType": "FPA12",
      "docType": "in",
      "file": null,
      "filename": "IT00499202641_kwefc.xml.p7m",
      "invoices": [
        {
          "invoiceDate": "2019-01-21T17:36:20.835+01:00",
          "number": "1",
          "status": "Inviata"
        }
      ],
      "username": "Utente",
      "lastUpdate": "2019-01-21T17:36:20.835+01:00",
      "idSdi": 7895
    },
    {
      "id": "3",
      "sender": {
        "description": "Aruba SPA",
        "countryCode": "IT",
        "vatCode": "56215678997",
        "fiscalCode": "94170917594"
      },
      "receiver": {
        "description": "Rossi SRL",
        "countryCode": "IT",
        "vatCode": "27446044667",
        "fiscalCode": "13591589640"
      },
      "invoiceType": "FPA12",
      "docType": "in",
      "file": null,
      "filename": "IT01787589930_bkemy.xml.p7m",
      "invoices": [
        {
          "invoiceDate": "2019-01-21T17:36:20.835+01:00",
          "number": "1",
          "status": "Inviata"
        }
      ],
      "username": "Utente",
      "lastUpdate": "2019-01-21T17:36:20.835+01:00",
      "idSdi": 7895
    },
    {
      "id": "4",
      "sender": {
        "description": "Aruba SPA",
        "countryCode": "IT",
        "vatCode": "51878525587",
        "fiscalCode": "37556497667"
      },
      "receiver": {
        "description": "Rossi SRL",
        "countryCode": "IT",
        "vatCode": "95708696901",
        "fiscalCode": "69989572913"
      },
      "invoiceType": "FPA12",
      "docType": "in",
      "file": null,
      "filename": "IT06620176401_pdrjw.xml.p7m",
      "invoices": [
        {
          "invoiceDate": "2019-01-21T17:36:20.835+01:00",
          "number": "1",
          "status": "Inviata"
        }
      ],
      "username": "Utente",
      "lastUpdate": "2019-01-21T17:36:20.835+01:00",
      "idSdi": 7895
    }
  ],
  "last": true,
  "totalElements": 4,
  "totalPages": 1,
  "size": 10,
  "number": 0,
  "first": true,
  "numberOfElements": 4
}