Exemplo n.º 1
0
 public HttpRequest(HttpRequestConfiguration config)
 {
     _endpoint      = config.Endpoint;
     _httpContent   = config.HttpContent;
     _httpMethod    = config.HttpMethod;
     _authenticator = config.Authenticator;
 }
Exemplo n.º 2
0
        public static HttpRequest GetCatalogue(IAuthenticator authenticator, string countryCode, TimeRange timeRange)
        {
            var filter = new Filter();

            filter.MarketCountries = new HashSet <string> {
                countryCode
            };
            filter.EventTypeIds = new HashSet <string> {
                "1"
            };
            filter.MarketTypeCodes = new HashSet <string> {
                "MATCH_ODDS"
            };
            DateTime utcNow = DateTime.UtcNow;

            filter.MarketStartTime = timeRange ?? new TimeRange {
                From = utcNow, To = utcNow.AddHours(24)
            };
            var marketProjection = new HashSet <string> {
                "COMPETITION", "RUNNER_METADATA", "MARKET_DESCRIPTION", "MARKET_START_TIME"
            };
            var data        = new { filter = filter, marketProjection, maxResults = 100 };
            var jsonContent = new JsonContent(data);
            var httpConfig  = new HttpRequestConfiguration(CatalogueEndpoint, jsonContent, authenticator);

            return(new HttpRequest(httpConfig));
        }
Exemplo n.º 3
0
        public static HttpRequest GetCountries(IAuthenticator authenticator)
        {
            var data        = new { filter = new Filter() };
            var jsonContent = new JsonContent(data);
            var httpConfig  = new HttpRequestConfiguration(CountriesEndpoint, jsonContent, authenticator);

            return(new HttpRequest(httpConfig));
        }
Exemplo n.º 4
0
        public static IHttpRequest Authorise(string username, string password)
        {
            const string AuthEnpoint = "https://identitysso.betfair.com/api/login";
            var          authData    = new Dictionary <string, string> {
                { "username", username },
                { "password", password }
            };

            var httpConfig = new HttpRequestConfiguration(AuthEnpoint, new FormUrlEncodedContent(authData));

            return(new HttpRequest(httpConfig));
        }
Exemplo n.º 5
0
        public static HttpRequest GetOdds(IAuthenticator authenticator, List <string> marketIds)
        {
            var priceDepth      = new { bestPricesDepth = 1 };
            var priceProjection = new
            {
                priceData             = new string[] { "EX_BEST_OFFERS" },
                exBestOffersOverrides = priceDepth
            };

            var data        = new { marketIds = marketIds, priceProjection = priceProjection };
            var jsonContent = new JsonContent(data);
            var httpConfig  = new HttpRequestConfiguration(OddsEndpoint, jsonContent, authenticator);

            return(new HttpRequest(httpConfig));
        }