Skip to content

Commit

Permalink
Merge pull request #25 from KrystianLesniak/develop
Browse files Browse the repository at this point in the history
Release Candidate: 1.2.0
  • Loading branch information
KrystianLesniak authored Aug 25, 2023
2 parents 0b5d447 + fee8814 commit 8bc54a6
Show file tree
Hide file tree
Showing 41 changed files with 496 additions and 3,179 deletions.
25 changes: 19 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
name: Publish
on:
workflow_dispatch:
pull_request:
push:
branches:
- 'main'
paths:
- src/*
- src/**
pull_request:
branches:
- 'develop'
- src/**
release:
types:
- published
Expand Down Expand Up @@ -66,7 +64,22 @@ jobs:
- name: Validate package
run: dotnet validate package local (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg")

run_test:
run_test_without_api:
# Release will run full tests in run_full_test
if: github.event_name != 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
- name: Run tests
working-directory: ${{ env.SlnFolderPath }}
run: |
dotnet test --configuration Release --filter TestCategory!=ApiTest
run_full_test:
# Run API Tests only when creating a GitHub Release
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -95,7 +108,7 @@ jobs:
# Publish only when creating a GitHub Release
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: [ validate_nuget, run_test ]
needs: [ validate_nuget, run_full_test ]
steps:
- uses: actions/download-artifact@v3
with:
Expand Down
41 changes: 29 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
_A C# .NET library that lets you get achievement, user, and game data from RetroAchievements._
<br><br>
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/KrystianLesniak/retroachievements-api-net/publish.yml?label=verification)
[![Coverage Status](https://coveralls.io/repos/github/KrystianLesniak/retroachievements-api-net/badge.svg)](https://coveralls.io/github/KrystianLesniak/retroachievements-api-net)
[![Coverage Status](https://coveralls.io/repos/github/KrystianLesniak/retroachievements-api-net/badge.svg?service=github&kill_cache=1)](https://coveralls.io/github/KrystianLesniak/retroachievements-api-net)
[![GitHub](https://img.shields.io/github/license/KrystianLesniak/retroachievements-api-net)](https://github.com/KrystianLesniak/retroachievements-api-net/blob/main/LICENSE)
[![Nuget](https://img.shields.io/nuget/dt/RetroAchievements.Api) ![Nuget](https://img.shields.io/nuget/vpre/RetroAchievements.Api)](https://www.nuget.org/packages/RetroAchievements.Api/)


## Features

✅ No external dependencies.
✅ Aligns 1:1 with the RAWeb API.
✅ Correctly maps types and properties from RAWeb PHP calls.
* No external dependencies.
* Supported frameworks: .NET 6.0, .NET 7.0.
* Aligns 1:1 with the RAWeb API.
* Correctly maps types and properties from RAWeb PHP calls.
* CancellationToken support.
* [IHttpClientFactory Typed Clients support](#different-usages).

******

Expand Down Expand Up @@ -85,6 +85,28 @@ class Program
}
```


## Different usages

<details>
<summary>Use with IHttpClientFactory as Typed Client</summary>

.NET documentation about using typed clients in your code can be found [here.](https://learn.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests#how-to-use-typed-clients-with-ihttpclientfactory)

To register HttpClient in DI container together with authentcation data you can use specified code:
```csharp
builder.Services.AddHttpClient<IRetroAchievementsHttpClient, RetroAchievementsHttpClient>(httpClient =>
{
var authData = new RetroAchievementsAuthenticationData("Username", "WebApiKey");
return new RetroAchievementsHttpClient(httpClient, authData);
});
```

After that ```IRetroAchievementsHttpClient``` can be injected into Controllers to be used like [in this example.](src/Examples/RetroAchievements.Api.WebApi/Controllers/RetroAchievementsController.cs)

</details>


# Requests List
#### Users
- GetAchievementsEarnedBetween(string user, DateTime from, DateTime to) - Get a list of achievements earned by a user between two dates.
Expand Down Expand Up @@ -130,11 +152,6 @@ class Program
- GetGameTicketData(int gameId) - Get ticket statistics for the specified game.
- GetAchievementTicketData(int achievementId) - Get ticket statistics for the specified achievement.

## Different usages

### With IHttpClientFactory as Typed Client
TODO: Provide example


## About
This project is heavily inspired and based on the [RetroAchievements/retroachievements-api-js](https://github.com/RetroAchievements/retroachievements-api-js) project.
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
- Add Unit Tests stage and GitHub secrets for RetroAchievements API, until then run UT locally before release
- Create missing Unit Tests
Loading

0 comments on commit 8bc54a6

Please sign in to comment.