private async Task <Dictionary <string, BoardInfo> > Get(Guid[] uuids, Platform platform, Region region, int season, bool ranked) { var queries = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("profile_ids", string.Join(',', uuids)), new KeyValuePair <string, string>("board_id", ranked ? "pvp_ranked" : "pvp_casual"), new KeyValuePair <string, string>("region_id", Constant.RegionToString(region)), new KeyValuePair <string, string>("season_id", season.ToString()) }; var session = await _sessionHandler.GetCurrentSessionAsync().ConfigureAwait(false); using var results = await ApiHelper.GetDataAsync(Endpoints.UbiServices.Players, platform, queries, session).ConfigureAwait(false); var deserialised = await JsonSerializer.DeserializeAsync <BoardInfoFetch>(results).ConfigureAwait(false); return(deserialised.Players); }
public async Task <PlayersSkillRecords> GetPlayersSkillRecordsAsync(Guid[] uuids, Platform platform, Region region, params int[] seasons) { var queries = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("profile_ids", string.Join(',', uuids)), new KeyValuePair <string, string>("board_ids", "pvp_ranked"), new KeyValuePair <string, string>("region_ids", Constant.RegionToString(region)), new KeyValuePair <string, string>("season_ids", string.Join(',', seasons)) }; var session = await _sessionHandler.GetCurrentSessionAsync().ConfigureAwait(false); using var results = await ApiHelper.GetDataAsync(Endpoints.UbiServices.PlayerSkillRecords, platform, queries, session).ConfigureAwait(false); var deserialised = await JsonSerializer.DeserializeAsync <PlayersSkillRecords>(results).ConfigureAwait(false); return(deserialised); }
public async Task <Dictionary <string, Dictionary <string, double> > > GetQueueStatisticsAsync(Guid[] uuids, Platform platform) { var queries = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("populations", HttpUtility.UrlEncode(string.Join(',', uuids))), new KeyValuePair <string, string>("statistics", Constant.QueuesStatisticsVariables) }; var session = await _sessionHandler.GetCurrentSessionAsync().ConfigureAwait(false); using var results = await ApiHelper.GetDataAsync(Endpoints.UbiServices.Statistics, platform, queries, session) .ConfigureAwait(false); var deserialised = await JsonSerializer.DeserializeAsync <QueueStatistics>(results) .ConfigureAwait(false); return(deserialised.PlayerQueueStatistics); }
private async Task <List <Profile> > Get(Platform?platform, string queryKey, string queryValue) { var queries = new List <KeyValuePair <string, string> >(); if (platform.HasValue) { var query = new KeyValuePair <string, string>("platformType", Constant.PlatformToString(platform.Value)); queries.Add(query); } queries.Add(new KeyValuePair <string, string>(queryKey, queryValue)); var session = await _sessionHandler.GetCurrentSessionAsync().ConfigureAwait(false); using var results = await ApiHelper.GetDataAsync(Endpoints.UbiServices.Search, null, queries, session).ConfigureAwait(false); var deserialised = await JsonSerializer.DeserializeAsync <ProfileSearch>(results).ConfigureAwait(false); return(deserialised.Profiles); }
/// <summary> /// Get a list of basic profiles (like <see cref="PlayerProgression.XP"/> and <see cref="PlayerProgression.Level"/>). /// </summary> /// <param name="uuids"> /// The UUIDs matching the player profiles (should be searched with <see cref="GetProfileAsync(string, Platform)"/> beforehand). /// </param> /// <param name="platform"> /// The platform <paramref name="uuids"/> belong to. /// </param> /// <returns> /// A list of basic profiles matching the request terms. /// </returns> public async Task <List <PlayerProgression> > GetPlayerProgressionAsync(Guid[] uuids, Platform platform) { var queries = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("profile_ids", string.Join(',', uuids)) }; var session = await _sessionHandler.GetCurrentSessionAsync().ConfigureAwait(false); using var results = await ApiHelper.GetDataAsync(Endpoints.UbiServices.Progressions, platform, queries, session).ConfigureAwait(false); var deserialised = await JsonSerializer.DeserializeAsync <PlayerProgressionFetch>(results).ConfigureAwait(false); foreach (var result in deserialised.PlayerProgressions) { // Attach link to player profile icon url var formatted = string.Format(Endpoints.Static.Avatar, result.ProfileId, Constant.Rainbow6S); result.ProfileIcon = new Uri(formatted); } return(deserialised.PlayerProgressions); }