This repository has been archived by the owner on Apr 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Removes Refit * Uses JSON source generated contexts * Publishes trimmed objects
- Loading branch information
Marcos Cordeiro
committed
Mar 2, 2024
1 parent
c10ff59
commit 720f96f
Showing
14 changed files
with
99 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Text.Json.Serialization; | ||
using Wasari.Tvdb.Abstractions; | ||
using Wasari.Tvdb.Api.Services; | ||
|
||
namespace Wasari.Tvdb.Api; | ||
|
||
[JsonSerializable(typeof(IEnumerable<WasariTvdbEpisode>))] | ||
[JsonSerializable(typeof(TvdbApiErrorResponse))] | ||
internal partial class WasariTvdbApiResponseSourceContext : JsonSerializerContext; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Wasari.Tvdb.Models; | ||
|
||
public interface ITvdbApi | ||
{ | ||
Task<TvdbResponse<IReadOnlyList<TvdbSearchResponseSeries>>?> SearchAsync(string query, string type = "series"); | ||
|
||
Task<TvdbResponse<TvdbSeries>?> GetSeriesAsync(string id, string seasonType = "default", string lang = "eng", | ||
int page = 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Wasari.Tvdb.Models; | ||
|
||
public record TvdbLoginRequest([property: JsonPropertyName("apikey")] string ApiKey, [property: JsonPropertyName("pin")] string Pin); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Wasari.Tvdb.Models; | ||
|
||
[JsonSourceGenerationOptions(WriteIndented = true)] | ||
[JsonSerializable(typeof(TvdbResponse<IReadOnlyList<TvdbSearchResponseSeries>>))] | ||
[JsonSerializable(typeof(TvdbResponse<TvdbSeries>))] | ||
[JsonSerializable(typeof(TvdbResponse<TvdbTokenResponseData?>))] | ||
[JsonSerializable(typeof(TvdbLoginRequest))] | ||
internal partial class TvdbSourceGenerationContext : JsonSerializerContext | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Net.Http.Json; | ||
using Wasari.Tvdb.Models; | ||
|
||
namespace Wasari.Tvdb; | ||
|
||
internal class TvdbApi : ITvdbApi | ||
{ | ||
private readonly HttpClient _httpClient; | ||
|
||
public TvdbApi(HttpClient httpClient) | ||
{ | ||
_httpClient = httpClient; | ||
} | ||
|
||
public Task<TvdbResponse<IReadOnlyList<TvdbSearchResponseSeries>>?> SearchAsync(string query, | ||
string type = "series") | ||
{ | ||
var url = $"/v4/search?query={query}&type={type}"; | ||
return _httpClient.GetFromJsonAsync(url, TvdbSourceGenerationContext.Default.TvdbResponseIReadOnlyListTvdbSearchResponseSeries); | ||
} | ||
|
||
public Task<TvdbResponse<TvdbSeries>?> GetSeriesAsync(string id, string seasonType = "default", string lang = "eng", | ||
int page = 0) | ||
{ | ||
var url = $"/v4/series/{id}/episodes/{seasonType}/{lang}?page={page}"; | ||
return _httpClient.GetFromJsonAsync(url, TvdbSourceGenerationContext.Default.TvdbResponseTvdbSeries); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters