area_details/
area_details.rs

1use eskom_se_push_api::area_info::{AreaInfo, AreaInfoURLBuilder};
2use eskom_se_push_api::{
3  constants::TOKEN_KEY, get_token_from_env, ureq_client::handle_ureq_response, Endpoint,
4};
5
6fn main() {
7  match get_token_from_env(None) {
8    Ok(val) => {
9      let api = AreaInfoURLBuilder::default()
10        .area_id("tshwane-6-brooklyn".to_owned())
11        .build()
12        .unwrap();
13      // Need to import the Endpoint trait
14      let response = ureq::request(api.method(), api.url().unwrap().as_str())
15        .set(TOKEN_KEY, &val)
16        .call();
17      match handle_ureq_response::<AreaInfo>(response) {
18        Ok(status) => {
19          println!("{:?}", status);
20        }
21        Err(e) => {
22          eprintln!("Error: {}", e);
23        }
24      }
25    }
26    Err(e) => panic!("Environment variable error: {}", e),
27  }
28}