Skip to content

Instantly share code, notes, and snippets.

@UberMouse
Created October 20, 2013 12:56
Show Gist options
  • Save UberMouse/7069255 to your computer and use it in GitHub Desktop.
Save UberMouse/7069255 to your computer and use it in GitHub Desktop.
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