public PinnacleClient(string clientId, string password, string currencyCode, OddsFormat oddsFormat,
                       string baseAddress = DefaultBaseAddress)
 {
     CurrencyCode = currencyCode;
     OddsFormat   = oddsFormat;
     _httpClient  = HttpClientFactory.GetNewInstance(clientId, password, true, baseAddress);
 }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sportId"></param>
        /// <param name="leagueId"></param>
        /// <param name="eventId"></param>
        /// <param name="periodNumber">0 for sports other than soccer, soccer: 0 = Game, 1 = 1st Half, 2 = 2nd Half</param>
        /// <param name="betType"></param>
        /// <param name="oddsFormat"></param>
        /// <param name="team"></param>
        /// <param name="side"></param>
        /// <param name="handicap"></param>
        /// <returns></returns>
        public Task <GetLineResponse> GetLine(int sportId, int leagueId, long eventId, int periodNumber, BetType betType,
                                              OddsFormat oddsFormat,
                                              TeamType?team = null, SideType?side = null, decimal?handicap = null)
        {
            if (team == null)
            {
                if (betType == BetType.Moneyline || betType == BetType.Spread || betType == BetType.Team_Total_Points)
                {
                    throw new Exception($"TeamType is required for {betType} Bets!");
                }
            }

            if (side == null)
            {
                if (betType == BetType.Total_Points || betType == BetType.Team_Total_Points)
                {
                    throw new Exception($"SideType is required for {betType} Bets!");
                }
            }

            if (handicap == null)
            {
                if (betType == BetType.Spread || betType == BetType.Total_Points || betType == BetType.Team_Total_Points)
                {
                    throw new Exception($"Handicap is required for {betType} Bets!");
                }
            }

            // get request uri
            var sb = new StringBuilder();

            sb.Append($"v1/line?sportId={sportId}");
            sb.Append($"&leagueId={leagueId}");
            sb.Append($"&eventId={eventId}");
            sb.Append($"&betType={betType.ToString().ToUpper()}");
            sb.Append($"&oddsFormat={oddsFormat.ToString().ToUpper()}");
            sb.Append($"&periodNumber={periodNumber}"); // i.e. for soccer: 0 = Game, 1 = 1st Half, 2 = 2nd Half

            if (team != null)
            {
                sb.Append($"&team={team.ToString().ToUpper()}");
            }

            if (side != null)
            {
                sb.Append($"&side={side.ToString().ToUpper()}");
            }

            if (handicap != null)
            {
                sb.Append($"&handicap={handicap.ToString().ToUpper()}");
            }

            var uri = sb.ToString();

            return(GetJsonAsync <GetLineResponse>(uri));
        }
        protected async Task <Feed> GetFeed(int sportId, int[] leagueIds, OddsFormat format, string currency, long lastTimestamp, int isLive)
        {
            //if (!IsFairFeedRequest(lastTimestamp))
            //    throw new Exception(
            //        string.Format(
            //            "Too many feed requests. Minimum interval time between request is {0} seconds or {1} seconds when specifying the last parameter",
            //            MinimumFeedRefresh,
            //            MinimumFeedRefreshWithLast));

            _lastFeedRequest = DateTime.Now;
            var uri = GetFeedRequestUri(sportId, leagueIds, format, currency, lastTimestamp, isLive);

            return((await GetXmlAsync <FeedResponse>(uri)).Feed);
        }
        public PinnacleClient(string clientId, string password, string currencyCode, OddsFormat oddsFormat)
        {
            _clientId    = clientId;
            _password    = password;
            CurrencyCode = currencyCode;
            OddsFormat   = oddsFormat;

            _httpClient = new HttpClient {
                BaseAddress = new Uri(BaseAddress)
            };

            // put auth header into httpclient
            _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
                                                                                            Convert.ToBase64String(
                                                                                                Encoding.ASCII.GetBytes(string.Format("{0}:{1}", _clientId, _password))));
        }
        protected string GetFeedRequestUri(int sportId, int[] leagueId, OddsFormat format, string currency, long lastTimestamp, int isLive)
        {
            var sb = new StringBuilder();

            sb.AppendFormat("feed?sportid={0}", sportId);
            if (leagueId.Length > 0)
            {
                sb.AppendFormat("&leagueid={0}", string.Join("-", leagueId));
            }
            sb.AppendFormat("&oddsformat={0}", (int)format);
            sb.AppendFormat("&currencycode={0}", currency);

            if (lastTimestamp > 0)
            {
                sb.AppendFormat("&last={0}", lastTimestamp);
            }

            if (isLive == 0 || isLive == 1)
            {
                sb.AppendFormat("&islive={0}", isLive);
            }

            return(sb.ToString());
        }
