Skip to content

Commit

Permalink
Updated with new fixes from GB, v2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
kamranayub committed Feb 16, 2013
1 parent 63dbd35 commit f63893a
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 83 deletions.
7 changes: 4 additions & 3 deletions GiantBomb.Api.Tests/Platforms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ public void platform_resource_should_return_platform_for_94()

Assert.IsNotNull(platform);
Assert.AreEqual(platformId, platform.Id);
Assert.AreEqual("PC", platform.Name);
Assert.AreEqual("PC", platform.Name);
Assert.AreEqual("PC", platform.Abbreviation);
Assert.IsNotNull(platform.ApiDetailUrl);
Assert.IsNotNull(platform.DateAdded);
Assert.IsNotNull(platform.DateLastUpdated);
Assert.IsTrue(platform.DateAdded > DateTime.MinValue);
Assert.IsTrue(platform.DateLastUpdated > DateTime.MinValue);
Assert.IsNotNull(platform.Deck);
Assert.IsNotNull(platform.Description);
Assert.IsNotNull(platform.Image);
Expand Down
2 changes: 2 additions & 0 deletions GiantBomb.Api.Tests/Releases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public void release_resource_should_return_release_for_29726() {
Assert.IsNotNull(release);
Assert.AreEqual(release.Id, releaseId);
Assert.IsTrue(release.Name.Contains("Morrowind"));
Assert.IsTrue(release.DateAdded > DateTime.MinValue);
Assert.IsTrue(release.DateLastUpdated > DateTime.MinValue);
Assert.IsNotNull(release.Platform, "No platform");
Assert.IsNotNull(release.Publishers, "No publishers");
Assert.IsNotNull(release.Developers, "No developers");
Expand Down
2 changes: 1 addition & 1 deletion GiantBomb.Api/GiantBomb.Api.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<description>RestSharp-based API wrapper for the GiantBomb games database public API</description>
<copyright>Copyright © kayub 2012</copyright>
<releaseNotes>
APIv2 support, contains BREAKING CHANGES. See Project Information.
Updated with fixes, see README.
</releaseNotes>
</metadata>
<files>
Expand Down
55 changes: 0 additions & 55 deletions GiantBomb.Api/Model/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,59 +33,4 @@ public class Game {
public string SiteDetailUrl { get; set; }
public List<Game> SimilarGames { get; set; }
}

/// <summary>
/// Used in lightweight responses where some properties are flattened
/// </summary>
internal class GameLite {
#region Same as Game
public int Id { get; set; }
public string Name { get; set; }
public string ApiDetailUrl { get; set; }
public DateTime DateAdded { get; set; }
public DateTime DateLastUpdated { get; set; }
public string Deck { get; set; }
public string Description { get; set; }
public int? ExpectedReleaseDay { get; set; }
public int? ExpectedReleaseMonth { get; set; }
public int? ExpectedReleaseQuarter { get; set; }
public int? ExpectedReleaseYear { get; set; }
public Image Image { get; set; }
public int NumberOfUserReviews { get; set; }
public DateTime? OriginalReleaseDate { get; set; }
public string SiteDetailUrl { get; set; }
#endregion
public string Platforms { get; set; }
}

internal static class GameExtensions {
internal static Game ToGame(this GameLite game) {
var g = new Game() {
Id = game.Id,
Name = game.Name,
ApiDetailUrl = game.ApiDetailUrl,
DateAdded = game.DateAdded,
DateLastUpdated = game.DateLastUpdated,
Deck = game.Deck,
Description = game.Description,
ExpectedReleaseDay = game.ExpectedReleaseDay,
ExpectedReleaseMonth = game.ExpectedReleaseMonth,
ExpectedReleaseQuarter = game.ExpectedReleaseQuarter,
ExpectedReleaseYear = game.ExpectedReleaseYear,
Image = game.Image,
NumberOfUserReviews = game.NumberOfUserReviews,
OriginalReleaseDate = game.OriginalReleaseDate,
SiteDetailUrl = game.SiteDetailUrl
};

// Platforms
if (!String.IsNullOrWhiteSpace(game.Platforms)) {
g.Platforms =
game.Platforms.Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries)
.Select(p => new Platform() { Name = p }).ToList();
}

return g;
}
}
}
6 changes: 3 additions & 3 deletions GiantBomb.Api/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
[assembly: ComVisible(false)]
[assembly: Guid("5d910805-e5ae-48f0-8e39-d37104d7a91e")]

