Sample code for 30+ languages & platforms
Rust Requires Chilkat v11.0.0+

Banco Inter Obtendo uma lista de boletos

See more Banco Inter Examples

Get a list of tickets that match the search criteria.

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 \
//   -H "Authorization: Bearer $TOKEN" \
//   --cert <nome arquivo certificado>.crt \
//   --key <nome arquivo chave privada>.key \
//   --get \
//   --data-urlencode "dataInicial=2022-04-01" \
//   --data-urlencode "dataFinal=2022-04-03" \
//   --data-urlencode "situacao=VENCIDO" \
//   --data-urlencode "tipoOrdenacao=ASC" \
//   --data-urlencode "itensPorPagina=10" \
//   --data-urlencode "paginaAtual=2" \
//  https://cdpj.partners.bancointer.com.br/cobranca/v2/boletos

// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code

let cert = chilkat::Cert::new();
if cert.load_from_file("<nome arquivo certificado>.crt").is_err() {
    println!("{}", cert.last_error_text());
    return;
}

let bd_priv_key = chilkat::BinData::new();
if bd_priv_key.load_file("<nome arquivo chave privada>.key").is_err() {
    println!("Failed to load key");
    return;
}

// Note: If your private key file requires a password, then set it here.
// Otherwise pass the empty string.
let priv_key_password = String::new();
let priv_key = chilkat::PrivateKey::new();
if priv_key.load_any_format(&bd_priv_key, &priv_key_password).is_err() {
    println!("{}", priv_key.last_error_text());
    return;
}

if cert.set_private_key(&priv_key).is_err() {
    println!("{}", cert.last_error_text());
    return;
}

let _ = http.set_ssl_client_cert(&cert);

let query_params = chilkat::JsonObject::new();
let _ = query_params.update_string("dataInicial", "2022-04-01");
let _ = query_params.update_string("dataFinal", "2022-04-03");
let _ = query_params.update_string("situacao", "VENCIDO");
let _ = query_params.update_string("tipoOrdenacao", "ASC");
let _ = query_params.update_int("itensPorPagina", 10);
let _ = query_params.update_int("paginaAtual", 2);

// Adds the "Authorization: Bearer $TOKEN" header.
http.set_auth_token("$TOKEN");

let resp = chilkat::HttpResponse::new();
if http.http_params("GET", "https://cdpj.partners.bancointer.com.br/cobranca/v2/boletos", &query_params, &resp).is_err() {
    println!("{}", http.last_error_text());
    return;
}

let sb_response_body = chilkat::StringBuilder::new();
let _ = resp.get_body_sb(&sb_response_body);

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 = resp.status_code();
println!("Response Status Code = {}", resp_status_code);
if resp_status_code >= 400 {
    println!("Response Header:");
    println!("{}", resp.header());
    println!("Failed.");
    return;
}

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// {
//   "totalPages": 1,
//   "totalElements": 58,
//   "last": true,
//   "first": true,
//   "size": 100,
//   "numberOfElements": 58,
//   "content": [
//     {
//       "nomeBeneficiario": "nome do beneficiario 1",
//       "cnpjCpfBeneficiario": "CNPJ/CPF beneficiario 1"
//     },
//     {
//       "nomeBeneficiario": "nome do beneficiario 2",
//       "cnpjCpfBeneficiario": "CNPJ/CPF beneficiario 2"
//     },
//     {
//       "nomeBeneficiario": "nome do beneficiario N",
//       "cnpjCpfBeneficiario": "CNPJ/CPF beneficiario N"
//     }
//   ]
// }

// 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 total_pages = j_resp.int_of("totalPages");
let total_elements = j_resp.int_of("totalElements");
let last = j_resp.bool_of("last");
let first = j_resp.bool_of("first");
let size = j_resp.int_of("size");
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);
    let _ = j_resp.string_of("content[i].nomeBeneficiario").unwrap_or_default();
    let _ = j_resp.string_of("content[i].cnpjCpfBeneficiario").unwrap_or_default();
    i = i + 1;
}