use serde::{Deserialize, Serialize};
use crate::{
errors::{ErrorHandle, SteamAppsError},
macros::do_http,
Steam, BASE,
};
use super::INTERFACE;
const ENDPOINT: &str = "GetAppList";
const VERSION: &str = "2";
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct App {
pub appid: u32,
pub name: String,
}
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct AppList {
pub apps: Vec<App>,
}
#[derive(Deserialize, Serialize, Debug)]
struct Wrapper {
applist: AppList,
}
impl Steam {
pub async fn get_app_list() -> Result<AppList, SteamAppsError> {
let url = format!("{}/{}/{}/v{}/", BASE, INTERFACE, ENDPOINT, VERSION);
let wrapper = do_http!(url, Wrapper, ErrorHandle, SteamAppsError::GetAppList);
Ok(wrapper.applist)
}
}