示例#1
0
        private OpenDotaApi(string apiKey, WebProxy proxy)
        {
            _request = new Request(apiKey, proxy);

            Matches         = new MatchEndpoint(_request);
            Player          = new PlayerEndpoint(_request);
            ProPlayers      = new ProPlayerEndpoint(_request);
            ProMatches      = new ProMatchesEndpoint(_request);
            PublicMatches   = new PublicMatchEndpoint(_request);
            Metadata        = new MetadataEndpoint(_request);
            MmrDistribution = new MmrDistributionEndpoint(_request);
            Search          = new SearchEndpoint(_request);
            Ranking         = new RankingEndpoint(_request);
            Benchmarks      = new BenchmarksEndpoint(_request);
            Status          = new StatusEndpoint(_request);
            Health          = new HealthEndpoint(_request);
            Request         = new RequestEndpoint(_request);
            FindMatch       = new FindMatchEndpoint(_request);
            Hero            = new HeroEndpoint(_request);
            HeroStats       = new HeroStatsEndpoint(_request);
            League          = new LeagueEndpoint(_request);
            Team            = new TeamEndpoint(_request);
            Replay          = new ReplayEndpoint(_request);
            Record          = new RecordEndpoint(_request);
            Live            = new LiveEndpoint(_request);
            Scenarios       = new ScenariosEndpoint(_request);
            Schema          = new SchemaEndpoint(_request);
        }
示例#2
0
        public OpenDota(string apiKey = null, IWebProxy proxy = null)
        {
            _request       = new RequestHandler(apiKey, proxy);
            _jsonFormatter = new JsonFormatter(_request);

            Matches       = new MatchesEndpoint(_jsonFormatter);
            PlayersByRank = new PlayersByRankEndpoint(_jsonFormatter);
            Players       = new PlayersEndpoint(_jsonFormatter, _request);
            ProPlayers    = new ProPlayersEndpoint(_jsonFormatter);
            ProMatches    = new ProMatchesEndpoint(_jsonFormatter);
            PublicMatches = new PublicMatchesEndpoint(_jsonFormatter);
            ParsedMatches = new ParsedMatchesEndpoint(_jsonFormatter);
            Metadata      = new MetadataEndpoint(_jsonFormatter);
            Distributions = new DistributionsEndpoint(_jsonFormatter);
            Search        = new SearchEndpoint(_jsonFormatter);
            Rankings      = new RankingsEndpoint(_jsonFormatter);
            Benchmarks    = new BenchmarksEndpoint(_jsonFormatter);
            Status        = new StatusEndpoint(_jsonFormatter);
            Health        = new HealthEndpoint(_jsonFormatter);
            Request       = new RequestEndpoint(_jsonFormatter, _request);
            FindMatches   = new FindMatchesEndpoint(_jsonFormatter);
            Heroes        = new HeroesEndpoint(_jsonFormatter);
            HeroStats     = new HeroStatsEndpoint(_jsonFormatter);
            Leagues       = new LeaguesEndpoint(_jsonFormatter);
            Teams         = new TeamsEndpoint(_jsonFormatter);
            Replays       = new ReplaysEndpoint(_jsonFormatter);
            Records       = new RecordsEndpoint(_jsonFormatter);
            Live          = new LiveEndpoint(_jsonFormatter);
            Scenarios     = new ScenariosEndpoint(_jsonFormatter);
            Schema        = new SchemaEndpoint(_jsonFormatter);
            Constants     = new ConstantsEndpoint(_request);
        }
示例#3
0
 public static string FetchEndpoint(RequestEndpoint endpoint)
 {
     return(endpoint switch
     {
         RequestEndpoint.JsonRpc => "json_rpc",
         RequestEndpoint.TransactionPool => "get_transaction_pool",
         RequestEndpoint.Transactions => "get_transactions",
         _ => throw new InvalidOperationException($"Unknown Endpoint ({endpoint})"),
     });
示例#4
0
        private async Task <T> PostAsync <T>(RequestEndpoint endpoint, object body = null)
        {
            try
            {
                var request = new RestRequest($"{endpoint.Group}/{endpoint.Action}", Method.POST);
                if (body != null)
                {
                    request.AddJsonBody(body);
                }

                return(await ExecuteAsync <T>(request));
            }
            catch
            {
                throw;
            }
        }
示例#5
0
 public static DeviceAndPort GetDeviceAndPort(this RequestEndpoint requestEndpoint)
 {
     return(new DeviceAndPort(requestEndpoint.EndpointId));
 }
示例#6
0
        /// <summary>
        /// Services the invoker asynchronous.
        /// </summary>
        /// <param name="method">The method.</param>
        /// <param name="endpoint">The endpoint.</param>
        /// <param name="token">The token.</param>
        /// <param name="queryString">The query string.</param>
        /// <param name="data">The data.</param>
        /// <param name="restEndpoint">The rest endpoint.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentOutOfRangeException">restEndpoint - null</exception>
        public async Task <string> ServiceInvokerAsync(
            HttpRequestMethod method,
            [Localizable(false)] string endpoint,
            CancellationToken token,
            Dictionary <string, string> queryString = null,
            string data = null,
            RequestEndpoint restEndpoint = RequestEndpoint.DEFAULT)
        {
            string host;
            Cookie cookie = null;
            var    requiresAuthentication = true;
            var    protocol = @"https";
            var    port     = 443;

            switch (restEndpoint)
            {
            case RequestEndpoint.DEFAULT:
                host     = $@"{_accountName}.vtexcommercestable.com.br";
                endpoint = $@"api/{endpoint}";
                break;

            case RequestEndpoint.PAYMENTS:
                host     = $@"{_accountName}.vtexpayments.com.br";
                endpoint = $@"api/{endpoint}";
                break;

            case RequestEndpoint.LOGISTICS:
                host     = @"logistics.vtexcommercestable.com.br";
                endpoint = $@"api/{endpoint}";
                if (queryString == null)
                {
                    queryString = new Dictionary <string, string>();
                }

                queryString.Add(@"an", _accountName);
                break;

            case RequestEndpoint.API:
            case RequestEndpoint.MASTER_DATA:
                host     = @"api.vtex.com";
                endpoint = $@"{_accountName}/{endpoint}";
                break;

            case RequestEndpoint.BRIDGE:
                host     = $@"{_accountName}.myvtex.com";
                endpoint = $@"api/{endpoint}";
                if (!string.IsNullOrWhiteSpace(_authCookie))
                {
                    cookie = new Cookie("VtexIdclientAutCookie", _authCookie);
                }

                break;

            case RequestEndpoint.HEALTH:
                protocol = @"http";
                port     = 80;
                host     = @"monitoring.vtex.com";
                endpoint = @"api/healthcheck/modules";
                requiresAuthentication = false;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(restEndpoint), restEndpoint, null);
            }
            var query = string.Empty;

            if (queryString != null &&
                queryString.Count > 0)
            {
                query = new QueryStringBuilder().AddRange(queryString).ToString();
            }

            var builder = new UriBuilder(protocol, host, port, endpoint)
            {
                Query = query.Replace(@"?", string.Empty)
            };

            return(await ServiceInvokerInternal(method, endpoint, token, data, builder, cookie, requiresAuthentication)
                   .ConfigureAwait(false));
        }