use crate::io::api::{ApiResult, RemoteResource, TextResponse, INCLUDED_ENDPOINTS};
use crate::schema::geonames::Countries;
use crate::util::Searchable;
use color_eyre::eyre::eyre;
pub type SearchResponse = TextResponse;
pub async fn download() -> ApiResult<Countries> {
let name = "GeoNames";
match INCLUDED_ENDPOINTS.find_by_name(name) {
| Some(endpoint) => {
let response = endpoint.invoke("countries", None).await;
endpoint.handle::<SearchResponse>(response).map(|text| text.to_string().into())
}
| None => Err(eyre!("{name} endpoint not found")),
}
}