Skip to content

Commit

Permalink
Remove examples for deprecated APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
tparviainen committed Jun 6, 2023
1 parent 968ebc9 commit fc028f1
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/ClashOfClans.App/ClashOfClans.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ClashOfClans" Version="8.7.0" />
<PackageReference Include="ClashOfClans" Version="8.8.0-rc3" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
</ItemGroup>

Expand Down
28 changes: 28 additions & 0 deletions src/ClashOfClans.App/Examples/LeaguesExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,33 @@ public async Task GetCapitalLeagueInformation()

Console.WriteLine($"Id: {capitalLeague.Id} = {capitalLeague.Name}");
}

/// <summary>
/// Get Builder Base league information
/// </summary>
public async Task GetBuilderBaseLeagueInformation()
{
var builderBaseLeagueId = 44000010; // Stone League V
var coc = new ClashOfClansClient(token);
var builderBaseLeague = await coc.Leagues.GetBuilderBaseLeagueAsync(builderBaseLeagueId);

Console.WriteLine($"Id: {builderBaseLeague.Id} = {builderBaseLeague.Name}");
}

/// <summary>
/// List Builder Base leagues
/// </summary>
public async Task ListBuilderBaseLeagues()
{
var coc = new ClashOfClansClient(token);
var builderBaseLeagues = (BuilderBaseLeagueList)await coc.Leagues.GetBuilderBaseLeaguesAsync();

Console.WriteLine($"Total amount of builder base leagues: {builderBaseLeagues.Count}");

foreach (var builderBaseLeague in builderBaseLeagues)
{
Console.WriteLine($"Id: {builderBaseLeague.Id}, Name: {builderBaseLeague.Name}");
}
}
}
}
18 changes: 9 additions & 9 deletions src/ClashOfClans.App/Examples/LocationsExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,35 +84,35 @@ public async Task GetPlayerRankingsForASpecificLocation()
}

/// <summary>
/// Get clan versus rankings for a specific location
/// Get clan Builder Base rankings for a specific location
/// </summary>
public async Task GetClanVersusRankingsForASpecificLocation()
public async Task GetClanBuilderBaseRankingsForASpecificLocation()
{
var coc = new ClashOfClansClient(token);
var locations = (LocationList)await coc.Locations.GetLocationsAsync();
var location = locations["Finland"];

Console.WriteLine($"Clan versus rankings for {location!.Name}");
var clanVersusRankings = (ClanVersusRankingList)await coc.Locations.GetClanVersusRankingAsync(location.Id);
Console.WriteLine($"Clan builder base rankings for {location!.Name}");
var clanBuilderBaseRankings = (ClanBuilderBaseRankingList)await coc.Locations.GetClanBuilderBaseRankingAsync(location.Id);

foreach (var clan in clanVersusRankings)
foreach (var clan in clanBuilderBaseRankings)
{
Console.WriteLine($"{clan.Rank}. {clan.Name}, clan level {clan.ClanLevel}, {clan.ClanVersusPoints} \uD83C\uDFC6");
}
}

/// <summary>
/// Get player versus rankings for a specific location
/// Get player Builder Base rankings for a specific location
/// </summary>
public async Task GetPlayerVersusRankingsForASpecificLocation()
public async Task GetPlayerBuilderBaseRankingsForASpecificLocation()
{
var coc = new ClashOfClansClient(token);
var locations = (LocationList)await coc.Locations.GetLocationsAsync();
var location = locations["Finland"];

var playerVersusRankings = (PlayerVersusRankingList)await coc.Locations.GetPlayerVersusRankingAsync(location!.Id);
var playerBuilderBaseRankings = (PlayerBuilderBaseRankingList)await coc.Locations.GetPlayerBuilderBaseRankingAsync(location!.Id);

foreach (var player in playerVersusRankings)
foreach (var player in playerBuilderBaseRankings)
{
Console.WriteLine($"Rank {player.Rank}, {player.VersusTrophies} \uD83C\uDFC6, player {player.Name}");
}
Expand Down
26 changes: 14 additions & 12 deletions src/ClashOfClans.App/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ static async Task Main(string[] _)
{
// Access clan specific information
var clansExamples = new ClansExamples(token, clanTag);
await clansExamples.RetrieveInformationAboutClansCurrentClanWarLeagueGroup();
await clansExamples.RetrieveClansClanWarLog();
await clansExamples.SearchClans();
await clansExamples.RetrieveInformationAboutClansCurrentClanWar();
await clansExamples.GetClanInformation();
await clansExamples.ListClanMembers();
await clansExamples.RetrieveClansClanWarLog();
await clansExamples.RetrieveInformationAboutClansCurrentClanWar();
await clansExamples.RetrieveInformationAboutClansCurrentClanWarLeagueGroup();
await clansExamples.RetrieveClansCapitalRaidSeasons();

// Access player specific information
Expand All @@ -36,33 +36,35 @@ static async Task Main(string[] _)

// Access league information
var leaguesExamples = new LeaguesExamples(token);
await leaguesExamples.ListCapitalLeagues();
await leaguesExamples.ListLeagues();
await leaguesExamples.GetLeagueSeasonRankings();
await leaguesExamples.GetCapitalLeagueInformation();
await leaguesExamples.GetBuilderBaseLeagueInformation();
await leaguesExamples.ListBuilderBaseLeagues();
await leaguesExamples.GetLeagueInformation();
await leaguesExamples.GetLeagueSeasons();
await leaguesExamples.GetLeagueSeasonRankings();
await leaguesExamples.ListWarLeagues();
await leaguesExamples.GetWarLeagueInformation();
await leaguesExamples.ListCapitalLeagues();
await leaguesExamples.GetCapitalLeagueInformation();
await leaguesExamples.ListWarLeagues();

// Access global and local rankings
var locationsExamples = new LocationsExamples(token);
await locationsExamples.ListLocations();
await locationsExamples.GetLocationInformation();
await locationsExamples.GetClanRankingsForASpecificLocation();
await locationsExamples.GetPlayerRankingsForASpecificLocation();
await locationsExamples.GetClanVersusRankingsForASpecificLocation();
await locationsExamples.GetPlayerVersusRankingsForASpecificLocation();
await locationsExamples.GetPlayerBuilderBaseRankingsForASpecificLocation();
await locationsExamples.GetClanBuilderBaseRankingsForASpecificLocation();
await locationsExamples.ListLocations();
await locationsExamples.GetCapitalRankingsForASpecificLocation();
await locationsExamples.GetLocationInformation();

// Access information about gold pass
var goldPassExamples = new GoldPassExamples(token);
await goldPassExamples.GetCurrentGoldPassSeason();

// Access labels
var labelsExamples = new LabelsExamples(token);
await labelsExamples.ListClanLabels();
await labelsExamples.ListPlayerLabels();
await labelsExamples.ListClanLabels();
}
catch (ClashOfClansException ex)
{
Expand Down

0 comments on commit fc028f1

Please sign in to comment.