Exemplo n.º 1
0
        private static async Task Main(string[] args)
        {
            Logger.Info("Starting...");

            try
            {
                AppConfig config;

                using (var r = new StreamReader("appsettings.json"))
                {
                    var json = r.ReadToEnd();
                    config = JsonConvert.DeserializeObject <AppConfig>(json);
                }

                using (var httpClient =
                           HttpClientFactory.GetNewInstance(config.Username, config.Password, true, config.BaseUrl))
                {
                    var api = new PinnacleClient(config.Currency, config.OddsFormat, httpClient);

                    long lastFixture = 0;
                    long lastLine    = 0;

                    var fixtures = await api.GetFixtures(new GetFixturesRequest(SampleSportId, lastFixture));

                    var lines = await api.GetOdds(new GetOddsRequest(fixtures.SportId,
                                                                     fixtures.Leagues.Select(i => i.Id).ToList(), lastLine, false));

                    var leagues = await api.GetLeagues(SampleSportId);

                    // Subsequent calls to GetOdds or GetFixtures should pass these 'Last' values to get only what changed since instead of the full snapshot
                    lastFixture = fixtures.Last;
                    lastLine    = lines.Last;

                    SaveResultsToOutputFolder(fixtures, lines, leagues);
                }

                Console.WriteLine("Done!");
                Logger.Info("Done!");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Logger.Error(e, "Exception in Task Run.");
            }

            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        private static async Task Main(string[] args)
        {
            Logger.Info("Starting...");

            try
            {
                AppConfig config;

                /*
                 * add a appsettings.json file that looks like this or feed the settings in some other ways
                 *       {
                 *        "Username": "******",
                 *        "Password": "******",
                 *        "Currency": "GBP",
                 *        "OddsFormat": "DECIMAL",
                 *        "BaseUrl": "https://api.pinnacle.com/"
                 *      }
                 */
                using (var r = new StreamReader("appsettings.json"))
                {
                    var json = r.ReadToEnd();
                    config = JsonConvert.DeserializeObject <AppConfig>(json);
                }

                using (var httpClient =
                           HttpClientFactory.GetNewInstance(config.Username, config.Password, true, config.BaseUrl))
                {
                    var api = new PinnacleClient(config.Currency, config.OddsFormat, httpClient);

                    long lastFixture = 0;
                    long lastLine    = 0;

                    var fixtures = await api.GetFixtures(new GetFixturesRequest(SampleSportId, lastFixture));

                    var lines = await api.GetOdds(new GetOddsRequest(fixtures.SportId, fixtures.Leagues.Select(i => i.Id).ToList(), lastLine, false));

                    var leagues = await api.GetLeagues(SampleSportId);

                    // Subsequent calls to GetOdds or GetFixtures should pass these 'Last' values to get only what changed since instead of the full snapshot
                    lastFixture = fixtures.Last;
                    lastLine    = lines.Last;

                    SaveResultsToOutputFolder(fixtures, lines, leagues);

                    var betResponse = await PlaceRandomBet(lines, api);

                    Console.WriteLine($"Status={betResponse.Status}, BetId={betResponse.BetId}, ErrorCode={betResponse.ErrorCode}, UniqueRequestId={betResponse.UniqueRequestId}");
                }

                Console.WriteLine("Done!");
                Logger.Info("Done!");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Logger.Error(e, "Exception in Task Run.");
            }

            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }