public async Task <bool> CatchThief(int userId) { var response = new HttpClientResponse(); await response.Convert(HttpClientRequestService.Patch($"users/{userId}/catch")); return(response.IsSuccessful); }
public async Task <Game> GetGame(int gameId) { HttpClientResponse response = new HttpClientResponse(); await response.Convert(HttpClientRequestService.Get($"games/{gameId}")); return(new GameJsonService().ToObject(response.ResponseContent)); }
public async Task <bool> Create(string message, int gameId, int?userId) { var response = new HttpClientResponse(); object parameters; if (userId == null) { parameters = new { message = message, }; } else { parameters = new { message = message, user_id = userId, } }; await response.Convert(HttpClientRequestService.Create($"games/{gameId}/notifications", parameters)); return(response.IsSuccessful); } }
public async Task <bool> UseGadget(int playerId, string gadgetName) { var response = new HttpClientResponse(); await response.Convert(HttpClientRequestService.Patch($"users/{playerId}/gadgets/{gadgetName}")); return(response.IsSuccessful); }
public async Task <bool> TriggerAlarm(int playerId) { var response = new HttpClientResponse(); await response.Convert(HttpClientRequestService.Create($"users/{playerId}/trigger-alarm", new { })); return(response.IsSuccessful); }
public async Task <bool> UpdatePoliceScore(int gameId, int score) { var response = new HttpClientResponse(); await response.Convert(HttpClientRequestService.Patch($"games/{gameId}/police-score/{score}")); return(response.IsSuccessful); }
public async Task <bool> Delete(int lootId) { var response = new HttpClientResponse(); await response.Convert(HttpClientRequestService.Delete($"loot/{lootId}")); return(response.IsSuccessful); }
public async void Create(PusherException e) { var response = new HttpClientResponse(); await response.Convert(HttpClientRequestService.Create("app-errors", new { error_id = GetErrorId(e), message = e.Message ?? DEFAULT_MESSAGE + " [PUSHER ERROR]", stacktrace = e.StackTrace ?? DEFAULT_STACKTRACE + " [PUSHER ERROR]" })); }
public async Task <bool> Update(int userId, Location location) { var response = new HttpClientResponse(); await response.Convert(HttpClientRequestService.Put($"users/{userId}", new { location = location.ToCsvString() })); return(response.ResponseContent != null); }
public async Task <Player> Create(Player player) { var response = new HttpClientResponse(); await response.Convert(HttpClientRequestService.Create("users", new { username = player.UserName, invite_key = player.InviteKey.Value, })); Player newPlayer = new PlayerJsonService().ToObject(response.ResponseContent, player.InviteKey).ToPlayer(); newPlayer.ErrorMessages = response.ErrorMessages; return(newPlayer); }
// Get all loot that is linked to a game public async Task <List <Loot> > GetAll(int gameId) { var response = new HttpClientResponse() { HasMultipleResults = true, }; await response.Convert(HttpClientRequestService.Get($"games/{gameId}/loot")); var result = new List <Loot>( new LootJsonService().ToObjects(response.ResponseContent) ); return(result); }
public async Task <List <PlayerBuilder> > GetAll(int gameId) { var response = new HttpClientResponse(); await response.Convert(HttpClientRequestService.GetAll($"games/{gameId}/gadgets")); List <PlayerBuilder> playersWithGadgets = new List <PlayerBuilder>(); foreach (PlayerBuilder player in new PlayerJsonService().ToObjects(response.ResponseContent)) { playersWithGadgets.Add(player); } return(playersWithGadgets); }
public async Task <List <Location> > GetAll(int gameId) { var response = new HttpClientResponse() { HasMultipleResults = true, }; await response.Convert(HttpClientRequestService.GetAll($"games/{gameId}/border-markers")); List <Location> result = new List <Location>( new LocationJsonService().ToObjects(response.ResponseContent) ); return(result); }
public async Task <Player> GetUser(int userId, int gameId) { HttpClientResponse response = new HttpClientResponse(); await response.Convert(HttpClientRequestService.Get($"users/{userId}")); if (response.Status == System.Net.HttpStatusCode.NotFound) { return(null); } var user = new PlayerJsonService().ToObject(response.ResponseContent); user.InviteKey.GameId = gameId; return(user.ToPlayer()); }
// Get all users that are linked to a game public async Task <List <Player> > GetAll(int gameId) { var usersResponse = new HttpClientResponse() { HasMultipleResults = true, }; await usersResponse.Convert(HttpClientRequestService.GetAll($"games/{gameId}/users-with-role")); var result = new List <Player>(); foreach (var builder in new PlayerJsonService().ToObjects(usersResponse.ResponseContent)) { result.Add(builder.ToPlayer()); } return(result); }
public async Task <List <InviteKey> > GetAll(int gameId) { var response = new HttpClientResponse(); response.HasMultipleResults = true; await response.Convert(HttpClientRequestService.GetAll($"games/{gameId}/invite-keys")); List <InviteKey> inviteKeys = new List <InviteKey>(); foreach (InviteKey inviteKey in new InviteKeyJsonService().ToObjects(response.ResponseContent)) { inviteKey.GameId = gameId; inviteKeys.Add(inviteKey); } return(inviteKeys); }
public async Task <List <InviteKey> > GetAll(string inviteCode) { var response = new HttpClientResponse(); await response.Convert(HttpClientRequestService.Get($"invite-keys/{inviteCode}")); List <InviteKey> result = new List <InviteKey>(); InviteKey key = new InviteKeyJsonService().ToObject(response.ResponseContent); key.Value = inviteCode; if (string.IsNullOrEmpty(key.Role)) { key.ErrorMessages = response.ErrorMessages.Count() > 0 ? response.ErrorMessages : new Dictionary <string, string>() { { "value", response.Status == HttpStatusCode.NotFound ? "De code is niet gevonden" : "Er is iets misgegaan" } }; } result.Add(key); return(result); }