Exemple #1
0
        public void GetObjectReturnsTheSameObject()
        {
            Faceit f = Get();

            Search search1 = f.GetObject <Search>();
            Search search2 = f.GetObject <Search>();

            Assert.AreEqual(search1, search2);
        }
        public void Search()
        {
            // arrange
            Authorization authorization = new Authorization("<< YOUR API KEY >>");
            Faceit        faceit        = new Faceit(authorization);

            // Search extends ApiBase.
            Search search = faceit.GetObject <Search>();

            // Paging<> is array of generic type, with integers Start and End
            Paging <SimplePlayer> players = search.GetPlayers("Donald Trump", country: "USA");

            foreach (var player in players.Items)
            {
                string playerid = player.PlayerId;
                string avatar   = player.Avatar;
                string country  = player.Country;
                string nickname = player.Nickname;
                bool   verified = (bool)player.Verified;

                // and more.
                // if you want more variables, use this PlayerId
                // in Players.GetPlayer() method.
            }
        }
Exemple #3
0
        public void Get()
        {
            // arrange
            Authorization authorization = new Authorization("<< YOUR API KEY >>");
            Faceit        faceit        = new Faceit(authorization);

            Games games = faceit.GetObject <Games>();
            Paging <GameDetails> details = games.GetGames();

            foreach (GameDetails game in details.Items)
            {
                // game title eg. "Counter Strike: Global Offensive", "CS:GO"
                string visiblename      = game.LongLabel;
                string visibleshortname = game.ShortLabel;

                // assets contains images.
                string landingimage = game.Assets.LandingPage;
            }
        }
Exemple #4
0
        public void Get()
        {
            string playerid = "<< PLAYER ID HERE >>";

            // arrange
            Faceit faceit = new Faceit(new Authorization("<< YOUR API KEY >>"));

            Types.Rankings rankings = faceit.GetObject <Types.Rankings>();

            // execute request to REST api
            RankingPaging <SimpleGamePlayer> players = rankings.GetGlobalPositionForPlayer("csgo", "EU", playerid, "pl");

            // iterate results
            foreach (SimpleGamePlayer player in players.Items)
            {
                string nickname  = player.Nickname;
                string id        = player.PlayerId;
                int?   faceitelo = player.FaceitElo;
                string country   = player.Country;

                // and more :D
            }
        }
        public void Get()
        {
            // arrange
            Authorization authorization = new Authorization("<< YOUR API KEY >>");
            Faceit        faceit        = new Faceit(authorization);

            Matches matches = faceit.GetObject <Matches>();
            Match   match   = matches.GetMatch("<< YOUR MATCH ID >>");

            string matchid        = match.MatchId;
            string chatroomid     = match.ChatRoomId;
            string demourl        = match.DemoUrl[0];
            string game           = match.Game;
            string selectedmap    = match.Voting.Maps.Pick[0];
            string teamleader     = match.Teams[0].Leader;
            bool?  affectingtoelo = match.CalculateElo;

            // in FaceitAPI variables type ulong and nullable - ulong? means unix timestamp
            // you can convert it to System.DateTime my type - UnixConverter (WILL BE LATER)
            ulong?startedat  = match.StartedAt;
            ulong?finishedat = match.FinishedAt;

            // and a lot more! :D
        }
        //
        // here we use FaceitAPI.Types.Response type.
        // he implementing IResponse, and in constructor put parameter Action<string, HttpResponseMessage>
        // Action is invoked like IResponse.ReadResponse method.
        //
        public void SecondMethod()
        {
            Faceit faceit = new Faceit(new Authorization("YOUR API KEY"));

            faceit.GetObject <Search>(new Response((json, responsemsg) => Console.WriteLine("json response is " + json)));
        }
        //
        // this way, we create IResponse interface implementation.
        // put this to GetObject<>(IResponse) method, or after you GetObject<>() set value Response.
        //
        public void FirstMethod()
        {
            Faceit faceit = new Faceit(new Authorization("YOUR API KEY"));

            faceit.GetObject <Search>(new ResponseImplementation());
        }