Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LeagueEndpoint update, new properties in championMastery and league #627

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions RiotSharp.Test/RiotApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,25 @@ public void GetChampionRotationAsync_Test()

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetLeaguePositionsAsync_BySummoner_Test()
public void GetLeagueEntriesAsync_Test()
{
EnsureCredibility(() =>
{
var leagues = Api.League.GetLeaguePositionsAsync(RiotApiTestBase.SummonersRegion, RiotApiTestBase.SummonerIds.FirstOrDefault());
var entries = Api.League.GetLeagueEntriesAsync(RiotApiTestBase.SummonersRegion, RiotApiTestBase.Queue, RiotApiTestBase.Tier, RiotApiTestBase.Division);

Assert.IsTrue(leagues.Result.Count > 0);
Assert.IsTrue(entries.Result.Count > 0);
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetLeagueEntriesBySummonerIdAsync_Test()
{
EnsureCredibility(() =>
{
var entries = Api.League.GetLeagueEntriesBySummonerIdAsync(Summoner1And2Region, Summoner1Id);

Assert.IsTrue(entries.Result.Count > 0);
});
}

Expand All @@ -125,6 +137,18 @@ public void GetMasterLeagueAsync_Test()
Assert.IsTrue(league.Result.Entries.Count > 0);
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetGrandMasterLeagueAsync_Test()
{
EnsureCredibility(() =>
{
var league = Api.League.GetGrandMasterLeagueAsync(Summoner1And2Region, RiotApiTestBase.Queue);

Assert.IsTrue(league.Result.Entries.Count > 0);
});
}
#endregion

#region Match Tests
Expand Down
2 changes: 2 additions & 0 deletions RiotSharp.Test/RiotApiTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ internal class RiotApiTestBase : CommonTestBase

public static Region SummonersRegion = (Region) Enum.Parse(typeof(Region), "Na");
public static string Queue = "RANKED_SOLO_5x5";
public static string Tier = "DIAMOND";
public static string Division = "II";

// Normal 5v5 Draft Pick games
public static int QueueId = 400;
Expand Down
4 changes: 0 additions & 4 deletions RiotSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ Global
{B4768473-9B66-419F-8CD1-15EAB4F71A75}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B4768473-9B66-419F-8CD1-15EAB4F71A75}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B4768473-9B66-419F-8CD1-15EAB4F71A75}.Release|Any CPU.Build.0 = Release|Any CPU
{22B1700C-4B99-4504-B4E8-24B9EEEBCF72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{22B1700C-4B99-4504-B4E8-24B9EEEBCF72}.Debug|Any CPU.Build.0 = Debug|Any CPU
{22B1700C-4B99-4504-B4E8-24B9EEEBCF72}.Release|Any CPU.ActiveCfg = Release|Any CPU
{22B1700C-4B99-4504-B4E8-24B9EEEBCF72}.Release|Any CPU.Build.0 = Release|Any CPU
{97CE2F8F-50FC-45FC-B043-C0F8B64E24B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{97CE2F8F-50FC-45FC-B043-C0F8B64E24B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97CE2F8F-50FC-45FC-B043-C0F8B64E24B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,11 @@ public class ChampionMastery
/// </summary>
[JsonProperty("summonerId")]
public string SummonerId { get; set; }

/// <summary>
/// Player ID for this entry.
/// </summary>
[JsonProperty("tokensEarned")]
public int TokensEarned { get; set; }
}
}
24 changes: 21 additions & 3 deletions RiotSharp/Endpoints/Interfaces/ILeagueEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,22 @@ namespace RiotSharp.Endpoints.Interfaces
public interface ILeagueEndpoint
{
/// <summary>
/// Retrieves the league positions for the specified summoner asynchronously.
/// Get all the league entries.
/// </summary>
/// <param name="region"><see cref="Region"/> in which you wish to look for the league positions of the summoner.</param>
/// <param name="region"><see cref="Region"/> in which you wish to look for the league entries of the league.</param>
/// <param name="queue">The queue name e.g. "RANKED_SOLO_5x5"</param>
/// <param name="division">The division number e.g. 'IV'</param>
/// <param name="tier">The tier name e.g. "DIAMOND"</param>
/// <returns><see cref="LeaguePosition" /> of the summoner in the leagues.</returns>
Task<List<LeaguePosition>> GetLeagueEntriesAsync(Region region, string queue, string tier, string division);

/// <summary>
/// Get league entries in all queues for a given summoner ID.
/// </summary>
/// <param name="region"><see cref="Region"/> in which you wish to look for the league entries of the summoner.</param>
/// <param name="summonerId">The summoner id.</param>
/// <returns><see cref="LeaguePosition" /> of the summoner in the leagues.</returns>
Task<List<LeaguePosition>> GetLeaguePositionsAsync(Region region, string summonerId);
Task<List<LeaguePosition>> GetLeagueEntriesBySummonerIdAsync(Region region, string summonerId);

/// <summary>
/// Get the challenger league for a particular queue asynchronously.
Expand All @@ -33,5 +43,13 @@ public interface ILeagueEndpoint
/// <param name="queue">Queue in which you wish to look for a master league.</param>
/// <returns>A <see cref="League" /> which contains all the masters for this specific region and queue.</returns>
Task<League> GetMasterLeagueAsync(Region region, string queue);

/// <summary>
/// Get the grandmaster league for a particular queue asynchronously.
/// </summary>
/// <param name="region"><see cref="Region"/> in which you wish to look for a grand master league.</param>
/// <param name="queue">Queue in which you wish to look for a grand master league.</param>
/// <returns>A <see cref="League" /> which contains all the grand masters for this specific region and queue.</returns>
Task<League> GetGrandMasterLeagueAsync(Region region, string queue);
}
}
6 changes: 6 additions & 0 deletions RiotSharp/Endpoints/LeagueEndpoint/League.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,11 @@ internal League() { }
/// </summary>
[JsonProperty("tier")]
public Tier Tier { get; set; }

/// <summary>
/// League ID
/// </summary>
[JsonProperty("leagueId")]
public string LeagueID { get; set; }
}
}
23 changes: 20 additions & 3 deletions RiotSharp/Endpoints/LeagueEndpoint/LeagueEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public class LeagueEndpoint : ILeagueEndpoint
{
private const string LeagueRootUrl = "/lol/league/v4";
private const string LeagueChallengerUrl = "/challengerleagues/by-queue/{0}";
private const string LeagueGrandMasterUrl = "/grandmasterleagues/by-queue/{0}";
private const string LeagueMasterUrl = "/masterleagues/by-queue/{0}";
private const string LeaguePositionBySummonerUrl = "/positions/by-summoner/{0}";
private const string LeagueEntriesBySummoner = "/entries/by-summoner/{0}";
private const string LeagueEntries = "/entries/{0}/{1}/{2}";

private readonly IRateLimitedRequester _requester;

Expand All @@ -29,11 +31,18 @@ public LeagueEndpoint(IRateLimitedRequester requester)
}

