Stastny.CRAPI 0.5.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Stastny.CRAPI --version 0.5.0                
NuGet\Install-Package Stastny.CRAPI -Version 0.5.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Stastny.CRAPI" Version="0.5.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Stastny.CRAPI --version 0.5.0                
#r "nuget: Stastny.CRAPI, 0.5.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Stastny.CRAPI as a Cake Addin
#addin nuget:?package=Stastny.CRAPI&version=0.5.0

// Install Stastny.CRAPI as a Cake Tool
#tool nuget:?package=Stastny.CRAPI&version=0.5.0                

How to use this wrapper

First of all, you have to obtain your own developer key - follow steps on CR API website.

After you have your key, add this nuget package in your project.

Now, you have to add using CRAPI; at beggining of your source code file. If you want to use async functionality, you have to add using System.Threading.Tasks; as well.

Using wrapper synchronously

After you obtained your developer key and added using CRAPI;, you can write this code:

// Initialize wrapper with your dev key
Wrapper wr = new Wrapper("3012e5ab523243q2a86w2bqa58bdf9bce96071843029447631924cf99w5a9kfc");

// Read player TAG from default input
string tag = Console.ReadLine();

// Get player from API
Player player = wr.GetPlayer(tag);

// Write player's name, level and arena'
Console.WriteLine($"{player.name} (XP level {player.stats.level}) ({player.arena.name})");
// Write player's clan name and player's role in clan
Console.WriteLine($"{player.clan.name} ({player.clan.role})");

Card[] cards = player.currentDeck;

// For each card in player's deck
foreach(Card c in cards)
{
	// Write card's name, elixir cost, rarity and level
    Console.WriteLine($"{c.name} {c.elixir} ({c.rarity}) --- level: {c.level}");
}

You can get much more information, this is just a showcase. See github for more details.

Using wrapper asynchronously

You have to write this code to special method → do not throw this into Main! Make method like static async void DoSomething() (async keyword!)

You have to add new using: using System.Threading.Tasks;

// As in sync version, initialize wrapper with your developer key
Wrapper wr = new Wrapper("3012e5ab523243q2a86w2bqa58bdf9bce96071843029447631924cf99w5a9kfc");

// Store player tag and clan tag
string tag = "80RGVCV9C";
string ctag = "22Y802";

Console.WriteLine("I'll get one player profile, one clan profile, best players and best clans async!");

// Get one player, one clan, best players and best clans async
Task<Player> a_player = wr.GetPlayerAsync(tag);
Task<Clan> a_clan = wr.GetClanAsync(ctag);
Task<SimplifiedPlayer[]> a_topPlayers = wr.GetTopPlayersAsync(); // wr.GetTopPlayers() and its async version return SimplifiedPlayer -> this is just like Player,
                                                                    // but simplified with less properties. If you want to get complete overview, get the top player:
                                                                    // Player topPlayer = wr.GetPlayer(wr.GetTopPlayers()[0].tag)
Task<SimplifiedClan[]> a_topClans = wr.GetTopClansAsync(); // Here is the same thing as with GetTopPlayers()


// Wait untill everything is prepared. You can for example write dots into console /* THIS IS OPTIONAL */
while (!a_player.IsCompleted || !a_clan.IsCompleted || !a_topPlayers.IsCompleted || !a_topClans.IsCompleted)
{
    Console.Write(".");
    System.Threading.Thread.Sleep(50);
}


// The while cycle above ends when everything loaded
Console.WriteLine("Done!");


// Get variables
// NOTE: If the while cycle above wouldn't be here, the application would wait untill everything is prepared here
Player player = await a_player;
Clan clan = await a_clan;
SimplifiedPlayer[] topPlayers = await a_topPlayers;
SimplifiedClan[] topCLans = await a_topClans;

// Write few names
Console.WriteLine(player.name);
Console.WriteLine(clan.name);
Console.WriteLine(topPlayers[0].name);
Console.WriteLine(topCLans[0].name);

You can get much more information, this is just a showcase. See github for more details.

Product Compatible and additional computed target framework versions.
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.7.3 1,149 8/12/2018
0.7.2 931 8/9/2018
0.7.1 1,093 6/3/2018
0.7.0 1,043 5/29/2018
0.6.3 1,029 5/29/2018
0.6.2 1,057 5/23/2018
0.6.1 1,017 5/12/2018
0.6.0 1,038 5/12/2018
0.5.5 1,040 3/26/2018
0.5.2 1,015 3/3/2018
0.5.1 1,023 3/1/2018
0.5.0 1,055 2/27/2018
0.4.3 1,032 2/19/2018
0.4.1 1,079 2/3/2018
0.4.0 1,038 1/30/2018
0.3.6 1,128 1/24/2018
0.3.4 1,031 1/15/2018
0.3.3 1,140 1/11/2018
0.3.2 1,377 1/5/2018
0.3.0 1,137 1/2/2018
0.2.9 1,049 1/1/2018
0.2.6 1,133 12/26/2017
0.2.5 1,087 12/26/2017
0.2.1 989 12/25/2017
0.2.0 982 12/25/2017
0.1.0 1,067 11/30/2017

Huge update fixing lot of bugs. Few features were added and open tournaments can now be requested from API.