public void CannotGetGroupMembersLeaderboardStandingsWithIncorrectActorType() { var key = "Leaderboard_CannotGetGroupMembersWithIncorrectActorType"; var loggedInAccount = Helpers.CreateAndLoginGlobal(Fixture.SUGARClient, key); var game = Helpers.GetGame(Fixture.SUGARClient.Game, key); var gameData = new EvaluationDataRequest { Key = key, EvaluationDataType = EvaluationDataType.Long, CreatingActorId = loggedInAccount.User.Id, Value = "5", GameId = game.Id }; Fixture.SUGARClient.GameData.Add(gameData); var standingsRequest = new LeaderboardStandingsRequest { LeaderboardToken = key, GameId = game.Id, ActorId = loggedInAccount.User.Id, LeaderboardFilterType = LeaderboardFilterType.GroupMembers, PageLimit = 10, PageOffset = 0 }; Assert.Throws <ClientHttpException>(() => Fixture.SUGARClient.Leaderboard.CreateGetLeaderboardStandings(standingsRequest)); }
public void CanGetGlobalLeaderboardStandings() { var key = "Leaderboard_CanGetGlobalLeaderboardStandings"; var loggedInAccount = Helpers.CreateAndLoginGlobal(Fixture.SUGARClient, key); var gameData = new EvaluationDataRequest { Key = key, EvaluationDataType = EvaluationDataType.Long, CreatingActorId = loggedInAccount.User.Id, Value = "5", GameId = Platform.GlobalGameId }; Fixture.SUGARClient.GameData.Add(gameData); var standingsRequest = new LeaderboardStandingsRequest { LeaderboardToken = key, LeaderboardFilterType = LeaderboardFilterType.Top, PageLimit = 10, PageOffset = 0, GameId = Platform.GlobalGameId, MultiplePerActor = false }; var standingsResponse = Fixture.SUGARClient.Leaderboard.CreateGetLeaderboardStandings(standingsRequest); Assert.Equal(1, standingsResponse.Count()); Assert.Equal(loggedInAccount.User.Name, standingsResponse.First().ActorName); }
public IActionResult GetLeaderboardStandings([FromBody] LeaderboardStandingsRequest leaderboardDetails) { var leaderboard = _leaderboardController.Get(leaderboardDetails.LeaderboardToken, leaderboardDetails.GameId.Value); var standings = _leaderboardController.GetStandings(leaderboard, leaderboardDetails.ToCore()); var standingsContract = standings.ToContractList(); return(new ObjectResult(standingsContract)); }
public static StandingsRequest ToCore(this LeaderboardStandingsRequest standingsContract) { return(new StandingsRequest { LeaderboardToken = standingsContract.LeaderboardToken, GameId = standingsContract.GameId.Value, ActorId = standingsContract.ActorId, LeaderboardFilterType = standingsContract.LeaderboardFilterType.Value, PageLimit = standingsContract.PageLimit.Value, PageOffset = standingsContract.PageOffset.Value, MultiplePerActor = standingsContract.MultiplePerActor.Value, DateStart = standingsContract.DateStart, DateEnd = standingsContract.DateEnd }); }
public void CannotGetLeaderboardStandingsWithoutGameId() { var key = "Leaderboard_CannotGetStandingsWithoutGameId"; Helpers.CreateAndLoginGlobal(Fixture.SUGARClient, key); var standingsRequest = new LeaderboardStandingsRequest { LeaderboardToken = key, LeaderboardFilterType = LeaderboardFilterType.Top, PageLimit = 10, PageOffset = 0 }; Assert.Throws <ClientHttpException>(() => Fixture.SUGARClient.Leaderboard.CreateGetLeaderboardStandings(standingsRequest)); }
/// <summary> /// Gathers the current standings in relation to the actor with the id provided using the filter, multiplePerActor, pageNumber and positionCount settings provided for the leaderboard provided. /// </summary> /// <param name="leaderboard">The leaderboard standings are being gathered for</param> /// <param name="actorId">The id of the actor the current standings are being gathered for</param> /// <param name="filter">The Filter type to order standings by</param> /// <param name="multiplePerActor">If the leaderboard allows for actors to appear multiple times</param> /// <param name="pageNumber">The page offset to gather positions from</param> /// <param name="positionCount">The amount of positions to gather standings for</param> /// <param name="standings">Callback which returns the Leaderboard standings</param> public void GetLeaderboardStandings(LeaderboardResponse leaderboard, int actorId, LeaderboardFilterType filter, bool multiplePerActor, int pageNumber, int positionCount, Action <List <LeaderboardStandingsResponse> > standings) { SUGARManager.unity.StartSpinner(); if (SUGARManager.UserSignedIn && leaderboard != null) { var request = new LeaderboardStandingsRequest { LeaderboardToken = leaderboard.Token, GameId = leaderboard.GameId, ActorId = actorId, LeaderboardFilterType = filter, PageLimit = positionCount, PageOffset = pageNumber, MultiplePerActor = filter != LeaderboardFilterType.Near ? multiplePerActor : false }; SUGARManager.client.Leaderboard.CreateGetLeaderboardStandingsAsync(request, response => { SUGARManager.unity.StopSpinner(); var leaderboardStandingsResponses = response.ToList(); foreach (var r in leaderboardStandingsResponses) { if (leaderboard.LeaderboardType == LeaderboardType.Earliest || leaderboard.LeaderboardType == LeaderboardType.Latest) { r.Value = DateTime.Parse(r.Value).ToString(Localization.SelectedLanguage); } } response = leaderboardStandingsResponses.Where(r => r.Ranking > 0); standings(response.ToList()); }, exception => { SUGARManager.unity.StopSpinner(); Debug.LogError($"Failed to get leaderboard standings. {exception}"); standings(null); }); } else { SUGARManager.unity.StopSpinner(); standings(null); } }
public void CanGetMultipleLeaderboardStandingsForActor() { var key = "Leaderboard_CanGetMultipleLeaderboardStandingsForActor"; var loggedInAccount = Helpers.CreateAndLoginGlobal(Fixture.SUGARClient, key); var game = Helpers.GetGame(Fixture.SUGARClient.Game, key); var count = 10; for (var i = 1; i < count + 1; i++) { var gameData = new EvaluationDataRequest { Key = key, EvaluationDataType = EvaluationDataType.Long, CreatingActorId = loggedInAccount.User.Id, Value = i.ToString(), GameId = game.Id }; Fixture.SUGARClient.GameData.Add(gameData); } var standingsRequest = new LeaderboardStandingsRequest { LeaderboardToken = key, LeaderboardFilterType = LeaderboardFilterType.Top, PageLimit = 10, PageOffset = 0, GameId = game.Id, MultiplePerActor = true }; var standingsResponse = Fixture.SUGARClient.Leaderboard.CreateGetLeaderboardStandings(standingsRequest); Assert.Equal(count, standingsResponse.Count()); Assert.Equal(count.ToString(), standingsResponse.First().Value); }
public void CreateGetLeaderboardStandingsAsync(LeaderboardStandingsRequest leaderboardDetails, Action <IEnumerable <LeaderboardStandingsResponse> > onSuccess, Action <Exception> onError) { AsyncRequestController.EnqueueRequest(() => CreateGetLeaderboardStandings(leaderboardDetails), onSuccess, onError); }
/// <summary> /// Get the standings for a Leaderboard using a <see cref="LeaderboardStandingsRequest"/>. /// </summary> /// <param name="leaderboardDetails"><see cref="LeaderboardStandingsRequest"/> object that holds the details that are wanted from the Leaderboard.</param> /// <returns>Returns multiple <see cref="LeaderboardStandingsResponse"/> that hold actor positions in the leaderboard.</returns> public IEnumerable <LeaderboardStandingsResponse> CreateGetLeaderboardStandings(LeaderboardStandingsRequest leaderboardDetails) { var query = GetUriBuilder(ControllerPrefix + "/standings").ToString(); return(Post <LeaderboardStandingsRequest, IEnumerable <LeaderboardStandingsResponse> >(query, leaderboardDetails)); }