Swift Fatturazione Elettronica Aruba IT: Get by Filename (Sent)

Back to Index

Questo metodo restituisce il dettaglio completo dello stato di una fattura elettronica.

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

CURL Command

curl -X GET  https://demows.fatturazioneelettronica.aruba.it/services/invoice/out/getByFilename?filename=IT07026037883_jtlkl.xml.p7m \
-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/getByFilename?filename=IT07026037883_jtlkl.xml.p7m
    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/getByFilename?filename=IT07026037883_jtlkl.xml.p7m", 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 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: String?
    var i: Int
    var count_i: Int
    var invoiceDate: String?
    var number: String?
    var status: String?

    id = jsonResponse.StringOf("id")
    senderDescription = jsonResponse.StringOf("sender.description")
    senderCountryCode = jsonResponse.StringOf("sender.countryCode")
    senderVatCode = jsonResponse.StringOf("sender.vatCode")
    senderFiscalCode = jsonResponse.StringOf("sender.fiscalCode")
    receiverDescription = jsonResponse.StringOf("receiver.description")
    receiverCountryCode = jsonResponse.StringOf("receiver.countryCode")
    receiverVatCode = jsonResponse.StringOf("receiver.vatCode")
    receiverFiscalCode = jsonResponse.StringOf("receiver.fiscalCode")
    invoiceType = jsonResponse.StringOf("invoiceType")
    docType = jsonResponse.StringOf("docType")
    file = jsonResponse.StringOf("file")
    filename = jsonResponse.StringOf("filename")
    username = jsonResponse.StringOf("username")
    lastUpdate = jsonResponse.StringOf("lastUpdate")
    idSdi = jsonResponse.StringOf("idSdi")
    i = 0
    count_i = jsonResponse.SizeOfArray("invoices").intValue
    while i < count_i {
        jsonResponse.I = i
        invoiceDate = jsonResponse.StringOf("invoices[i].invoiceDate")
        number = jsonResponse.StringOf("invoices[i].number")
        status = jsonResponse.StringOf("invoices[i].status")
        i = i + 1
    }


}

Sample JSON Response Body

{
  "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": "ZEdWemRBPT0=",
  "filename": "IT07026037883_jtlkl.xml.p7m",
  "invoices": [
    {
      "invoiceDate": "2019-01-21T17:36:21.179+01:00",
      "number": "1",
      "status": "Inviata"
    },
    {
      "invoiceDate": "2019-01-21T17:36:21.179+01:00",
      "number": "2",
      "status": "Consegnata"
    }
  ],
  "username": "Utente",
  "lastUpdate": "2019-01-21T17:36:21.179+01:00",
  "idSdi": null
}