/// <inheritdoc />
public async Task<List<LeaguePosition>> GetLeaguePositionsAsync(Region region, string summonerId)
public async Task<List<LeaguePosition>> GetLeagueEntriesAsync(Region region, string queue, string tier, string division)
{
var json = await _requester.CreateGetRequestAsync(
LeagueRootUrl + string.Format(LeaguePositionBySummonerUrl, summonerId), region).ConfigureAwait(false);
LeagueRootUrl + string.Format(LeagueEntries, queue, tier, division), region).ConfigureAwait(false);
return JsonConvert.DeserializeObject<List<LeaguePosition>>(json);
}

/// <inheritdoc />
public async Task<List<LeaguePosition>> GetLeagueEntriesBySummonerIdAsync(Region region, string summonerId)
{
var json = await _requester.CreateGetRequestAsync(
LeagueRootUrl + string.Format(LeagueEntriesBySummoner, summonerId), region).ConfigureAwait(false);
return JsonConvert.DeserializeObject<List<LeaguePosition>>(json);
}

Expand All @@ -52,5 +61,13 @@ public async Task<League> GetMasterLeagueAsync(Region region, string queue)
region).ConfigureAwait(false);
return JsonConvert.DeserializeObject<League>(json);
}

/// <inheritdoc />
public async Task<League> GetGrandMasterLeagueAsync(Region region, string queue)
{
var json = await _requester.CreateGetRequestAsync(LeagueRootUrl + string.Format(LeagueGrandMasterUrl, queue),
region).ConfigureAwait(false);
return JsonConvert.DeserializeObject<League>(json);
}
}
}
88 changes: 44 additions & 44 deletions RiotSharp/Endpoints/LeagueEndpoint/LeaguePosition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ internal LeaguePosition()
{
}

