diff --git a/src/lib.rs b/src/lib.rs index 031f844..61ba75a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -89,6 +89,16 @@ impl Protontweaks { self.try_apps().await.unwrap() } + pub async fn try_app_ids(&self) -> Result, String> { + self.try_apps() + .await + .map(|apps| apps.iter().map(|app| app.id.clone()).collect()) + } + + pub async fn app_ids(&self) -> Vec { + self.try_app_ids().await.unwrap() + } + pub async fn try_app(&self, app_id: &str) -> Result { self.get::(&format!("{app_id}.json")).await } @@ -127,6 +137,17 @@ mod tests { assert!(api.apps().await.len() > 0, "Should be a list of apps"); } + #[tokio::test] + async fn app_ids() { + let api = Protontweaks::new(); + + assert!( + api.try_app_ids().await.unwrap().len() > 0, + "Should be a list of app ids" + ); + assert!(api.app_ids().await.len() > 0, "Should be a list of app ids"); + } + #[tokio::test] async fn try_app() { let expected_id = "644930";