public async Task <bool> GetUserByIdAsync(ulong steamId, ApplicationPlayerDetails toFill) { if (!IsApiKeySet()) { return(false); } toFill.SteamId = steamId; toFill.EverythingLoaded = false; try { // Player profile var playerSummaryResponse = await _steamUser.GetPlayerSummaryAsync(steamId); toFill.PlayerProfile = playerSummaryResponse.Data; // Friend list var friendListResponse = await _steamUser.GetFriendsListAsync(steamId); toFill.Friends = friendListResponse.Data.Select(x => x.SteamId).ToList(); // Owned games var ownedGamesResponse = await _steamPlayerService.GetOwnedGamesAsync(steamId); toFill.OwnedGames = ownedGamesResponse.Data; toFill.EverythingLoaded = true; return(true); } catch (SteamIdNotConstructedException) { return(false); } }
private async void LoadSteamDetailsAsync() { if (!IsApiKeySet()) { return; } _steamWeb = new SteamWebInterfaceFactory(Settings.ApiKey); _steamUser = _steamWeb.CreateSteamWebInterface <SteamUser>(); _steamPlayerService = _steamWeb.CreateSteamWebInterface <PlayerService>(); _steamStore = _steamWeb.CreateSteamStoreInterface(); PlayerDetails = new ApplicationPlayerDetails(); if (IsUsernameSet()) { if (!await UpdateProfile(Settings.Username)) { ApplicationConstants.MessageInvalidUsername(); Settings.Username = null; } } FetchApps(); }
public async Task <bool> UpdateProfile(string username) { if (!IsApiKeySet()) { ApplicationConstants.MessageApiNotSet(); return(false); } try { var vanityResolveResponse = await _steamUser.ResolveVanityUrlAsync(username); PlayerDetails = new ApplicationPlayerDetails(); await GetUserByIdAsync(vanityResolveResponse.Data, PlayerDetails); return(true); } catch (VanityUrlNotResolvedException) { return(false); } }