Skip to content

Commit

Permalink
Close #8
Browse files Browse the repository at this point in the history
Welcome nuget and fixed that achievements are output under screenshots!
  • Loading branch information
liebki committed Aug 18, 2022
1 parent 77016aa commit 8c6ef53
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 11 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ A wrapper for the API of wrag.io, to get a game including all it's data
### Created using
- .NET Core 6.0

### Nuget(s)
- Newtonsoft.Json (Needs to be added to your project too, until I figure out why)
### Nugets/Dependencies used
- Newtonsoft.Json

## Features

### New
- Thanks to sgamesdev, I got reminded that the screenshots are missing too, those are included by now
- A nuget package exists now, no more problems: https://www.nuget.org/packages/RawgNET

### General
- Get a "Game" object including the complete data like images, description, achievements, screenshots and many more things..
Expand Down Expand Up @@ -42,7 +42,7 @@ using (RawgClient client = new(new RawgClientOptions("YOUR KEY FROM https://rawg
Console.WriteLine($"Screenshots {Environment.NewLine}--------------");
foreach (Screenshot item in game.Screenshots)
{
Console.WriteLine($"------ {Environment.NewLine} Id: {item.Id} {Environment.NewLine} Url: {item.Image} {Environment.NewLine} Image: {item.Image} {Environment.NewLine}");
Console.WriteLine($"------ {Environment.NewLine} Id: {item.Id} {Environment.NewLine} Url: {item.Image} {Environment.NewLine} Dimension: {item.Width}x{item.Height} {Environment.NewLine}");
}
}
else
Expand Down Expand Up @@ -74,7 +74,5 @@ At https://rawg.io/apidocs just press the "Get API Key" button.

## Roadmap

- Make code more clean especially the ""RawgRequest"" method!
- Clean up the messy RawgAccessManager
- Export "Newtonsoft.Json" nuget package with library
- Clean up the messy RawgAccessManager!
- More to come..
20 changes: 19 additions & 1 deletion RawgNET/RawgAccessManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private static async Task<AchievementResult> QueryMoreAchievements(string page)

private static async Task<ScreenshotResult> QueryScreenshots(string gamename, string rawgkey)
{
string RawgRequestUrl = GameNameToAchievementQueryUrl(gamename, rawgkey);
string RawgRequestUrl = GameNameToScreenshotQueryUrl(gamename, rawgkey);
string JsonResponse = "";
using (HttpClient Client = new())
{
Expand Down Expand Up @@ -231,6 +231,24 @@ private static async Task<Game> QueryGame(string gamename, string rawgkey)
return DeserializeGameJson(JsonResponse);
}

/// <summary>
/// Method to build a ready-to-query url (screenshots)
/// </summary>
/// <param name="gamename">Name of the game we'd like to query</param>
/// <param name="rawgkey">Your API-Key</param>
/// <returns></returns>
private static string GameNameToScreenshotQueryUrl(string gamename, string rawgkey)
{
string GameName = gamename;
GameName = GameName.ToLower();
if (gamename.Contains(' '))
{
GameName = GameName.Replace(" ", "-");
}
string reqUrl = RawgApiBaseUrl + GameName + $"/screenshots?key={rawgkey}";
return reqUrl;
}

/// <summary>
/// Method to build a ready-to-query url (achievements)
/// </summary>
Expand Down
14 changes: 13 additions & 1 deletion RawgNET/RawgNET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,27 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.0.4</Version>
<Version>0.0.5</Version>
<Title>RawgNet</Title>
<Authors>liebki</Authors>
<Copyright>liebki</Copyright>
<PackageProjectUrl>https://github.com/liebki/RawgNET</PackageProjectUrl>
<RepositoryUrl>https://github.com/liebki/RawgNET</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Description>A wrapper for the API of wrag.io, to get a game including all it's data</Description>
<IncludeSymbols>False</IncludeSymbols>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\..\..\Desktop\LICENSE.txt">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion RawgNetDemo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private static void Main(string[] args)
Console.WriteLine($"Screenshots {Environment.NewLine}--------------");
foreach (Screenshot item in game.Screenshots)
{
Console.WriteLine($"------ {Environment.NewLine} Id: {item.Id} {Environment.NewLine} Url: {item.Image} {Environment.NewLine} Image: {item.Image} {Environment.NewLine}");
Console.WriteLine($"------ {Environment.NewLine} Id: {item.Id} {Environment.NewLine} Url: {item.Image} {Environment.NewLine} Dimension: {item.Width}x{item.Height} {Environment.NewLine}");
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion RawgNetDemo/RawgNetDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.0.4</Version>
<Version>0.0.5</Version>
<Title>RawgNetDemo</Title>
<Authors>liebki</Authors>
<Copyright>liebki</Copyright>
Expand Down

0 comments on commit 8c6ef53

Please sign in to comment.