| | | 1 | | using EHonda.KicktippAi.Core; |
| | | 2 | | |
| | | 3 | | namespace KicktippIntegration; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Interface for the Kicktipp client responsible for interacting with kicktipp.de |
| | | 7 | | /// Authentication is handled automatically via dependency injection |
| | | 8 | | /// </summary> |
| | | 9 | | public interface IKicktippClient |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Get open predictions for a specific community |
| | | 13 | | /// </summary> |
| | | 14 | | /// <param name="community">The community name</param> |
| | | 15 | | /// <returns>List of matches with open predictions</returns> |
| | | 16 | | Task<List<Match>> GetOpenPredictionsAsync(string community); |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Place a bet for a specific match in a community |
| | | 20 | | /// </summary> |
| | | 21 | | /// <param name="community">The community name</param> |
| | | 22 | | /// <param name="match">The match to bet on</param> |
| | | 23 | | /// <param name="prediction">The bet prediction</param> |
| | | 24 | | /// <param name="overrideBet">If true, overrides an existing bet for this match</param> |
| | | 25 | | /// <returns>True if the bet was placed successfully</returns> |
| | | 26 | | Task<bool> PlaceBetAsync(string community, Match match, BetPrediction prediction, bool overrideBet = false); |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Place multiple bets for matches in a community |
| | | 30 | | /// </summary> |
| | | 31 | | /// <param name="community">The community name</param> |
| | | 32 | | /// <param name="bets">Dictionary of matches and their corresponding predictions</param> |
| | | 33 | | /// <param name="overrideBets">If true, overrides existing bets for the matches</param> |
| | | 34 | | /// <returns>True if all bets were placed successfully</returns> |
| | | 35 | | Task<bool> PlaceBetsAsync(string community, Dictionary<Match, BetPrediction> bets, bool overrideBets = false); |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// Get the current standings (league table) for a specific community |
| | | 39 | | /// </summary> |
| | | 40 | | /// <param name="community">The community name</param> |
| | | 41 | | /// <returns>List of team standings ordered by position</returns> |
| | | 42 | | Task<List<TeamStanding>> GetStandingsAsync(string community); |
| | | 43 | | |
| | | 44 | | /// <summary> |
| | | 45 | | /// Get matches with detailed information including recent history for both teams |
| | | 46 | | /// </summary> |
| | | 47 | | /// <param name="community">The community name</param> |
| | | 48 | | /// <returns>List of matches with their recent history context</returns> |
| | | 49 | | Task<List<MatchWithHistory>> GetMatchesWithHistoryAsync(string community); |
| | | 50 | | |
| | | 51 | | /// <summary> |
| | | 52 | | /// Get home/away specific match history for both teams from a match |
| | | 53 | | /// </summary> |
| | | 54 | | /// <param name="community">The community name</param> |
| | | 55 | | /// <param name="homeTeam">The home team name</param> |
| | | 56 | | /// <param name="awayTeam">The away team name</param> |
| | | 57 | | /// <returns>Tuple containing home team's home history and away team's away history</returns> |
| | | 58 | | Task<(List<MatchResult> homeTeamHomeHistory, List<MatchResult> awayTeamAwayHistory)> GetHomeAwayHistoryAsync(string |
| | | 59 | | |
| | | 60 | | /// <summary> |
| | | 61 | | /// Get head-to-head match history between two teams |
| | | 62 | | /// </summary> |
| | | 63 | | /// <param name="community">The community name</param> |
| | | 64 | | /// <param name="homeTeam">The home team name</param> |
| | | 65 | | /// <param name="awayTeam">The away team name</param> |
| | | 66 | | /// <returns>List of head-to-head match results</returns> |
| | | 67 | | Task<List<MatchResult>> GetHeadToHeadHistoryAsync(string community, string homeTeam, string awayTeam); |
| | | 68 | | |
| | | 69 | | /// <summary> |
| | | 70 | | /// Get head-to-head match history between two teams with detailed column breakdown for CSV export |
| | | 71 | | /// </summary> |
| | | 72 | | /// <param name="community">The community name</param> |
| | | 73 | | /// <param name="homeTeam">The home team name</param> |
| | | 74 | | /// <param name="awayTeam">The away team name</param> |
| | | 75 | | /// <returns>List of head-to-head results with separate League, Matchday, PlayedAt columns</returns> |
| | | 76 | | Task<List<HeadToHeadResult>> GetHeadToHeadDetailedHistoryAsync(string community, string homeTeam, string awayTeam); |
| | | 77 | | |
| | | 78 | | /// <summary> |
| | | 79 | | /// Get placed predictions for the current matchday |
| | | 80 | | /// </summary> |
| | | 81 | | /// <param name="community">The community name</param> |
| | | 82 | | /// <returns>Dictionary of matches and their placed predictions</returns> |
| | | 83 | | Task<Dictionary<Match, BetPrediction?>> GetPlacedPredictionsAsync(string community); |
| | | 84 | | |
| | | 85 | | /// <summary> |
| | | 86 | | /// Get open bonus questions for a specific community |
| | | 87 | | /// </summary> |
| | | 88 | | /// <param name="community">The community name</param> |
| | | 89 | | /// <returns>List of bonus questions with open predictions</returns> |
| | | 90 | | Task<List<BonusQuestion>> GetOpenBonusQuestionsAsync(string community); |
| | | 91 | | |
| | | 92 | | /// <summary> |
| | | 93 | | /// Place bonus predictions for a community |
| | | 94 | | /// </summary> |
| | | 95 | | /// <param name="community">The community name</param> |
| | | 96 | | /// <param name="predictions">Dictionary of bonus question IDs and their corresponding predictions</param> |
| | | 97 | | /// <param name="overridePredictions">If true, overrides existing predictions for the questions</param> |
| | | 98 | | /// <returns>True if all predictions were placed successfully</returns> |
| | | 99 | | Task<bool> PlaceBonusPredictionsAsync(string community, Dictionary<string, BonusPrediction> predictions, bool overri |
| | | 100 | | |
| | | 101 | | /// <summary> |
| | | 102 | | /// Get placed bonus predictions for a community |
| | | 103 | | /// </summary> |
| | | 104 | | /// <param name="community">The community name</param> |
| | | 105 | | /// <returns>Dictionary of bonus question IDs and their currently placed predictions, or null if no prediction is pl |
| | | 106 | | Task<Dictionary<string, BonusPrediction?>> GetPlacedBonusPredictionsAsync(string community); |
| | | 107 | | } |
| | | 108 | | |
| | | 109 | | /// <summary> |
| | | 110 | | /// Represents login credentials for kicktipp.de |
| | | 111 | | /// Used for dependency injection configuration |
| | | 112 | | /// </summary> |
| | | 113 | | public record KicktippCredentials(string Username, string Password) |
| | | 114 | | { |
| | | 115 | | public bool IsValid => !string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password); |
| | | 116 | | } |
| | | 117 | | |
| | | 118 | | /// <summary> |
| | | 119 | | /// Configuration class for Kicktipp credentials |
| | | 120 | | /// Used with IOptions pattern for dependency injection |
| | | 121 | | /// </summary> |
| | | 122 | | public class KicktippOptions |
| | | 123 | | { |
| | | 124 | | public const string ConfigurationSectionName = "Kicktipp"; |
| | | 125 | | |
| | 1 | 126 | | public string Username { get; set; } = string.Empty; |
| | 1 | 127 | | public string Password { get; set; } = string.Empty; |
| | | 128 | | |
| | 1 | 129 | | public KicktippCredentials ToCredentials() => new(Username, Password); |
| | | 130 | | } |
| | | 131 | | |
| | | 132 | | /// <summary> |
| | | 133 | | /// Represents a bet prediction with home and away goals |
| | | 134 | | /// </summary> |
| | | 135 | | public record BetPrediction(int HomeGoals, int AwayGoals) |
| | | 136 | | { |
| | | 137 | | public override string ToString() => $"{HomeGoals}:{AwayGoals}"; |
| | | 138 | | } |