use reqwest::Method;
use crate::{api_url, send_api_request, Error, ImageInfo, ImgurClient, Result};
pub async fn get_image(client: &ImgurClient, image: &str) -> Result<ImageInfo> {
let uri = api_url!(format!("image/{image}"));
let res = send_api_request(client, Method::GET, uri, None).await?;
let status = res.status();
if status.is_client_error() || status.is_server_error() {
let body = res.text().await?;
return Err(Error::ApiError(status.as_u16(), body));
}
Ok(res.json().await?)
}