Skip to main content

bill_example/
bill_example.rs

1use cdg_api::cdg_types::{BillType, FormatType};
2use cdg_api::endpoints::Endpoints;
3use cdg_api::param_models::BillActionsParams;
4use cdg_api::response_models::BillActionsResponse;
5use cdg_api::CongressApiClient;
6
7use std::error::Error;
8
9fn main() -> Result<(), Box<dyn Error>> {
10    let client = CongressApiClient::new(None)?; // Use default API key
11
12    // Define parameters
13    let params = BillActionsParams::default()
14        .format(FormatType::Json)
15        .limit(10);
16
17    // Create the endpoint
18    let endpoint = Endpoints::BillActions(118, BillType::S, 4361, params);
19
20    // Fetch the data
21    let response: BillActionsResponse = client.fetch(endpoint)?;
22
23    // Process the response
24    for action in response.actions {
25        println!("{:#?}\n", action);
26        println!("=====================");
27        println!("=====================\n");
28    }
29
30    Ok(())
31}
32
33//fn main() -> Result<(), Box<dyn Error>> {
34//    let client = CongressApiClient::new(None)?; // Use default API key
35//
36//    // Define parameters
37//    let params = BillListParams::default().format(FormatType::Json).limit(10);
38//
39//    // Create the endpoint
40//    let endpoint = Endpoints::BillList(params);
41//
42//    // Fetch the data
43//    let response: BillsResponse = client.fetch(endpoint)?;
44//
45//    // Process the response
46//    for bill in response.bills {
47//        println!(
48//            "{}, {}, {}\n",
49//            bill.title.unwrap_or("".to_string()),
50//            bill.bill_type.unwrap_or("".to_string()),
51//            bill.number.unwrap_or("".to_string())
52//        );
53//    }
54//
55//    Ok(())
56//}