package main;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.time.LocalDateTime;

import parser.OddsPortal;

public class Main {

    public static void main(String[] args) {

        // testExpektParser();
        updateFromOddsportal();

//        testArbMatches();
//        op.getHistoricMatches("soccer", "japan", "j2-league", "2020");
        // callingRScript();
    }

    private static void callingRScript() throws IOException {
        System.out.println(System.getProperty("user.dir"));
        final String rPath = System.getProperty("user.dir") + "\\src\\RScript\\scorePrediction.R";

        final Process exec = Runtime.getRuntime().exec("C:\\Program Files\\R\\R-3.6.3\\bin\\Rscript.exe " + rPath);

        final BufferedReader stdInput = new BufferedReader(new InputStreamReader(exec.getInputStream()));

        final BufferedReader stdError = new BufferedReader(new InputStreamReader(exec.getErrorStream()));

        // Read the output from the command
        System.out.println("Here is the standard output of the command:\n");
        String s = null;
        while ((s = stdInput.readLine()) != null) {
            System.out.println(s);
        }
        // Read any errors from the attempted command
        System.out.println("Here is the standard error of the command (if any):\n");
        while ((s = stdError.readLine()) != null) {
            System.out.println(s);
        }
    }

    private static void testArbMatches() {
        new ArbChecker();
    }

    private static void updateFromOddsportal() {
        final OddsPortal op = new OddsPortal();

        System.out.println("Getting One days ago matches");
        op.getMatches(LocalDateTime.now().plusDays(-1));
        System.out.println("Getting Today days ago matches");
        op.getMatches(LocalDateTime.now().plusDays(0));
         System.out.println("Getting Tomorrows matches");
        op.getMatches(LocalDateTime.now().plusDays(1));
        System.out.println("Getting Next days matches");
        op.getMatches(LocalDateTime.now().plusDays(2));

    }

}
