Drinks: models and boilerplate

This commit is contained in:
2020-03-05 18:17:45 +01:00
parent 9735a0d5a0
commit da67b8eda2
11 changed files with 305 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ namespace EstusShots.Client
public Seasons Seasons { get; }
public Episodes Episodes { get; }
public Players Players { get; }
public Drinks Drinks { get; }
/// <summary>
/// Creates a new instance of <see cref="EstusShotsClient"/>
@@ -37,6 +38,7 @@ namespace EstusShots.Client
Seasons = new Seasons(this);
Episodes = new Episodes(this);
Players = new Players(this);
Drinks = new Drinks(this);
}
/// <summary>

View File

@@ -0,0 +1,34 @@
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
{
/// <inheritdoc/>
public class Drinks : IDrinksController
{
private readonly EstusShotsClient _client;
public Drinks(EstusShotsClient client)
{
_client = client;
}
private string ActionUrl([CallerMemberName]string caller = "") =>
$"{_client.ApiUrl}{GetType().Name}/{caller}";
/// <inheritdoc/>
public async Task<ApiResponse<GetDrinksResponse>> GetDrinks(GetDrinksParameter parameter)
=> await _client.PostToApi<GetDrinksResponse, GetDrinksParameter>(ActionUrl(), parameter);
/// <inheritdoc/>
public async Task<ApiResponse<GetDrinkDetailsResponse>> GetDrinkDetails(GetDrinkDetailsParameter parameter)
=> await _client.PostToApi<GetDrinkDetailsResponse, GetDrinkDetailsParameter>(ActionUrl(), parameter);
/// <inheritdoc/>
public async Task<ApiResponse<SaveDrinkResponse>> SaveDrink(SaveDrinkParameter parameter)
=> await _client.PostToApi<SaveDrinkResponse, SaveDrinkParameter>(ActionUrl(), parameter);
}
}