Esempio n. 6
0
 public PinnacleClient(string currencyCode, OddsFormat oddsFormat, HttpClient httpClient)
 {
     CurrencyCode = currencyCode;
     OddsFormat   = oddsFormat;
     _httpClient  = httpClient;
 }
 public async Task <Feed> GetFeed(int sportId, int[] leagueIds, OddsFormat format, string currency, long lastTimestamp, bool isLive)
 {
     return(await GetFeed(sportId, leagueIds, format, currency, lastTimestamp, isLive? 1 : 0));
 }
 public async Task <Feed> GetFeed(int sportId, int[] leagueIds, OddsFormat format, string currency)
 {
     return(await GetFeed(sportId, leagueIds, format, currency, -1, -1));
 }
Esempio n. 9
0
 public Task <TeaserGroupsResponse> GetTeaserGroups(OddsFormat format) => JsonGetAsync <TeaserGroupsResponse>(RequestStringSegment.TeaserGroups, format);
Esempio n. 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sportId"></param>
        /// <param name="leagueId"></param>
        /// <param name="eventId"></param>
        /// <param name="periodNumber">0 for sports other than soccer, soccer: 0 = Game, 1 = 1st Half, 2 = 2nd Half</param>
        /// <param name="betType"></param>
        /// <param name="oddsFormat"></param>
        /// <param name="team"></param>
        /// <param name="side"></param>
        /// <param name="handicap"></param>
        /// <returns></returns>
        public Task <GetLineResponse> GetLine(int sportId, int leagueId, long eventId, int periodNumber, BetType betType, OddsFormat oddsFormat,
                                              TeamType?team = null, SideType?side = null, decimal?handicap = null)
        {
            if (team == null)
            {
                if (betType == BetType.MoneyLine || betType == BetType.Spread || betType == BetType.TeamTotalPoints)
                {
                    throw new Exception(string.Format("TeamType is required for {0} Bets!", betType));
                }
            }

            if (side == null)
            {
                if (betType == BetType.TotalPoints || betType == BetType.TeamTotalPoints)
                {
                    throw new Exception(string.Format("SideType is required for {0} Bets!", betType));
                }
            }

            if (handicap == null)
            {
                if (betType == BetType.Spread || betType == BetType.TotalPoints || betType == BetType.TeamTotalPoints)
                {
                    throw new Exception(string.Format("Handicap is required for {0} Bets!", betType));
                }
            }

            // get request uri
            var sb = new StringBuilder();

            sb.AppendFormat("v1/line?sportId={0}", sportId);
            sb.AppendFormat("&leagueId={0}", leagueId);
            sb.AppendFormat("&eventId={0}", eventId);
            sb.AppendFormat("&betType={0}", betType.ToString().ToUpper());
            sb.AppendFormat("&oddsFormat={0}", oddsFormat.ToString().ToUpper());
            sb.AppendFormat("&periodNumber={0}", periodNumber);                 // i.e. for soccer: 0 = Game, 1 = 1st Half, 2 = 2nd Half

            if (team != null)
            {
                sb.AppendFormat("&team={0}", team.ToString().ToUpper());
            }

            if (side != null)
            {
                sb.AppendFormat("&side={0}", side.ToString().ToUpper());
            }

            if (handicap != null)
            {
                sb.AppendFormat("&handicap={0}", handicap.ToString().ToUpper());
            }

            var uri = sb.ToString();

            return(JsonGetAsync <GetLineResponse>(uri));
        }
 public StraightLineRequest(int sportId, int leagueId, long eventId, int period, OddsFormat format, BetType betType, decimal?handicap = null, TeamType?team = null, SideType?side = null)
 {
     SportId      = sportId;
     LeagueId     = leagueId;
     EventId      = eventId;
     PeriodNumber = period;
     OddsFormat   = format.ToString();
     BetType      = betType.ToString();
     Handicap     = handicap;
     Team         = team == null ? null : team.ToString();
     Side         = side == null ? null : side.ToString();
 }