/// <summary>
/// The name of the league of the participant.
/// Only when it's called from the GetLeaguePositions()
/// </summary>
[JsonProperty("leagueName")]
public string LeagueName { get; set; }

/// <summary>
/// The queue type of the league.
/// Only for the GetLeaguePositions() -> don't exist when it's an entry from a League
Expand All @@ -27,23 +20,10 @@ internal LeaguePosition()
public string QueueType { get; set; }

/// <summary>
/// The rank of the participant in a league.
/// </summary>
[JsonProperty("rank")]
public string Rank { get; set; }

///<summary>
/// The league tier of the participant.
/// Only when it's called from the GetLeaguePositions()
/// The name of the summoner.
/// </summary>
[JsonProperty("tier")]
public string Tier { get; set; }

/// <summary>
/// Specifies if the participant is fresh blood.
/// </summary>
[JsonProperty("freshBlood")]
public bool FreshBlood { get; set; }
[JsonProperty("summonerName")]
public string SummonerName { get; set; }

/// <summary>
/// Specifies if the participant is on a hot streak.
Expand All @@ -52,22 +32,22 @@ internal LeaguePosition()
public bool HotStreak { get; set; }

/// <summary>
/// Specifies if the participant is inactive.
/// Mini series data for the participant. Only present if the participant is currently in a mini series.
/// </summary>
[JsonProperty("inactive")]
public bool Inactive { get; set; }
[JsonProperty("miniSeries")]
public MiniSeries MiniSeries { get; set; }

/// <summary>
/// Specifies if the participant is a veteran.
/// The number of wins for the participant.
/// </summary>
[JsonProperty("veteran")]
public bool Veteran { get; set; }
[JsonProperty("wins")]
public int Wins { get; set; }

/// <summary>
/// The league points of the participant.
/// Specifies if the participant is a veteran.
/// </summary>
[JsonProperty("leaguePoints")]
public int LeaguePoints { get; set; }
[JsonProperty("veteran")]
public bool Veteran { get; set; }

/// <summary>
/// The number of losses for the participant.
Expand All @@ -76,27 +56,47 @@ internal LeaguePosition()
public int Losses { get; set; }

/// <summary>
/// Mini series data for the participant. Only present if the participant is currently in a mini series.
/// The rank of the participant in a league.
/// </summary>
[JsonProperty("miniSeries")]
public MiniSeries MiniSeries { get; set; }
[JsonProperty("rank")]
public string Rank { get; set; }

/// <summary>
/// The id of the league of the participant.
/// Only when it's called from the GetLeaguePositions() 'this method is deprecated)
/// </summary>
[JsonProperty("leagueId")]
public string LeagueID { get; set; }

/// <summary>
/// Specifies if the participant is inactive.
/// </summary>
[JsonProperty("inactive")]
public bool Inactive { get; set; }

///<summary>
/// The league tier of the participant.
/// Only when it's called from the GetLeaguePositions()
/// </summary>
[JsonProperty("tier")]
public string Tier { get; set; }

/// <summary>
/// The ID of the participant (i.e., summoner or team) represented by this entry.
/// Specifies if the participant is fresh blood.
/// </summary>
[JsonProperty("playerOrTeamId")]
public string PlayerOrTeamId { get; set; }
[JsonProperty("freshBlood")]
public bool FreshBlood { get; set; }

/// <summary>
/// The name of the the participant (i.e., summoner or team) represented by this entry.
/// Player's summonerId (Encrypted)
/// </summary>
[JsonProperty("playerOrTeamName")]
public string PlayerOrTeamName { get; set; }
[JsonProperty("summonerId")]
public string summonerId { get; set; }

/// <summary>
/// The number of wins for the participant.
/// The league points of the participant.
/// </summary>
[JsonProperty("wins")]
public int Wins { get; set; }
[JsonProperty("leaguePoints")]
public int LeaguePoints { get; set; }
}
}