Swift 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='

Swift Example


func chilkatTest() {
    let rest = CkoRest()
    var success: Bool

    //  URL: https://demows.fatturazioneelettronica.aruba.it/services/invoice/out/findByUsername?username=Utente
    var bTls: Bool = true
    var port: Int = 443
    var bAutoReconnect: Bool = true
    success = rest.Connect("demows.fatturazioneelettronica.aruba.it", port: port, tls: bTls, autoReconnect: bAutoReconnect)
    if success != true {
        print("ConnectFailReason: \(rest.ConnectFailReason.intValue)")
        print("\(rest.LastErrorText)")
        return
    }

    rest.AddHeader("Authorization", value: "Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=")
    rest.AddHeader("Accept", value: "application/json")

    let sbResponseBody = CkoStringBuilder()
    success = rest.FullRequestNoBodySb("GET", uriPath: "/services/invoice/out/findByUsername?username=Utente", sb: sbResponseBody)
    if success != true {
        print("\(rest.LastErrorText)")
        return
    }

    var respStatusCode: Int = rest.ResponseStatusCode.intValue
    if respStatusCode >= 400 {
        print("Response Status Code = \(respStatusCode)")
        print("Response Header:")
        print("\(rest.ResponseHeader)")
        print("Response Body:")
        print("\(sbResponseBody.GetAsString())")
        return
    }

    let jsonResponse = CkoJsonObject()
    jsonResponse.LoadSb(sbResponseBody)

    //  See the Online Tool for Generating JSON Parse Code
    var last: Bool
    var totalElements: Int
    var totalPages: Int
    var size: Int
    var number: Int
    var first: Bool
    var numberOfElements: Int
    var i: Int
    var count_i: Int
    var id: String?
    var senderDescription: String?
    var senderCountryCode: String?
    var senderVatCode: String?
    var senderFiscalCode: String?
    var receiverDescription: String?
    var receiverCountryCode: String?
    var receiverVatCode: String?
    var receiverFiscalCode: String?
    var invoiceType: String?
    var docType: String?
    var file: String?
    var filename: String?
    var username: String?
    var lastUpdate: String?
    var idSdi: Int
    var j: Int
    var count_j: Int
    var invoiceDate: String?
    var number_str: String?
    var status: String?

    last = jsonResponse.BoolOf("last")
    totalElements = jsonResponse.IntOf("totalElements").intValue
    totalPages = jsonResponse.IntOf("totalPages").intValue
    size = jsonResponse.IntOf("size").intValue
    number = jsonResponse.IntOf("number").intValue
    first = jsonResponse.BoolOf("first")
    numberOfElements = jsonResponse.IntOf("numberOfElements").intValue
    i = 0
    count_i = jsonResponse.SizeOfArray("content").intValue
    while i < count_i {
        jsonResponse.I = i
        id = jsonResponse.StringOf("content[i].id")
        senderDescription = jsonResponse.StringOf("content[i].sender.description")
        senderCountryCode = jsonResponse.StringOf("content[i].sender.countryCode")
        senderVatCode = jsonResponse.StringOf("content[i].sender.vatCode")
        senderFiscalCode = jsonResponse.StringOf("content[i].sender.fiscalCode")
        receiverDescription = jsonResponse.StringOf("content[i].receiver.description")
        receiverCountryCode = jsonResponse.StringOf("content[i].receiver.countryCode")
        receiverVatCode = jsonResponse.StringOf("content[i].receiver.vatCode")
        receiverFiscalCode = jsonResponse.StringOf("content[i].receiver.fiscalCode")
        invoiceType = jsonResponse.StringOf("content[i].invoiceType")
        docType = jsonResponse.StringOf("content[i].docType")
        file = jsonResponse.StringOf("content[i].file")
        filename = jsonResponse.StringOf("content[i].filename")
        username = jsonResponse.StringOf("content[i].username")
        lastUpdate = jsonResponse.StringOf("content[i].lastUpdate")
        idSdi = jsonResponse.IntOf("content[i].idSdi").intValue
        j = 0
        count_j = jsonResponse.SizeOfArray("content[i].invoices").intValue
        while j < count_j {
            jsonResponse.J = j
            invoiceDate = jsonResponse.StringOf("content[i].invoices[j].invoiceDate")
            number_str = jsonResponse.StringOf("content[i].invoices[j].number")
            status = jsonResponse.StringOf("content[i].invoices[j].status")
            j = j + 1
        }

        i = i + 1
    }


}

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
}