Created
October 20, 2013 12:56
-
-
Save UberMouse/7069255 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IEnumerable<Game> GetAppInfos(params string[] appIds) | |
{ | |
var response = _httpClient.Get(API_ENDPOINT + string.Join(",", appIds)).StaticBody<Dictionary<string, StoreApiResponse>>(); | |
foreach (var id in appIds) | |
{ | |
yield return _parseGame(response[id], id); | |
} | |
} | |
private Game _parseGame(StoreApiResponse appInfo, string appId) | |
{ | |
if (!appInfo.Success) return new Game {Success = false}; | |
const string MultiPlayerId = "1"; | |
const string CoopId = "9"; | |
var categories = appInfo.Data.Categories; | |
var coop = categories.Any(x => x.Id == CoopId); | |
var mp = categories.Any(x => x.Id == MultiPlayerId); | |
return new Game {AppId = appId, Coop = coop, Multiplayer = mp, Name = appInfo.Data.Name}; | |
} | |
class StoreApiResponse | |
{ | |
public bool Success { get; set; } | |
public StoreApiData Data { get; set; } | |
} | |
class StoreApiData | |
{ | |
public List<StoreApiCategory> Categories { get; set; } | |
public string Name { get; set; } | |
} | |
class StoreApiCategory | |
{ | |
public string Id { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment