private static async Task ExecutePlayerStats(IRealmRoyaleApiClient client) { // Example fetching a player and his match history Player player = await client.GetPlayerAsync("overpowered", PlayerIdentifier.HiRez); Console.WriteLine($"{player.Name}, level: {player.Level}"); PlayerStats playerStats = await client.GetPlayerStatsAsync(player.Id); Console.WriteLine($"Wins: {playerStats.AggregateStats.Wins}, Losses: {playerStats.AggregateStats.Losses}"); foreach (var queueStat in playerStats.QueueClassStats) { Console.WriteLine($"{queueStat.ClassName}/{queueStat.MatchQueueName} Wins: {queueStat.Stats.Wins}, Losses: {queueStat.Stats.Losses}"); } Console.WriteLine("Last matches:"); var matchHistory = await client.GetPlayerMatchHistoryAsync(player.Id); foreach (Match match in matchHistory.Matches.Take(5)) { Console.WriteLine($"{match.Id}: {match.MapGame} ({match.ClassName})"); } }
/// <summary> /// getplayer /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='player'> /// The player /// </param> /// <param name='platform'> /// The platform /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async System.Threading.Tasks.Task <Player> GetPlayerAsync(this IRealmRoyaleApiClient operations, string player, string platform, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { using (var _result = await operations.GetPlayerWithHttpMessagesAsync(player, platform, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// gethirezserverstatus /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <HirezServerStatus> GetHirezServerStatusAsync(this IRealmRoyaleApiClient operations, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.GetHirezServerStatusWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) { return(_result.Body?.FirstOrDefault()); } }
private static async Task ExecuteQueuedMatches(IRealmRoyaleApiClient client) { // Example fetching siege matches played yesterday at noon // To reduce response times the HiRez API introduces time slices to fetch matches from a specific queue // An hour is divided into 6 parts (00, 10, 20, 30, 40, 50) DateTime date = DateTime.UtcNow.AddDays(-1); var hourSpan = new TimeSpan(12, 0, 0); var matchCount = 0; for (var min = 0; min < 60; min += 10) { var minSpan = new TimeSpan(0, min, 0); var queueData = await client.GetMatchIdsByQueueAsync(Queue.Solo, date, hourSpan, minSpan); matchCount += queueData.Count; Console.WriteLine($"Found {queueData.Count} matches in queue for slice {hourSpan},{minSpan}."); } // Or simply fetch the data from a whole hour var queueDataWholeHour = await client.GetMatchIdsByQueueAsync(Queue.Solo, date, hourSpan); Console.WriteLine($"Found {queueDataWholeHour.Count} matches in queue for {hourSpan}"); Debug.Assert(queueDataWholeHour.Count == matchCount); }
/// <summary> /// testsession /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <string> TestSessionAsync(this IRealmRoyaleApiClient operations, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.TestSessionWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// createsession /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async System.Threading.Tasks.Task <Session> CreateSessionAsync(this IRealmRoyaleApiClient operations, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { using (var _result = await operations.CreateSessionWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
private static async Task ExecuteApiDataStats(IRealmRoyaleApiClient client) { // Example contacting the API and getting a raw response from the client Console.WriteLine("Pinging API..."); var ping = await client.PingAsync(); Console.WriteLine(ping); Console.WriteLine(); var dataUsed = await client.GetDataUsedWithHttpMessagesAsync(); var rawResponseContent = await dataUsed.Response.Content.ReadAsStringAsync(); Console.WriteLine(rawResponseContent); Console.WriteLine(); }
/// <summary> /// getmatchidsbyqueue /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='queue'> /// The queue /// </param> /// <param name='date'> /// The date /// </param> /// <param name='hour'> /// The hour /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async System.Threading.Tasks.Task <System.Collections.Generic.IList <MatchIdsByQueue> > GetMatchIdsByQueueAsync(this IRealmRoyaleApiClient operations, string queue, string date, string hour, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { using (var _result = await operations.GetMatchIdsByQueueWithHttpMessagesAsync(queue, date, hour, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// ping /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> public static string Ping(this IRealmRoyaleApiClient operations) { return(operations.PingAsync().GetAwaiter().GetResult()); }
/// <summary> /// testsession /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> public static string TestSession(this IRealmRoyaleApiClient operations) { return(operations.TestSessionAsync().GetAwaiter().GetResult()); }
/// <summary> /// gethirezserverstatus /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> public static HirezServerStatus GetHirezServerStatus(this IRealmRoyaleApiClient operations) { return(operations.GetHirezServerStatusAsync().GetAwaiter().GetResult()); }
public static Task <Leaderboard> GetLeaderboardAsync(this IRealmRoyaleApiClient operations, Queue queue, RankingCriteria rankingCriteria, CancellationToken cancellationToken = default) { return(operations.GetLeaderboardAsync(((int)queue).ToString(), ((int)rankingCriteria).ToString(), cancellationToken)); }
public static Task <MatchDetails> GetMatchDetailsAsync(this IRealmRoyaleApiClient operations, int matchId, CancellationToken cancellationToken = default) { return(operations.GetMatchDetailsAsync(matchId.ToString(), cancellationToken)); }
/// <summary> /// getpatchinfo /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> public static PatchInfo GetPatchInfo(this IRealmRoyaleApiClient operations) { return(operations.GetPatchInfoAsync().GetAwaiter().GetResult()); }
/// <summary> /// getplayer /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='player'> /// The player /// </param> /// <param name='platform'> /// The platform /// </param> public static Player GetPlayer(this IRealmRoyaleApiClient operations, string player, string platform) { return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IRealmRoyaleApiClient)s).GetPlayerAsync(player, platform), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// createsession /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> public static Session CreateSession(this IRealmRoyaleApiClient operations) { return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IRealmRoyaleApiClient)s).CreateSessionAsync(), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// getdataused /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async System.Threading.Tasks.Task <System.Collections.Generic.IList <DataUsed> > GetDataUsedAsync(this IRealmRoyaleApiClient operations, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { using (var _result = await operations.GetDataUsedWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public static Task <IList <MatchIdsByQueue> > GetMatchIdsByQueueAsync(this IRealmRoyaleApiClient operations, Queue queue, DateTime date, TimeSpan hour, TimeSpan?minute = null, CancellationToken cancellationToken = default) { return(operations.GetMatchIdsByQueueAsync(((int)queue).ToString(), date.ToApiParameterDate(), hour.ToApiParameterHourAndMinTime(minute), cancellationToken)); }
public static Task <IList <MatchIdsByQueue> > GetMatchIdsByQueueAsync(this IRealmRoyaleApiClient operations, Queue queue, string date, string hour, CancellationToken cancellationToken = default) { return(operations.GetMatchIdsByQueueAsync(((int)queue).ToString(), date, hour, cancellationToken)); }
/// <summary> /// getmatchidsbyqueue /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='queue'> /// The queue /// </param> /// <param name='date'> /// The date /// </param> /// <param name='hour'> /// The hour /// </param> public static System.Collections.Generic.IList <MatchIdsByQueue> GetMatchIdsByQueue(this IRealmRoyaleApiClient operations, string queue, string date, string hour) { return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IRealmRoyaleApiClient)s).GetMatchIdsByQueueAsync(queue, date, hour), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// getmatchdetails /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='matchId'> /// The matchId /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async System.Threading.Tasks.Task <MatchDetails> GetMatchDetailsAsync(this IRealmRoyaleApiClient operations, string matchId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { using (var _result = await operations.GetMatchDetailsWithHttpMessagesAsync(matchId, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public static Task <PlayerStats> GetPlayerStatsAsync(this IRealmRoyaleApiClient operations, int playerId, CancellationToken cancellationToken = default) { return(operations.GetPlayerStatsAsync(playerId.ToString(), cancellationToken)); }
public static Task <Player> GetPlayerAsync(this IRealmRoyaleApiClient operations, string player, PlayerIdentifier identifier, CancellationToken cancellationToken = default) { return(operations.GetPlayerAsync(player, ((int)identifier).ToString(), cancellationToken)); }
/// <summary> /// getdataused /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> public static System.Collections.Generic.IList <DataUsed> GetDataUsed(this IRealmRoyaleApiClient operations) { return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IRealmRoyaleApiClient)s).GetDataUsedAsync(), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// getleaderboard /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='queue'> /// The queue /// </param> /// <param name='tier'> /// The tier /// </param> public static Leaderboard GetLeaderboard(this IRealmRoyaleApiClient operations, string queue, string tier) { return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IRealmRoyaleApiClient)s).GetLeaderboardAsync(queue, tier), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// getmatchdetails /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='matchId'> /// The matchId /// </param> public static MatchDetails GetMatchDetails(this IRealmRoyaleApiClient operations, string matchId) { return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IRealmRoyaleApiClient)s).GetMatchDetailsAsync(matchId), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// getleaderboard /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='queue'> /// The queue /// </param> /// <param name='tier'> /// The tier /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async System.Threading.Tasks.Task <Leaderboard> GetLeaderboardAsync(this IRealmRoyaleApiClient operations, string queue, string tier, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { using (var _result = await operations.GetLeaderboardWithHttpMessagesAsync(queue, tier, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }