pub async fn new(endpoint: &str) -> Client {
        // for the timezone endpoint, define a region list property
        let regions: Vec<Value> = match endpoint {
            "timezone" => {
                let url = "https://worldtimeapi.org/api/timezone/".to_string();
                let response = reqwest::get(&url).await.unwrap();
                let regions = response.json().await.unwrap();
                regions
            }
            "ip" => {
                let url = "https://worldtimeapi.org/api/ip".to_string();
                let response = reqwest::get(&url).await.unwrap();
                let regions = response.json().await.unwrap();
                regions
            }
            _ => panic!("Unsupported endpoint: {}", endpoint),
        };

        let url: String = format!("https://worldtimeapi.org/api/{}", endpoint);

        Client { regions, url }
    }
/// Create a new client for the specified endpoint.
Create a new client for the specified endpoint.
Create a new client for the specified endpoint .
pub async fn new(endpoint: &str) -> Client {
        // for the timezone endpoint, define a region list property
        let regions: Vec<Value> = match endpoint {
            "timezone" => {
                let url = "https://worldtimeapi.org/api/timezone/".to_string();
                let response = reqwest::get(&url).await.unwrap();
                let regions = response.json().await.unwrap();
                regions
            }
            "ip" => {
                let url = "https://worldtimeapi.org/api/ip".to_string();
                let response = reqwest::get(&url).await.unwrap();
                let regions = response.json().await.unwrap();
                regions
            }
            _ => panic!("Unsupported endpoint: {}", endpoint),
        };
        let url: String = format!("https://worldtimeapi.org/api/{}", endpoint);
        Client { regions, url }
    }
pub async fn new ( endpoint : & str ) -> Client { // for the timezone endpoint, define a region list property let regions : Vec < Value > = match endpoint { " " => { let url = " " . to_string ( ) ; let response = reqwest :: get ( & url ) . await . unwrap ( ) ; let regions = response . json ( ) . await . unwrap ( ) ; regions } " " => { let url = " " . to_string ( ) ; let response = reqwest :: get ( & url ) . await . unwrap ( ) ; let regions = response . json ( ) . await . unwrap ( ) ; regions } _ => panic ! ( " " endpoint ) , } ; let url : String = format ! ( " " endpoint ) ; Client { regions , url } }
Create a new client for the specified endpoint.
Create a new client for the specified endpoint .
endpoint
&str