예제 #1
0
        private async Task <GameLibrary> FetchGameLibraryAsync(string userId)
        {
            var url     = SteamUtils.GetOwnedGamesUrl(_secrets.Value.SteamApiKey, userId);
            var jsonObj = await _remoteApiService.GetJsonObjectAsync(url, SteamUtils.ApiName);

            var games = jsonObj["response"]["games"]
                        ?.Children()
                        .Select(token => token.ToObject <PlayedGame>())
                        .ToList();

            if (games == null)
            {
                throw new LibraryUnavailableException("Could not access library.", userId);
            }

            return(new GameLibrary
            {
                UserId = userId,
                Games = games,
                LatestUpdate = DateTime.Now
            });
        }