Skip to content

Commit

Permalink
Quick fix: Replaced class with interface for IRetroAchievementsAuthen…
Browse files Browse the repository at this point in the history
…ticationData parameter to depend upon abstractions, not concretions
  • Loading branch information
KrystianLesniak committed Aug 25, 2023
1 parent 2e30a63 commit fee8814
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 60 deletions.
3 changes: 1 addition & 2 deletions docs/ToDo.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<h1 align="center">To Do</h1>

- Add more GuardAgainsts in Requests
- Create missing Unit Tests
- Change RetroAchievementsAuthenticationData to interface IRetroAchievementsAuthenticationData in all methods for Depend upon abstractions, not concretions
- Create missing Unit Tests
4 changes: 2 additions & 2 deletions src/RetroAchievements.Api/AchievementsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ public static class AchievementsApi
{
#region GetAchievementUnlocks
/// <inheritdoc cref="GetAchievementUnlocksRequest(int, int, int)"/>
public static async Task<GetAchievementUnlocksResponse> GetAchievementUnlocksAsync(this IRetroAchievementsHttpClient client, int achievementId, int offset = 0, int count = 50, RetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
public static async Task<GetAchievementUnlocksResponse> GetAchievementUnlocksAsync(this IRetroAchievementsHttpClient client, int achievementId, int offset = 0, int count = 50, IRetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
{
return await client.SendAsync(new GetAchievementUnlocksRequest(achievementId, offset, count), authenticationData, cancellationToken);
}

/// <inheritdoc cref="GetAchievementUnlocksRequest(int, int, int)"/>
public static GetAchievementUnlocksResponse GetAchievementUnlocks(this IRetroAchievementsHttpClient client, int achievementId, int offset = 0, int count = 50, RetroAchievementsAuthenticationData? authenticationData = null)
public static GetAchievementUnlocksResponse GetAchievementUnlocks(this IRetroAchievementsHttpClient client, int achievementId, int offset = 0, int count = 50, IRetroAchievementsAuthenticationData? authenticationData = null)
{
return client.Send(new GetAchievementUnlocksRequest(achievementId, offset, count), authenticationData);
}
Expand Down
8 changes: 4 additions & 4 deletions src/RetroAchievements.Api/ConsolesApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ public static class ConsolesApi
{
#region GetConsoleIds
/// <inheritdoc cref="GetConsoleIdsRequest()"/>
public static async Task<GetConsoleIdsResponse> GetConsoleIdsAsync(this IRetroAchievementsHttpClient client, RetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
public static async Task<GetConsoleIdsResponse> GetConsoleIdsAsync(this IRetroAchievementsHttpClient client, IRetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
{
return await client.SendAsync(new GetConsoleIdsRequest(), authenticationData, cancellationToken);
}

/// <inheritdoc cref="GetConsoleIdsRequest()"/>
public static GetConsoleIdsResponse GetConsoleIds(this IRetroAchievementsHttpClient client, RetroAchievementsAuthenticationData? authenticationData = null)
public static GetConsoleIdsResponse GetConsoleIds(this IRetroAchievementsHttpClient client, IRetroAchievementsAuthenticationData? authenticationData = null)
{
return client.Send(new GetConsoleIdsRequest(), authenticationData);
}
#endregion GetConsoleIds

#region GetGamesList
/// <inheritdoc cref="GetGamesListRequest(int, bool, bool)"/>
public static async Task<GetGamesListResponse> GetGamesListAsync(this IRetroAchievementsHttpClient client, int consoleId, bool onlyWithAchievements = false, bool getHashes = false, RetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
public static async Task<GetGamesListResponse> GetGamesListAsync(this IRetroAchievementsHttpClient client, int consoleId, bool onlyWithAchievements = false, bool getHashes = false, IRetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
{
return await client.SendAsync(new GetGamesListRequest(consoleId, onlyWithAchievements, getHashes), authenticationData, cancellationToken);
}

/// <inheritdoc cref="GetGamesListRequest(int, bool, bool)"/>
public static GetGamesListResponse GetGamesList(this IRetroAchievementsHttpClient client, int consoleId, bool onlyWithAchievements = false, bool getHashes = false, RetroAchievementsAuthenticationData? authenticationData = null)
public static GetGamesListResponse GetGamesList(this IRetroAchievementsHttpClient client, int consoleId, bool onlyWithAchievements = false, bool getHashes = false, IRetroAchievementsAuthenticationData? authenticationData = null)
{
return client.Send(new GetGamesListRequest(consoleId, onlyWithAchievements, getHashes), authenticationData);
}
Expand Down
16 changes: 8 additions & 8 deletions src/RetroAchievements.Api/FeedApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,55 +11,55 @@ public static class FeedApi
{
#region GetAchievementOfTheWeek
/// <inheritdoc cref="GetAchievementOfTheWeekRequest()"/>
public static async Task<GetAchievementOfTheWeekResponse> GetAchievementOfTheWeekAsync(this IRetroAchievementsHttpClient client, RetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
public static async Task<GetAchievementOfTheWeekResponse> GetAchievementOfTheWeekAsync(this IRetroAchievementsHttpClient client, IRetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
{
return await client.SendAsync(new GetAchievementOfTheWeekRequest(), authenticationData, cancellationToken);
}

/// <inheritdoc cref="GetAchievementOfTheWeekRequest()"/>
public static GetAchievementOfTheWeekResponse GetAchievementOfTheWeek(this IRetroAchievementsHttpClient client, RetroAchievementsAuthenticationData? authenticationData = null)
public static GetAchievementOfTheWeekResponse GetAchievementOfTheWeek(this IRetroAchievementsHttpClient client, IRetroAchievementsAuthenticationData? authenticationData = null)
{
return client.Send(new GetAchievementOfTheWeekRequest(), authenticationData);
}
#endregion GetAchievementOfTheWeek

#region GetActiveClaims
/// <inheritdoc cref="GetActiveClaimsRequest()"/>
public static async Task<GetActiveClaimsResponse> GetActiveClaimsAsync(this IRetroAchievementsHttpClient client, RetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
public static async Task<GetActiveClaimsResponse> GetActiveClaimsAsync(this IRetroAchievementsHttpClient client, IRetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
{
return await client.SendAsync(new GetActiveClaimsRequest(), authenticationData, cancellationToken);
}

/// <inheritdoc cref="GetActiveClaimsRequest()"/>
public static GetActiveClaimsResponse GetActiveClaims(this IRetroAchievementsHttpClient client, RetroAchievementsAuthenticationData? authenticationData = null)
public static GetActiveClaimsResponse GetActiveClaims(this IRetroAchievementsHttpClient client, IRetroAchievementsAuthenticationData? authenticationData = null)
{
return client.Send(new GetActiveClaimsRequest(), authenticationData);
}
#endregion GetActiveClaims

#region GetClaims
/// <inheritdoc cref="GetClaimsRequest(ClaimKind)"/>
public static async Task<GetClaimsResponse> GetClaimsAsync(this IRetroAchievementsHttpClient client, ClaimKind claimKind = ClaimKind.Completed, RetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
public static async Task<GetClaimsResponse> GetClaimsAsync(this IRetroAchievementsHttpClient client, ClaimKind claimKind = ClaimKind.Completed, IRetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
{
return await client.SendAsync(new GetClaimsRequest(claimKind), authenticationData, cancellationToken);
}

/// <inheritdoc cref="GetClaimsRequest(ClaimKind)"/>
public static GetClaimsResponse GetClaims(this IRetroAchievementsHttpClient client, ClaimKind claimKind = ClaimKind.Completed, RetroAchievementsAuthenticationData? authenticationData = null)
public static GetClaimsResponse GetClaims(this IRetroAchievementsHttpClient client, ClaimKind claimKind = ClaimKind.Completed, IRetroAchievementsAuthenticationData? authenticationData = null)
{
return client.Send(new GetClaimsRequest(claimKind), authenticationData);
}
#endregion GetClaims

#region GetTopTenUsers
/// <inheritdoc cref="GetTopTenUsersRequest()"/>
public static async Task<GetTopTenUsersResponse> GetTopTenUsersAsync(this IRetroAchievementsHttpClient client, RetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
public static async Task<GetTopTenUsersResponse> GetTopTenUsersAsync(this IRetroAchievementsHttpClient client, IRetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
{
return await client.SendAsync(new GetTopTenUsersRequest(), authenticationData, cancellationToken);
}

/// <inheritdoc cref="GetTopTenUsersRequest()"/>
public static GetTopTenUsersResponse GetTopTenUsers(this IRetroAchievementsHttpClient client, RetroAchievementsAuthenticationData? authenticationData = null)
public static GetTopTenUsersResponse GetTopTenUsers(this IRetroAchievementsHttpClient client, IRetroAchievementsAuthenticationData? authenticationData = null)
{
return client.Send(new GetTopTenUsersRequest(), authenticationData);
}
Expand Down
24 changes: 12 additions & 12 deletions src/RetroAchievements.Api/GamesApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,69 +10,69 @@ public static class GamesApi
{
#region GetAchievementCount
/// <inheritdoc cref="GetAchievementIdentifiersRequest(int)"/>
public static async Task<GetAchievementIdentifiersResponse> GetAchievementIdentifiersAsync(this IRetroAchievementsHttpClient client, int gameId, RetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
public static async Task<GetAchievementIdentifiersResponse> GetAchievementIdentifiersAsync(this IRetroAchievementsHttpClient client, int gameId, IRetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
{
return await client.SendAsync(new GetAchievementIdentifiersRequest(gameId), authenticationData, cancellationToken);
}

/// <inheritdoc cref="GetAchievementIdentifiersRequest(int)"/>
public static GetAchievementIdentifiersResponse GetAchievementIdentifiers(this IRetroAchievementsHttpClient client, int gameId, RetroAchievementsAuthenticationData? authenticationData = null)
public static GetAchievementIdentifiersResponse GetAchievementIdentifiers(this IRetroAchievementsHttpClient client, int gameId, IRetroAchievementsAuthenticationData? authenticationData = null)
{
return client.Send(new GetAchievementIdentifiersRequest(gameId), authenticationData);
}
#endregion GetAchievementCount

#region GetAchievementDistribution
/// <inheritdoc cref="GetAchievementDistributionRequest(int, bool, bool)"/>
public static async Task<GetAchievementDistributionResponse> GetAchievementDistributionAsync(this IRetroAchievementsHttpClient client, int gameId, bool hardcoreOnly = false, bool unofficialAchievements = false, RetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
public static async Task<GetAchievementDistributionResponse> GetAchievementDistributionAsync(this IRetroAchievementsHttpClient client, int gameId, bool hardcoreOnly = false, bool unofficialAchievements = false, IRetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
{
return await client.SendAsync(new GetAchievementDistributionRequest(gameId, hardcoreOnly, unofficialAchievements), authenticationData, cancellationToken);
}

/// <inheritdoc cref="GetAchievementDistributionRequest(int, bool, bool)"/>
public static GetAchievementDistributionResponse GetAchievementDistribution(this IRetroAchievementsHttpClient client, int gameId, bool hardcoreOnly = false, bool unofficialAchievements = false, RetroAchievementsAuthenticationData? authenticationData = null)
public static GetAchievementDistributionResponse GetAchievementDistribution(this IRetroAchievementsHttpClient client, int gameId, bool hardcoreOnly = false, bool unofficialAchievements = false, IRetroAchievementsAuthenticationData? authenticationData = null)
{
return client.Send(new GetAchievementDistributionRequest(gameId, hardcoreOnly, unofficialAchievements), authenticationData);
}
#endregion GetAchievementDistribution

#region GetGame
/// <inheritdoc cref="GetGameDataRequest(int)"/>
public static async Task<GetGameDataResponse> GetGameDataAsync(this IRetroAchievementsHttpClient client, int gameId, RetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
public static async Task<GetGameDataResponse> GetGameDataAsync(this IRetroAchievementsHttpClient client, int gameId, IRetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
{
return await client.SendAsync(new GetGameDataRequest(gameId), authenticationData, cancellationToken);
}

/// <inheritdoc cref="GetGameDataRequest(int)"/>
public static GetGameDataResponse GetGameData(this IRetroAchievementsHttpClient client, int gameId, RetroAchievementsAuthenticationData? authenticationData = null)
public static GetGameDataResponse GetGameData(this IRetroAchievementsHttpClient client, int gameId, IRetroAchievementsAuthenticationData? authenticationData = null)
{
return client.Send(new GetGameDataRequest(gameId), authenticationData);
}
#endregion GetGame

#region GetGameExtended
/// <inheritdoc cref="GetGameExtendedDataRequest(int)"/>
public static async Task<GetGameExtendedDataResponse> GetGameExtendedDataAsync(this IRetroAchievementsHttpClient client, int gameId, RetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
public static async Task<GetGameExtendedDataResponse> GetGameExtendedDataAsync(this IRetroAchievementsHttpClient client, int gameId, IRetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
{
return await client.SendAsync(new GetGameExtendedDataRequest(gameId), authenticationData, cancellationToken);
}

/// <inheritdoc cref="GetGameExtendedDataRequest(int)"/>
public static GetGameExtendedDataResponse GetGameExtendedData(this IRetroAchievementsHttpClient client, int gameId, RetroAchievementsAuthenticationData? authenticationData = null)
public static GetGameExtendedDataResponse GetGameExtendedData(this IRetroAchievementsHttpClient client, int gameId, IRetroAchievementsAuthenticationData? authenticationData = null)
{
return client.Send(new GetGameExtendedDataRequest(gameId), authenticationData);
}
#endregion GetGameExtended

#region GetGameRankAndScore
/// <inheritdoc cref="GetGameRankAndScoreRequest(int, RankType)"/>
public static async Task<GetGameRankAndScoreResponse> GetGameRankAndScoreAsync(this IRetroAchievementsHttpClient client, int gameId, RankType rankType = RankType.HighScores, RetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
public static async Task<GetGameRankAndScoreResponse> GetGameRankAndScoreAsync(this IRetroAchievementsHttpClient client, int gameId, RankType rankType = RankType.HighScores, IRetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
{
return await client.SendAsync(new GetGameRankAndScoreRequest(gameId, rankType), authenticationData, cancellationToken);
}

/// <inheritdoc cref="GetGameRankAndScoreRequest(int, RankType)"/>
public static GetGameRankAndScoreResponse GetGameRankAndScore(this IRetroAchievementsHttpClient client, int gameId, RankType rankType = RankType.HighScores, RetroAchievementsAuthenticationData? authenticationData = null)
public static GetGameRankAndScoreResponse GetGameRankAndScore(this IRetroAchievementsHttpClient client, int gameId, RankType rankType = RankType.HighScores, IRetroAchievementsAuthenticationData? authenticationData = null)
{
return client.Send(new GetGameRankAndScoreRequest(gameId, rankType), authenticationData);
}
Expand All @@ -81,13 +81,13 @@ public static GetGameRankAndScoreResponse GetGameRankAndScore(this IRetroAchieve
#region GetGameRating

/// <inheritdoc cref="GetGameRatingRequest(int)"/>
public static async Task<GetGameRatingResponse> GetGameRatingAsync(this IRetroAchievementsHttpClient client, int gameId, RetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
public static async Task<GetGameRatingResponse> GetGameRatingAsync(this IRetroAchievementsHttpClient client, int gameId, IRetroAchievementsAuthenticationData? authenticationData = null, CancellationToken cancellationToken = default)
{
return await client.SendAsync(new GetGameRatingRequest(gameId), authenticationData, cancellationToken);
}

/// <inheritdoc cref="GetGameRatingRequest(int)"/>
public static GetGameRatingResponse GetGameRating(this IRetroAchievementsHttpClient client, int gameId, RetroAchievementsAuthenticationData? authenticationData = null)
public static GetGameRatingResponse GetGameRating(this IRetroAchievementsHttpClient client, int gameId, IRetroAchievementsAuthenticationData? authenticationData = null)
{
return client.Send(new GetGameRatingRequest(gameId), authenticationData);
}
Expand Down
Loading

0 comments on commit fee8814

Please sign in to comment.