1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
use crate::{error::ApiError, forge::{ForgeClient, PROMO_URL, models::ForgePromos}}; impl ForgeClient { /// Fetches Forge promotions JSON with latest versions per MC version. /// /// # Errors /// /// Returns [`ApiError::Http`] if the request or parsing fails. pub async fn get_promos(&self) -> Result<ForgePromos, ApiError> { let resp = self.client.get(PROMO_URL).send().await?.error_for_status()?; Ok(resp.json().await?) } } #[cfg(test)] #[allow(clippy::unwrap_used)] mod tests { use super::*; use reqwest::Client; #[tokio::test] async fn test_get_promos() { let client = ForgeClient::new(Client::new()); let promos = client.get_promos().await.unwrap(); assert!(!promos.promos.is_empty()); } }