use crate::idota2match_570::get_heroes::Hero;
use crate::idota2match_570::get_league_listing::League;
use crate::idota2match_570::get_live_league_games::LiveLeagueGame;
use crate::idota2match_570::get_match_details::MatchResult;
use crate::idota2match_570::get_match_history::ResponseMatchHistory;
use crate::idota2match_570::get_team_info_by_team_id::TeamInfo;
use crate::isteam_apps::get_app_list::SteamApp;
use crate::isteam_news::get_news_for_app::NewsItem;
use crate::isteam_user::get_friend_list::Friend;
use crate::isteam_user::get_player_bans::PlayerBans;
use crate::isteam_user::get_player_summaries::PlayerSummary;
use crate::isteam_user::resolve_vanity_url::VanityUrlResolution;
use crate::isteam_user_stats::get_global_achievement_percentages_for_app::AchievementPercentage;
use crate::isteam_user_stats::get_player_achievements::PlayerAchievements;
use crate::isteam_user_stats::get_schema_for_game::GameSchema;
use crate::isteam_user_stats::get_user_stats_for_game::UserStatsForGame;
use crate::iplayer_service::get_badges::Badges;
use crate::iplayer_service::get_owned_games::OwnedGames;
use crate::iplayer_service::get_recently_played_games::RecentlyPlayedGames;
use crate::store_steampowered_com::appdetails::SteamAppDetails;
pub mod util;
pub mod isteam_apps;
pub mod isteam_user;
pub mod isteam_user_stats;
pub mod isteam_news;
pub mod iplayer_service;
pub mod store_steampowered_com;
pub mod idota2match_570;
#[cfg(test)]
mod tests;
pub fn get_cached_app_details(app_id: i64) -> Result<SteamAppDetails, String> {
let boxed_result = store_steampowered_com::appdetails::get_cached(app_id);
boxed_result
}
pub fn get_app_details(app_id: i64) -> Result<SteamAppDetails, String> {
let boxed_result = store_steampowered_com::appdetails::get(app_id);
boxed_result
}
pub fn get_app_list() -> Result<Vec<SteamApp>, String> {
let boxed_result = isteam_apps::get_app_list::get();
boxed_result
}
pub fn get_cached_app_list() -> Result<Vec<SteamApp>, String> {
let boxed_result = isteam_apps::get_app_list::get_cached();
boxed_result
}
pub fn get_dota2_match_history(account_id: Option<i64>,
game_mode: Option<u8>,
skill: Option<u8>,
min_players: Option<u32>,
start_at_match_id: Option<i64>,
matches_requested: Option<u32>,
tournament_games_only: Option<bool>)
-> Result<ResponseMatchHistory, String> {
idota2match_570::get_dota2_match_history(
account_id,
game_mode,
skill,
min_players,
start_at_match_id,
matches_requested,
tournament_games_only
)
}
pub fn get_dota2_match_details(match_id: u64) -> Result<MatchResult, String> {
idota2match_570::get_dota2_match_details(match_id)
}
pub fn get_cached_dota2_match_details(match_id: u64) -> Result<MatchResult, String> {
idota2match_570::get_cached_dota2_match_details(match_id)
}
pub fn get_dota2_heroes(language: Option<String>) -> Result<Vec<Hero>, String> {
idota2match_570::get_dota2_heroes(language)
}
pub fn get_dota2_league_listing(language: Option<String>) -> Result<Vec<League>, String> {
idota2match_570::get_dota2_league_listing(language)
}
pub fn get_dota2_live_league_games() -> Result<Vec<LiveLeagueGame>, String> {
idota2match_570::get_dota2_live_league_games()
}
pub fn get_dota2_team_info_by_team_id(start_at_team_id: Option<u64>, teams_requested: Option<u32>) -> Result<Vec<TeamInfo>, String> {
idota2match_570::get_dota2_team_info_by_team_id(start_at_team_id, teams_requested)
}
pub fn get_player_summaries(steamids: Vec<u64>) -> Result<Vec<PlayerSummary>, String> {
isteam_user::get_player_summaries::get(steamids)
}
pub fn get_friend_list(steamid: u64, relationship: Option<String>) -> Result<Vec<Friend>, String> {
isteam_user::get_friend_list::get(steamid, relationship)
}
pub fn get_player_bans(steamids: Vec<u64>) -> Result<Vec<PlayerBans>, String> {
isteam_user::get_player_bans::get(steamids)
}
pub fn resolve_vanity_url(vanity_url: String, url_type: Option<u8>) -> Result<VanityUrlResolution, String> {
isteam_user::resolve_vanity_url::get(vanity_url, url_type)
}
pub fn get_owned_games(steamid: u64, include_appinfo: Option<bool>, include_played_free_games: Option<bool>) -> Result<OwnedGames, String> {
iplayer_service::get_owned_games::get(steamid, include_appinfo, include_played_free_games)
}
pub fn get_recently_played_games(steamid: u64, count: Option<u32>) -> Result<RecentlyPlayedGames, String> {
iplayer_service::get_recently_played_games::get(steamid, count)
}
pub fn get_steam_level(steamid: u64) -> Result<u64, String> {
iplayer_service::get_steam_level::get(steamid)
}
pub fn get_badges(steamid: u64) -> Result<Badges, String> {
iplayer_service::get_badges::get(steamid)
}
pub fn get_player_achievements(steamid: u64, appid: i64, language: Option<String>) -> Result<PlayerAchievements, String> {
isteam_user_stats::get_player_achievements::get(steamid, appid, language)
}
pub fn get_user_stats_for_game(steamid: u64, appid: i64) -> Result<UserStatsForGame, String> {
isteam_user_stats::get_user_stats_for_game::get(steamid, appid)
}
pub fn get_schema_for_game(appid: i64) -> Result<GameSchema, String> {
isteam_user_stats::get_schema_for_game::get(appid)
}
pub fn get_global_achievement_percentages_for_app(appid: i64) -> Result<Vec<AchievementPercentage>, String> {
isteam_user_stats::get_global_achievement_percentages_for_app::get(appid)
}
pub fn get_number_of_current_players(appid: i64) -> Result<i64, String> {
isteam_user_stats::get_number_of_current_players::get(appid)
}
pub fn get_news_for_app(appid: i64, count: Option<u32>, maxlength: Option<u32>) -> Result<Vec<NewsItem>, String> {
isteam_news::get_news_for_app::get(appid, count, maxlength)
}
pub fn convert_32bit_account_id_to_64bit(account_id_32bit: i64) -> i64 {
let valves_magic_constant = 76561197960265728;
let mut converted_to_64_bit = account_id_32bit;
converted_to_64_bit += valves_magic_constant;
converted_to_64_bit
}
pub fn convert_64bit_account_id_to_32bit(account_id_32bit: i64) -> i64 {
let valves_magic_constant = 76561197960265728;
let mut converted_to_32_bit = account_id_32bit;
converted_to_32_bit -= valves_magic_constant;
converted_to_32_bit
}
pub(crate) fn get_scheme() -> String {
"https".to_string()
}
pub(crate) fn get_host() -> String {
let host = "api.steampowered.com".to_string();
host
}
pub(crate) fn make_api_call(url: String) -> Result<String, String> {
let boxed_response = minreq::get(url).send();
if boxed_response.is_err() {
return Err("Operation timed out (API call)".to_string());
}
let raw_response : Vec<u8> = boxed_response.unwrap().into_bytes();
let response_string_boxed = String::from_utf8(raw_response);
if response_string_boxed.is_err() {
let error_message = response_string_boxed.err().unwrap().to_string();
if error_message == "invalid utf-8 sequence of 1 bytes from index 1" {
return Err("no response from API".to_string());
}
return Err("invalid utf-8 sequence".to_string());
}
let response_string: String = response_string_boxed.unwrap();
Ok(response_string)
}