Add episodes controller

This commit is contained in:
2020-02-29 16:01:22 +01:00
parent 0cef2e3df2
commit 54c0fb2fd2
10 changed files with 190 additions and 23 deletions

View File

@@ -21,6 +21,7 @@ namespace EstusShots.Client
// API Routes
public Seasons Seasons { get; }
public Episodes Episodes { get; }
/// <summary>
/// Creates a new instance of <see cref="EstusShotsClient"/>
@@ -32,6 +33,7 @@ namespace EstusShots.Client
HttpClient = new HttpClient {Timeout = TimeSpan.FromSeconds(10)};
Seasons = new Seasons(this);
Episodes = new Episodes(this);
}
/// <summary>

View File

@@ -0,0 +1,24 @@
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using EstusShots.Shared.Interfaces;
using EstusShots.Shared.Models;
using EstusShots.Shared.Models.Parameters;
namespace EstusShots.Client.Routes
{
public class Episodes : IEpisodesController
{
private readonly EstusShotsClient _client;
public Episodes(EstusShotsClient client)
{
_client = client;
}
private string ActionUrl([CallerMemberName]string caller = "") =>
$"{_client.ApiUrl}{nameof(Episodes)}/{caller}";
public async Task<ApiResponse<GetEpisodesResponse>> GetEpisodes(GetEpisodesParameter parameter)
=> await _client.PostToApi<GetEpisodesResponse, GetEpisodesParameter>(ActionUrl(), parameter);
}
}