All the code
This commit is contained in:
32
Gameboard.ShogiUI.Sockets/Repositories/PlayerRepository.cs
Normal file
32
Gameboard.ShogiUI.Sockets/Repositories/PlayerRepository.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Gameboard.Shogi.Api.ServiceModels.Messages;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Websockets.Repositories.Utility;
|
||||
|
||||
namespace Websockets.Repositories
|
||||
{
|
||||
[Obsolete("Use GameboardRepository. Functions from PlayerRepository will be moved.")]
|
||||
public class PlayerRepository
|
||||
{
|
||||
private readonly IAuthenticatedHttpClient client;
|
||||
|
||||
public PlayerRepository(IAuthenticatedHttpClient client)
|
||||
{
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public async Task<GetPlayerResponse> GetPlayer(string playerName)
|
||||
{
|
||||
var response = await client.GetAsync($"/Player/{playerName}");
|
||||
var json = await response.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<GetPlayerResponse>(json);
|
||||
}
|
||||
|
||||
public async Task DeletePlayer(string playerName)
|
||||
{
|
||||
var response = await client.DeleteAsync($"/Player/{playerName}");
|
||||
await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user