[assembly: AssemblyVersion("2.0.1")]
[assembly: AssemblyFileVersion("2.0.1")]
[assembly: AssemblyInformationalVersion("2.0.1")]
[assembly: AssemblyVersion("2.0.2")]
[assembly: AssemblyFileVersion("2.0.2")]
[assembly: AssemblyInformationalVersion("2.0.2")]
4 changes: 2 additions & 2 deletions GiantBomb.Api/Resources/Games.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public Game GetGame(int id, string[] limitFields = null) {
}

public IEnumerable<Game> GetGames(int page = 1, int pageSize = GiantBombBase.DefaultLimit, string[] limitFields = null) {
var liteGames = GetListResource<GameLite>("games", page, pageSize, limitFields);
var liteGames = GetListResource<Game>("games", page, pageSize, limitFields);

if (liteGames == null) return null;

return liteGames.Select(g => g.ToGame());
return liteGames;
}
}
}
12 changes: 1 addition & 11 deletions GiantBomb.Api/Resources/Releases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,7 @@ namespace GiantBomb.Api {
public partial class GiantBombRestClient {

public Release GetRelease(int id, string[] limitFields = null) {

// Workaround until Issue#9 gets fixed
var filter = new Dictionary<string, object>()
{
{"id", id}
};

return GetListResource<Release>("releases", fieldList: limitFields, filterOptions: filter).FirstOrDefault();

// TODO Use once GB fixes their release API
// return GetSingleResource<Release>("release", ResourceTypes.Releases, id, limitFields);
return GetSingleResource<Release>("release", ResourceTypes.Releases, id, limitFields);
}

public IEnumerable<Release> GetReleasesForGame(int gameId, string[] limitFields = null)
Expand Down
10 changes: 5 additions & 5 deletions GiantBomb.Api/Resources/Search.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ public IEnumerable<Game> SearchForGames(string query, int page = 1, int pageSize
var result = InternalSearchForGames(query, page, pageSize, limitFields);

if (result.StatusCode == GiantBombBase.StatusOk)
return result.Results.Select(g => g.ToGame());
return result.Results;

return null;
}

internal GiantBombResults<GameLite> InternalSearchForGames(string query, int page = 1, int pageSize = GiantBombBase.DefaultLimit, string[] limitFields = null) {
internal GiantBombResults<Game> InternalSearchForGames(string query, int page = 1, int pageSize = GiantBombBase.DefaultLimit, string[] limitFields = null) {
var request = GetListResource("search", page, pageSize, limitFields);

request.AddParameter("query", query);
request.AddParameter("resources", "game");

return Execute<GiantBombResults<GameLite>>(request);
return Execute<GiantBombResults<Game>>(request);
}

public IEnumerable<Game> SearchForAllGames(string query, string[] limitFields = null) {
var results = new List<GameLite>();
var results = new List<Game>();
var result = InternalSearchForGames(query, limitFields: limitFields);

if (result == null || result.StatusCode != GiantBombBase.StatusOk)
Expand All @@ -48,7 +48,7 @@ public IEnumerable<Game> SearchForAllGames(string query, string[] limitFields =
}
}

return results.Select(g => g.ToGame());
return results;
}
}
}
4 changes: 1 addition & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ GiantBomb-C# 2.0+ is only compatible with GiantBomb APIv2. Keep using the old pa

### Breaking Changes/Known Issues

* Platforms return `null` for abbreviation (#11)
* Platforms `LastUpdated` is spelled incorrectly on the API (#10)
* Releases don't return all associations (#9)
* Platform/Release `DateLastUpdated` is spelled incorrectly on the API (#10)

## Readme

Expand Down

0 comments on commit f63893a

Please sign in to comment.