Sample code for 30+ languages & platforms
Rust

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

Rust

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

let http = chilkat::Http::new();

// 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.
http.set_auth_token("NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=");
http.set_request_header("Accept", "application/json");

let sb_response_body = chilkat::StringBuilder::new();
if http.quick_get_sb("https://ws.fatturazioneelettronica.aruba.it/services/invoice/in/findByUsername?username=Username", &sb_response_body).is_err() {
    println!("{}", http.last_error_text());
    return;
}

let j_resp = chilkat::JsonObject::new();
let _ = j_resp.load_sb(&sb_response_body);
j_resp.set_emit_compact(false);

println!("Response Body:");
println!("{}", j_resp.emit().unwrap_or_default());

let resp_status_code = http.last_status();
println!("Response Status Code = {}", resp_status_code);
if resp_status_code >= 400 {
    println!("Response Header:");
    println!("{}", http.last_header());
    println!("Failed.");
    return;
}

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

let mut j: i32 = 0;
let mut count_j: i32 = 0;

let mut error_code = j_resp.string_of("errorCode").unwrap_or_default();
let mut error_description = j_resp.string_of("errorDescription").unwrap_or_default();
let last = j_resp.bool_of("last");
let total_elements = j_resp.int_of("totalElements");
let total_pages = j_resp.int_of("totalPages");
let size = j_resp.int_of("size");
let number = j_resp.int_of("number");
let first = j_resp.bool_of("first");
let number_of_elements = j_resp.int_of("numberOfElements");
let mut i = 0;
let count_i = j_resp.size_of_array("content");
while i < count_i {
    j_resp.set_i(i);
    error_code = j_resp.string_of("content[i].errorCode").unwrap_or_default();
    error_description = j_resp.string_of("content[i].errorDescription").unwrap_or_default();
    let _ = j_resp.string_of("content[i].id").unwrap_or_default();
    let _ = j_resp.string_of("content[i].sender.description").unwrap_or_default();
    let _ = j_resp.string_of("content[i].sender.countryCode").unwrap_or_default();
    let _ = j_resp.string_of("content[i].sender.vatCode").unwrap_or_default();
    let _ = j_resp.string_of("content[i].sender.fiscalCode").unwrap_or_default();
    let _ = j_resp.string_of("content[i].receiver.description").unwrap_or_default();
    let _ = j_resp.string_of("content[i].receiver.countryCode").unwrap_or_default();
    let _ = j_resp.string_of("content[i].receiver.vatCode").unwrap_or_default();
    let _ = j_resp.string_of("content[i].receiver.fiscalCode").unwrap_or_default();
    let _ = j_resp.string_of("content[i].invoiceType").unwrap_or_default();
    let _ = j_resp.string_of("content[i].docType").unwrap_or_default();
    let _ = j_resp.string_of("content[i].file").unwrap_or_default();
    let _ = j_resp.string_of("content[i].filename").unwrap_or_default();
    let _ = j_resp.string_of("content[i].username").unwrap_or_default();
    let _ = j_resp.string_of("content[i].lastUpdate").unwrap_or_default();
    let _ = j_resp.string_of("content[i].creationDate").unwrap_or_default();
    let _ = j_resp.string_of("content[i].idSdi").unwrap_or_default();
    let _ = j_resp.bool_of("content[i].pddAvailable");
    j = 0;
    count_j = j_resp.size_of_array("content[i].invoices");
    while j < count_j {
        j_resp.set_j(j);
        let _ = j_resp.string_of("content[i].invoices[j].invoiceDate").unwrap_or_default();
        let _ = j_resp.string_of("content[i].invoices[j].number").unwrap_or_default();
        let _ = j_resp.string_of("content[i].invoices[j].status").unwrap_or_default();
        let _ = j_resp.string_of("content[i].invoices[j].statusDescription").unwrap_or_default();
        j = j + 1;
    }

    i = i + 1;
}