Skip to content
This repository was archived by the owner on Mar 16, 2025. It is now read-only.

Commit 6ef8251

Browse files
[v2] Add TMDB error response json (#153 #158)
1 parent b48f6b7 commit 6ef8251

File tree

5 files changed

+77
-32
lines changed

5 files changed

+77
-32
lines changed

src/libs/Trakt.NET.Extensions.TMDB/Internal/Json/SerializerContexts/TMDBJsonSerializerContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ namespace TraktNET
1111
[JsonSerializable(typeof(IReadOnlyList<TMDBConfigurationImages>))]
1212
[JsonSerializable(typeof(TMDBEpisodeImages))]
1313
[JsonSerializable(typeof(IReadOnlyList<TMDBEpisodeImages>))]
14+
[JsonSerializable(typeof(TMDBErrorResponse))]
15+
[JsonSerializable(typeof(IReadOnlyList<TMDBErrorResponse>))]
1416
[JsonSerializable(typeof(TMDBImage))]
1517
[JsonSerializable(typeof(IReadOnlyList<TMDBImage>))]
1618
[JsonSerializable(typeof(TMDBMovieImages))]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace TraktNET
2+
{
3+
public record class TMDBErrorResponse
4+
{
5+
public bool? Success { get; set; }
6+
7+
public uint? StatusCode { get; set; }
8+
9+
public string? StatusMessage { get; set; }
10+
}
11+
}

src/libs/Trakt.NET.Extensions.TMDB/TraktTMDBExtensions.cs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,106 +8,106 @@ public static async Task<TMDBMovieImages> GetTMDBImagesAsync(this TraktMovieMini
88
return await Task.FromResult(new TMDBMovieImages());
99
}
1010

11-
public static async Task<TMDBVideos> GetTMDBVideosAsync(this TraktMovieMinimal traktMovie, CancellationToken cancellationToken = default)
12-
{
13-
// TODO
14-
return await Task.FromResult(new TMDBVideos());
15-
}
16-
1711
public static async Task<TMDBMovieImages> GetTMDBImagesAsync(this TraktMovie traktMovie, CancellationToken cancellationToken = default)
1812
{
1913
// TODO
2014
return await Task.FromResult(new TMDBMovieImages());
2115
}
2216

23-
public static async Task<TMDBVideos> GetTMDBVideosAsync(this TraktMovie traktMovie, CancellationToken cancellationToken = default)
17+
public static async Task<TMDBShowImages> GetTMDBImagesAsync(this TraktShowMinimal traktShow, CancellationToken cancellationToken = default)
2418
{
2519
// TODO
26-
return await Task.FromResult(new TMDBVideos());
20+
return await Task.FromResult(new TMDBShowImages());
2721
}
2822

29-
public static async Task<TMDBShowImages> GetTMDBImagesAsync(this TraktShowMinimal traktShow, CancellationToken cancellationToken = default)
23+
public static async Task<TMDBShowImages> GetTMDBImagesAsync(this TraktShow traktShow, CancellationToken cancellationToken = default)
3024
{
3125
// TODO
3226
return await Task.FromResult(new TMDBShowImages());
3327
}
34-
public static async Task<TMDBVideos> GetTMDBVideosAsync(this TraktShowMinimal traktShow, CancellationToken cancellationToken = default)
28+
29+
public static async Task<TMDBSeasonImages> GetTMDBImagesAsync(this TraktSeasonMinimal traktSeason, CancellationToken cancellationToken = default)
3530
{
3631
// TODO
37-
return await Task.FromResult(new TMDBVideos());
32+
return await Task.FromResult(new TMDBSeasonImages());
3833
}
3934

40-
public static async Task<TMDBShowImages> GetTMDBImagesAsync(this TraktShow traktShow, CancellationToken cancellationToken = default)
35+
public static async Task<TMDBSeasonImages> GetTMDBImagesAsync(this TraktSeason traktSeason, CancellationToken cancellationToken = default)
4136
{
4237
// TODO
43-
return await Task.FromResult(new TMDBShowImages());
38+
return await Task.FromResult(new TMDBSeasonImages());
4439
}
4540

41+
public static async Task<TMDBEpisodeImages> GetTMDBImagesAsync(this TraktEpisodeMinimal traktEpisode, CancellationToken cancellationToken = default)
42+
{
43+
// TODO
44+
return await Task.FromResult(new TMDBEpisodeImages());
45+
}
4646

47-
public static async Task<TMDBVideos> GetTMDBVideosAsync(this TraktShow traktShow, CancellationToken cancellationToken = default)
47+
public static async Task<TMDBEpisodeImages> GetTMDBImagesAsync(this TraktEpisode traktEpisode, CancellationToken cancellationToken = default)
4848
{
4949
// TODO
50-
return await Task.FromResult(new TMDBVideos());
50+
return await Task.FromResult(new TMDBEpisodeImages());
5151
}
5252

53-
public static async Task<TMDBSeasonImages> GetTMDBImagesAsync(this TraktSeasonMinimal traktSeason, CancellationToken cancellationToken = default)
53+
public static async Task<TMDBPersonImages> GetTMDBImagesAsync(this TraktPersonMinimal traktPerson, CancellationToken cancellationToken = default)
5454
{
5555
// TODO
56-
return await Task.FromResult(new TMDBSeasonImages());
56+
return await Task.FromResult(new TMDBPersonImages());
5757
}
5858

59-
public static async Task<TMDBVideos> GetTMDBVideosAsync(this TraktSeasonMinimal traktSeason, CancellationToken cancellationToken = default)
59+
public static async Task<TMDBPersonImages> GetTMDBImagesAsync(this TraktPerson traktPerson, CancellationToken cancellationToken = default)
6060
{
6161
// TODO
62-
return await Task.FromResult(new TMDBVideos());
62+
return await Task.FromResult(new TMDBPersonImages());
6363
}
6464

65-
public static async Task<TMDBSeasonImages> GetTMDBImagesAsync(this TraktSeason traktSeason, CancellationToken cancellationToken = default)
65+
public static async Task<TMDBVideos> GetTMDBVideosAsync(this TraktMovieMinimal traktMovie, CancellationToken cancellationToken = default)
6666
{
6767
// TODO
68-
return await Task.FromResult(new TMDBSeasonImages());
68+
return await Task.FromResult(new TMDBVideos());
6969
}
7070

71-
public static async Task<TMDBVideos> GetTMDBVideosAsync(this TraktSeason traktSeason, CancellationToken cancellationToken = default)
71+
public static async Task<TMDBVideos> GetTMDBVideosAsync(this TraktMovie traktMovie, CancellationToken cancellationToken = default)
7272
{
7373
// TODO
7474
return await Task.FromResult(new TMDBVideos());
7575
}
7676

77-
public static async Task<TMDBEpisodeImages> GetTMDBImagesAsync(this TraktEpisodeMinimal traktEpisode, CancellationToken cancellationToken = default)
77+
public static async Task<TMDBVideos> GetTMDBVideosAsync(this TraktShowMinimal traktShow, CancellationToken cancellationToken = default)
7878
{
7979
// TODO
80-
return await Task.FromResult(new TMDBEpisodeImages());
80+
return await Task.FromResult(new TMDBVideos());
8181
}
8282

83-
public static async Task<TMDBVideos> GetTMDBVideosAsync(this TraktEpisodeMinimal traktEpisode, CancellationToken cancellationToken = default)
83+
public static async Task<TMDBVideos> GetTMDBVideosAsync(this TraktShow traktShow, CancellationToken cancellationToken = default)
8484
{
8585
// TODO
8686
return await Task.FromResult(new TMDBVideos());
8787
}
8888

89-
public static async Task<TMDBEpisodeImages> GetTMDBImagesAsync(this TraktEpisode traktEpisode, CancellationToken cancellationToken = default)
89+
public static async Task<TMDBVideos> GetTMDBVideosAsync(this TraktSeasonMinimal traktSeason, CancellationToken cancellationToken = default)
9090
{
9191
// TODO
92-
return await Task.FromResult(new TMDBEpisodeImages());
92+
return await Task.FromResult(new TMDBVideos());
9393
}
9494

95-
public static async Task<TMDBVideos> GetTMDBVideosAsync(this TraktEpisode traktEpisode, CancellationToken cancellationToken = default)
95+
public static async Task<TMDBVideos> GetTMDBVideosAsync(this TraktSeason traktSeason, CancellationToken cancellationToken = default)
9696
{
9797
// TODO
9898
return await Task.FromResult(new TMDBVideos());
9999
}
100100

101-
public static async Task<TMDBPersonImages> GetTMDBImagesAsync(this TraktPersonMinimal traktPerson, CancellationToken cancellationToken = default)
101+
public static async Task<TMDBVideos> GetTMDBVideosAsync(this TraktEpisodeMinimal traktEpisode, CancellationToken cancellationToken = default)
102102
{
103103
// TODO
104-
return await Task.FromResult(new TMDBPersonImages());
104+
return await Task.FromResult(new TMDBVideos());
105105
}
106106

107-
public static async Task<TMDBPersonImages> GetTMDBImagesAsync(this TraktPerson traktPerson, CancellationToken cancellationToken = default)
107+
public static async Task<TMDBVideos> GetTMDBVideosAsync(this TraktEpisode traktEpisode, CancellationToken cancellationToken = default)
108108
{
109109
// TODO
110-
return await Task.FromResult(new TMDBPersonImages());
110+
return await Task.FromResult(new TMDBVideos());
111111
}
112112
}
113113
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"success": false,
3+
"status_code": 6,
4+
"status_message": "Invalid id: The pre-requisite id is invalid or not found."
5+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace TraktNET.Json
2+
{
3+
public sealed class TMDBErrorResponseTests
4+
{
5+
[Fact]
6+
public void TestTMDBErrorResponseConstructor()
7+
{
8+
var errorResponse = new TMDBErrorResponse();
9+
10+
errorResponse.Success.ShouldBeNull();
11+
errorResponse.StatusCode.ShouldBeNull();
12+
errorResponse.StatusMessage.ShouldBeNull();
13+
}
14+
15+
[Fact]
16+
public async Task TestTMDBErrorResponseFromJson()
17+
{
18+
TMDBErrorResponse? errorResponse = await TMDBTestUtility.DeserializeJsonAsync<TMDBErrorResponse>("errorresponse.json");
19+
20+
errorResponse.ShouldNotBeNull();
21+
22+
errorResponse!.Success.ShouldBe(false);
23+
errorResponse!.StatusCode.ShouldBe(6U);
24+
errorResponse!.StatusMessage.ShouldBe("Invalid id: The pre-requisite id is invalid or not found.");
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)