use std::sync::Once;

static INIT: Once = Once::new();

pub fn init() {
    INIT.call_once(|| {
        let _ = dotenvy::from_path(concat!(env!("CARGO_MANIFEST_DIR"), "/.env"));
    });
}

pub fn api_key() -> String {
    init();
    std::env::var("RANDOM_ORG_API_KEY").expect("RANDOM_ORG_API_KEY missing")
}

pub fn client() -> randomorg_rpc::Client {
    randomorg_rpc::Client::new(api_key())
}
