Client methods for enemies

This commit is contained in:
2020-03-07 11:01:07 +01:00
parent 2e7aed8d49
commit 9d53da530a
2 changed files with 35 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,33 @@
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 Enemies : IEnemiesController
{
private readonly EstusShotsClient _client;
public Enemies(EstusShotsClient client)
{
_client = client;
}
public async Task<ApiResponse<GetEnemiesResponse>> GetEnemies(GetEnemiesParameter parameter)
=> await _client.PostToApi<GetEnemiesResponse, GetEnemiesParameter>(ActionUrl(), parameter);
public async Task<ApiResponse<GetEnemyResponse>> GetEnemy(GetEnemyParameter parameter)
=> await _client.PostToApi<GetEnemyResponse, GetEnemyParameter>(ActionUrl(), parameter);
public async Task<ApiResponse<SaveEnemyResponse>> SaveEnemy(SaveEnemyParameter parameter)
=> await _client.PostToApi<SaveEnemyResponse, SaveEnemyParameter>(ActionUrl(), parameter);
public async Task<ApiResponse<DeleteEnemyResponse>> DeleteEnemy(DeleteEnemyParameter parameter)
=> await _client.PostToApi<DeleteEnemyResponse, DeleteEnemyParameter>(ActionUrl(), parameter);
private string ActionUrl([CallerMemberName]string caller = "") =>
$"{_client.ApiUrl}{GetType().Name}/{caller}";
}
}