diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 46346fbc..146c0ac7 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -54,7 +54,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v3 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -68,4 +68,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/develop-build.yml b/.github/workflows/develop-build.yml index b58703a9..cc3d2fcf 100644 --- a/.github/workflows/develop-build.yml +++ b/.github/workflows/develop-build.yml @@ -10,14 +10,6 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Setup .NET 6 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '6.0.x' - - name: Setup .NET 7 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '7.0.x' - name: Setup .NET 8 uses: actions/setup-dotnet@v1 with: diff --git a/.github/workflows/master-build-daily.yml b/.github/workflows/master-build-daily.yml index 78a18f90..f3d88e50 100644 --- a/.github/workflows/master-build-daily.yml +++ b/.github/workflows/master-build-daily.yml @@ -10,14 +10,6 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Setup .NET 6 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '6.0.x' - - name: Setup .NET 7 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '7.0.x' - name: Setup .NET 8 uses: actions/setup-dotnet@v1 with: diff --git a/.github/workflows/master-build.yml b/.github/workflows/master-build.yml index 6bfbd9b5..97159bb2 100644 --- a/.github/workflows/master-build.yml +++ b/.github/workflows/master-build.yml @@ -9,14 +9,6 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Setup .NET 6 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '6.0.x' - - name: Setup .NET 7 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '7.0.x' - name: Setup .NET 8 uses: actions/setup-dotnet@v1 with: diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index 0c0dd54d..d9be0c27 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -10,14 +10,6 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Setup .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.x - - name: Setup .NET 7 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '7.0.x' - name: Setup .NET 8 uses: actions/setup-dotnet@v1 with: diff --git a/Nhl.Api.Common/Http/NhlStatsApiHttpClient.cs b/Nhl.Api.Common/Http/NhlStatsApiHttpClient.cs deleted file mode 100644 index 09ede558..00000000 --- a/Nhl.Api.Common/Http/NhlStatsApiHttpClient.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Net.Http; - -namespace Nhl.Api.Common.Http; - -/// -/// The dedicated NHL statistics HTTP Client for the Nhl.Api -/// -public class NhlStatsApiHttpClient : NhlApiHttpClient -{ - private static readonly object _lock = new object(); - private static HttpClient _httpClient; - - /// - /// The NHL statistics NHL HTTP API endpoint - /// - public const string ClientApiUrl = "https://statsapi.web.nhl.com/api/"; - - - /// - /// The dedicated NHL statistics HTTP Client for the Nhl.Api - /// - public NhlStatsApiHttpClient() : base(clientApiUri: ClientApiUrl, clientVersion: "v1", timeoutInSeconds: 30) - { - - } - - /// - /// The HTTP client for the Nhl.Api - /// - public override HttpClient HttpClient - { - get - { - lock (_lock) - { - _httpClient ??= new HttpClient() - { - BaseAddress = new Uri($"{Client}{ClientVersion}"), - Timeout = Timeout - }; - - return _httpClient; - } - } - } -} diff --git a/Nhl.Api.Common/Nhl.Api.Common.csproj b/Nhl.Api.Common/Nhl.Api.Common.csproj index 92b8a693..4e565125 100644 --- a/Nhl.Api.Common/Nhl.Api.Common.csproj +++ b/Nhl.Api.Common/Nhl.Api.Common.csproj @@ -1,8 +1,8 @@  - 3.3.0 - net6.0;net7.0;net8.0 + 3.4.0 + net8.0 true diff --git a/Nhl.Api.Domain/Enumerations/Player/PlayerEnum.cs b/Nhl.Api.Domain/Enumerations/Player/PlayerEnum.cs index 2a7663b5..89a1c616 100644 --- a/Nhl.Api.Domain/Enumerations/Player/PlayerEnum.cs +++ b/Nhl.Api.Domain/Enumerations/Player/PlayerEnum.cs @@ -1,3 +1,5 @@ +namespace Nhl.Api.Models.Enumerations.Player; + /// /// The NHL player enumeration of all NHL players /// diff --git a/Nhl.Api.Domain/Enumerations/Player/PlayerEnumFileGeneratorHelper.cs b/Nhl.Api.Domain/Enumerations/Player/PlayerEnumFileGeneratorHelper.cs index 9590fc6f..c5e18abf 100644 --- a/Nhl.Api.Domain/Enumerations/Player/PlayerEnumFileGeneratorHelper.cs +++ b/Nhl.Api.Domain/Enumerations/Player/PlayerEnumFileGeneratorHelper.cs @@ -48,6 +48,7 @@ public static async Task UpdatePlayerEnumToFile(string path) } using StreamWriter outputFile = new(Path.Combine(path, "InternalPlayerEnum.cs")); + outputFile.WriteLine($"namespace Nhl.Api.Models.Enumerations.Player;"); outputFile.WriteLine($"/// "); outputFile.WriteLine($"/// The NHL player enumeration of all NHL players"); outputFile.WriteLine($"/// "); diff --git a/Nhl.Api.Domain/Models/Player/ExpressionGoalieFilterBuilder.cs b/Nhl.Api.Domain/Models/Player/ExpressionGoalieFilterBuilder.cs new file mode 100644 index 00000000..016644dc --- /dev/null +++ b/Nhl.Api.Domain/Models/Player/ExpressionGoalieFilterBuilder.cs @@ -0,0 +1,449 @@ +using Nhl.Api.Common.Extensions; +using System.ComponentModel; +using System.Runtime.Serialization; +using System.Text; + +namespace Nhl.Api.Models.Player; + +/// +/// The expression filter for the NHL API for goalie statistics, this class is used to build the expression filter for the NHL API for goalie statistics
+/// Here is an example of how to use the PlayerFilterExpressionBuilder to build an expression filter for the NHL API for goalie statistics
+///
+/// +/// expressionFilter +/// .AddFilter(GoalieStatisticsFilter.SavePercentage) +/// .GreaterThanOrEqualTo(0.900) +/// .And() +/// .AddFilter(GoalieStatisticsFilter.Goals) +/// .GreaterThan(1) +/// .And() +/// .AddFilter(GoalieStatisticsFilter.Assists) +/// .GreaterThan(1) +/// .And() +/// .AddFilter(GoalieStatisticsFilter.SkaterFullName) +/// .Contains("Connor") +/// .Build(); +/// +/// +///
+public class GoalieFilterExpressionBuilder +{ + private readonly StringBuilder _filterExpression = new("factCayenneExp="); + + /// + /// Adds a filter to the expression filter to filter by any of the returned properties + /// + /// The filter to add to the expression + /// The builder to continue building the expression + public GoalieFilterExpressionBuilder AddFilter(GoalieStatisticsFilter goalieStatisticsFilter) + { + _filterExpression.Append($"{goalieStatisticsFilter.GetEnumMemberValue()}"); + return this; + } + + /// + /// Adds a 'contains' filter to the expression filter + /// + /// The value to search for + /// The builder to continue building the expression + public GoalieFilterExpressionBuilder Contains(object value) + { + _filterExpression.Append($" like '%{value}%'"); + return this; + } + + /// + /// Adds a 'not contains' filter to the expression filter + /// + /// The value to exclude + /// The builder to continue building the expression + public GoalieFilterExpressionBuilder NotContains(object value) + { + _filterExpression.Append($" not like '%{value}%'"); + return this; + } + + /// + /// Adds an 'AND' logical operator to the expression filter + /// + /// The builder to continue building the expression + public GoalieFilterExpressionBuilder And() + { + _filterExpression.Append(" and "); + return this; + } + + /// + /// Adds an 'OR' logical operator to the expression filter + /// + /// The builder to continue building the expression + public GoalieFilterExpressionBuilder Or() + { + _filterExpression.Append(" or "); + return this; + } + + /// + /// Adds a start group '(' to the expression filter + /// + /// The builder to continue building the expression + public GoalieFilterExpressionBuilder StartGroup() + { + _filterExpression.Append("("); + return this; + } + + /// + /// Adds an end group ')' to the expression filter + /// + /// The builder to continue building the expression + public GoalieFilterExpressionBuilder EndGroup() + { + _filterExpression.Append(")"); + return this; + } + + /// + /// Adds an 'equal to' filter to the expression filter. + /// + /// The value to compare against. + /// The builder to continue building the expression. + public GoalieFilterExpressionBuilder EqualTo(object value) + { + if (value is string) + { + _filterExpression.Append($" = '{value}' "); + } + else + { + _filterExpression.Append($" = {value} "); + } + + return this; + } + + /// + /// Adds a 'not equal to' filter to the expression filter + /// + /// The value to compare against. + /// The builder to continue building the expression + public GoalieFilterExpressionBuilder NotEqualTo(object value) + { + if (value is string) + { + _filterExpression.Append($" != '{value}' "); + } + else + { + _filterExpression.Append($" != {value} "); + } + + return this; + } + + /// + /// Adds a 'greater than' filter to the expression filter + /// + /// The value to compare against. + /// The builder to continue building the expression + public GoalieFilterExpressionBuilder GreaterThan(object value) + { + if (value is string) + { + _filterExpression.Append($" > '{value}' "); + } + else + { + _filterExpression.Append($" > {value} "); + } + + return this; + } + + /// + /// Adds a 'greater than or equal to' filter to the expression filter + /// + /// The value to compare against + /// The builder to continue building the expression + public GoalieFilterExpressionBuilder GreaterThanOrEqualTo(object value) + { + if (value is string) + { + _filterExpression.Append($" >= '{value}' "); + } + else + { + _filterExpression.Append($" >= {value} "); + } + + return this; + } + + /// + /// Adds a 'less than' filter to the expression filter + /// + /// The value to compare against + /// The builder to continue building the expression + public GoalieFilterExpressionBuilder LessThan(object value) + { + if (value is string) + { + _filterExpression.Append($" < '{value}' "); + + } + else + { + _filterExpression.Append($" < {value} "); + } + + return this; + } + + /// + /// Adds a 'less than or equal to' filter to the expression filter + /// + /// The value to compare against + /// The builder to continue building the expression + public GoalieFilterExpressionBuilder LessThanOrEqualTo(object value) + { + if (value is string) + { + _filterExpression.Append($" <= '{value}' "); + } + else + { + _filterExpression.Append($" <= {value} "); + } + + return this; + } + + /// + /// Converts the expression filter to a string + /// + /// The expression filter as a string + public override string ToString() + { + return _filterExpression.ToString(); + } + + /// + /// Builds the expression filter for the NHL player statistics + /// + /// The built expression filter. + public ExpressionGoalieFilter Build() + { + return new ExpressionGoalieFilter(_filterExpression.ToString()); + } + + /// + /// An empty expression filter for the NHL goalie statistics + /// + public static ExpressionGoalieFilter Empty => new(string.Empty); +} + + +/// +/// A class that represents the expression filter for the NHL API for goalie statistics
+/// See for an example of how to use the expression filter for NHL goalie to filter results +///
+public class ExpressionGoalieFilter +{ + private readonly string _filterExpression; + + /// + /// A class that represents the expression filter for the NHL goalie statistics + /// + public ExpressionGoalieFilter(string filterExpression) + { + _filterExpression = filterExpression; + } + + /// + /// The ToString method for the expression filter to return the raw expression for filtering
+ /// See for an example of how to use the expression filter + ///
+ /// The raw expression for filtering + public override string ToString() + { + return _filterExpression.ToString(); + } + + /// + /// Determines if the expression is valid based on the length of the expression + /// + public bool IsValidExpression => _filterExpression.Length > 15; + + /// + /// An empty expression filter for the NHL goalie statistics + /// + public static ExpressionGoalieFilter Empty => new(string.Empty); + +} + +/// +/// A class that represents the NHL goalie statistics filter for searching statistics +/// +public enum GoalieStatisticsFilter +{ + /// + /// The NHL goalie assists + /// + [Description("assists")] + [EnumMember(Value = "assists")] + Assists, + + /// + /// The NHL goalie games played + /// + [Description("gamesPlayed")] + [EnumMember(Value = "gamesPlayed")] + GamesPlayed, + + /// + /// The NHL goalie games started + /// + [Description("gamesStarted")] + [EnumMember(Value = "gamesStarted")] + GamesStarted, + + /// + /// The NHL goalie full name + /// + [Description("goalieFullName")] + [EnumMember(Value = "goalieFullName")] + GoalieFullName, + + /// + /// The NHL goalie goals + /// + [Description("goals")] + [EnumMember(Value = "goals")] + Goals, + + /// + /// The NHL goalie goals against + /// + [Description("goalsAgainst")] + [EnumMember(Value = "goalsAgainst")] + GoalsAgainst, + + /// + /// The NHL goalie goals against average + /// + [Description("goalsAgainst")] + [EnumMember(Value = "goalsAgainstAverage")] + GoalsAgainstAverage, + + /// + /// The NHL goalie last name + /// + [EnumMember(Value = "lastName")] + [Description("lastName")] + LastName, + + /// + /// The NHL goalie losses + /// + [Description("losses")] + [EnumMember(Value = "losses")] + Losses, + + /// + /// The NHL goalie OT losses + /// + [Description("otLosses")] + [EnumMember(Value = "otLosses")] + OvertimeLosses, + + /// + /// The NHL goalie penalty minutes + /// + [Description("penaltyMinutes")] + [EnumMember(Value = "penaltyMinutes")] + PenaltyMinutes, + + /// + /// The NHL goalie player identifier + /// + [Description("playerId")] + [EnumMember(Value = "playerId")] + PlayerId, + + /// + /// The NHL goalie points + /// + [Description("points")] + [EnumMember(Value = "points")] + Points, + + /// + /// The NHL goalie save percentage + /// + [Description("savePct")] + [EnumMember(Value = "savePct")] + SavePercentage, + + /// + /// The NHL goalie saves + /// + [Description("saves")] + [EnumMember(Value = "saves")] + Saves, + + /// + /// The NHL goalie season identifier + /// + [Description("seasonId")] + [EnumMember(Value = "seasonId")] + SeasonId, + + /// + /// The NHL goalie shoots and catches + /// + [Description("shootsCatches")] + [EnumMember(Value = "shootsCatches")] + ShootsCatches, + + /// + /// The NHL shots against + /// + [Description("shotsAgainst")] + [EnumMember(Value = "shotsAgainst")] + ShotsAgainst, + + /// + /// The NHL shutouts + /// + [Description("shutouts")] + [EnumMember(Value = "shutouts")] + Shutouts, + + /// + /// The NHL goalie team abbreviations + /// + [Description("teamAbbrevs")] + [EnumMember(Value = "teamAbbrevs")] + TeamAbbrevs, + + /// + /// The NHL goalie ties + /// + [Description("ties")] + [EnumMember(Value = "ties")] + Ties, + + /// + /// The NHL goalie time on ice + /// + [Description("timeOnIce")] + [EnumMember(Value = "timeOnIce")] + TimeOnIce, + + /// + /// The NHL goalie wins + /// + [Description("wins")] + [EnumMember(Value = "wins")] + Wins +} \ No newline at end of file diff --git a/Nhl.Api.Domain/Models/Player/ExpressionPlayerFilterBuilder.cs b/Nhl.Api.Domain/Models/Player/ExpressionPlayerFilterBuilder.cs new file mode 100644 index 00000000..4f22d49d --- /dev/null +++ b/Nhl.Api.Domain/Models/Player/ExpressionPlayerFilterBuilder.cs @@ -0,0 +1,470 @@ +using Nhl.Api.Common.Extensions; +using System.ComponentModel; +using System.Runtime.Serialization; +using System.Text; + +namespace Nhl.Api.Models.Player; + +/// +/// The expression filter for the NHL API for player statistics, this class is used to build the expression filter for the NHL API for player statistics
+/// Here is an example of how to use the PlayerFilterExpressionBuilder to build an expression filter for the NHL API for player statistics
+///
+/// +/// expressionFilter +/// .AddFilter(PlayerStatisticsFilter.GamesPlayed) +/// .GreaterThanOrEqualTo(25) +/// .And() +/// .AddFilter(PlayerStatisticsFilter.Goals) +/// .GreaterThan(5) +/// .And() +/// .AddFilter(PlayerStatisticsFilter.Assists) +/// .GreaterThan(10) +/// .And() +/// .AddFilter(PlayerStatisticsFilter.SkaterFullName) +/// .Contains("Ale") +/// .Build(); +/// +/// +///
+public class PlayerFilterExpressionBuilder + +{ + private readonly StringBuilder _filterExpression = new("factCayenneExp="); + + /// + /// Adds a filter to the expression filter to filter by any of the returned properties + /// + /// The player statistics filter + /// The builder to continue building the expression + public PlayerFilterExpressionBuilder AddFilter(PlayerStatisticsFilter playerStatisticsFilter) + { + _filterExpression.Append($"{playerStatisticsFilter.GetEnumMemberValue()}"); + return this; + } + + /// + /// Adds a 'contains' filter to the expression filter + /// + /// The value to search for + /// The builder to continue building the expression + public PlayerFilterExpressionBuilder Contains(object value) + { + _filterExpression.Append($" like '%{value}%'"); + return this; + } + + /// + /// Adds a 'not contains' filter to the expression filter + /// + /// The value to exclude + /// The builder to continue building the expression + public PlayerFilterExpressionBuilder NotContains(object value) + { + _filterExpression.Append($" not like '%{value}%'"); + return this; + } + + /// + /// Adds an 'AND' logical operator to the expression filter + /// + /// The builder to continue building the expression + public PlayerFilterExpressionBuilder And() + { + _filterExpression.Append(" and "); + return this; + } + + /// + /// Adds an 'OR' logical operator to the expression filter + /// + /// The builder to continue building the expression + public PlayerFilterExpressionBuilder Or() + { + _filterExpression.Append(" or "); + return this; + } + + /// + /// Adds a start group '(' to the expression filter + /// + /// The builder to continue building the expression + public PlayerFilterExpressionBuilder StartGroup() + { + _filterExpression.Append("("); + return this; + } + + /// + /// Adds an end group ')' to the expression filter + /// + /// The builder to continue building the expression + public PlayerFilterExpressionBuilder EndGroup() + { + _filterExpression.Append(")"); + return this; + } + + /// + /// Adds an 'equal to' filter to the expression filter. + /// + /// The value to compare against. + /// The builder to continue building the expression. + public PlayerFilterExpressionBuilder EqualTo(object value) + { + if (value is string) + { + _filterExpression.Append($" = '{value}' "); + } + else + { + _filterExpression.Append($" = {value} "); + } + + return this; + } + + /// + /// Adds a 'not equal to' filter to the expression filter + /// + /// The value to compare against. + /// The builder to continue building the expression + public PlayerFilterExpressionBuilder NotEqualTo(object value) + { + if (value is string) + { + _filterExpression.Append($" != '{value}' "); + } + else + { + _filterExpression.Append($" != {value} "); + } + + return this; + } + + /// + /// Adds a 'greater than' filter to the expression filter + /// + /// The value to compare against. + /// The builder to continue building the expression + public PlayerFilterExpressionBuilder GreaterThan(object value) + { + _filterExpression.Append($" > {value} "); + return this; + } + + /// + /// Adds a 'greater than or equal to' filter to the expression filter + /// + /// The value to compare against + /// The builder to continue building the expression + public PlayerFilterExpressionBuilder GreaterThanOrEqualTo(object value) + { + if (value is string) + { + _filterExpression.Append($" > '{value}' "); + } + else + { + _filterExpression.Append($" > {value} "); + } + + return this; + } + + /// + /// Adds a 'less than' filter to the expression filter + /// + /// The value to compare against + /// The builder to continue building the expression + public PlayerFilterExpressionBuilder LessThan(object value) + { + if (value is string) + { + _filterExpression.Append($" < '{value}' "); + + } + else + { + _filterExpression.Append($" < {value} "); + } + + return this; + } + + /// + /// Adds a 'less than or equal to' filter to the expression filter + /// + /// The value to compare against + /// The builder to continue building the expression + public PlayerFilterExpressionBuilder LessThanOrEqualTo(object value) + { + if (value is string) + { + _filterExpression.Append($" <= '{value}' "); + } + else + { + _filterExpression.Append($" <= {value} "); + } + + return this; + } + + /// + /// Converts the expression filter to a string + /// + /// The expression filter as a string + public override string ToString() + { + return _filterExpression.ToString(); + } + + /// + /// Builds the expression filter for the NHL player statistics + /// + /// The built expression filter. + public ExpressionPlayerFilter Build() + { + return new ExpressionPlayerFilter(_filterExpression.ToString()); + } + + /// + /// An empty expression filter for the NHL player statistics + /// + public static ExpressionPlayerFilter Empty => new(string.Empty); +} + + +/// +/// A class that represents the expression filter for the NHL API for player statistics
+/// See for an example of how to use the expression filter for NHL players to filter results +///
+public class ExpressionPlayerFilter +{ + private readonly string _filterExpression; + + /// + /// A class that represents the expression filter for the NHL player statistics + /// + public ExpressionPlayerFilter(string filterExpression) + { + _filterExpression = filterExpression; + } + + /// + /// The ToString method for the expression filter to return the raw expression for filtering
+ /// See for an example of how to use the expression filter + ///
+ /// The raw expression for filtering + public override string ToString() + { + return _filterExpression.ToString(); + } + + /// + /// Determines if the expression is valid based on the length of the expression + /// + public bool IsValidExpression => _filterExpression.Length > 15; + + /// + /// An empty expression filter for the NHL player statistics + /// + public static ExpressionPlayerFilter Empty => new(string.Empty); + +} + +/// +/// The enumeration for the NHL player statistics information for the NHL API for player statistics +/// +public enum PlayerStatisticsFilter +{ + /// + /// Assists + /// + [Description("assists")] + [EnumMember(Value = "assists")] + Assists, + + /// + /// Even goals + /// + [Description("evGoals")] + [EnumMember(Value = "evGoals")] + EvenGoals, + + /// + /// Even points + /// + [Description("evPoints")] + [EnumMember(Value = "evPoints")] + EvenPoints, + + /// + /// Faceoff win percentage + /// + [Description("faceoffWinPct")] + [EnumMember(Value = "faceoffWinPct")] + FaceoffWinPercentage, + + /// + /// Game-winning goals + /// + [Description("gameWinningGoals")] + [EnumMember(Value = "gameWinningGoals")] + GameWinningGoals, + + /// + /// Games played + /// + [Description("gamesPlayed")] + [EnumMember(Value = "gamesPlayed")] + GamesPlayed, + + /// + /// Goals + /// + [Description("goals")] + [EnumMember(Value = "goals")] + Goals, + + /// + /// Last name + /// + [Description("lastName")] + [EnumMember(Value = "lastName")] + LastName, + + /// + /// Overtime goals + /// + [Description("otGoals")] + [EnumMember(Value = "otGoals")] + OvertimeGoals, + + /// + /// Penalty minutes + /// + [Description("penaltyMinutes")] + [EnumMember(Value = "penaltyMinutes")] + PenaltyMinutes, + + /// + /// Player ID + /// + [Description("playerId")] + [EnumMember(Value = "playerId")] + PlayerId, + + /// + /// Plus-minus + /// + [Description("plusMinus")] + [EnumMember(Value = "plusMinus")] + PlusMinus, + + /// + /// Points + /// + [Description("points")] + [EnumMember(Value = "points")] + Points, + + /// + /// Points per game + /// + [Description("pointsPerGame")] + [EnumMember(Value = "pointsPerGame")] + PointsPerGame, + + /// + /// Position code + /// + [Description("positionCode")] + [EnumMember(Value = "positionCode")] + PositionCode, + + /// + /// Power play goals + /// + [Description("ppGoals")] + [EnumMember(Value = "ppGoals")] + PowerPlayGoals, + + /// + /// Power play points + /// + [Description("ppPoints")] + [EnumMember(Value = "ppPoints")] + PowerPlayPoints, + + /// + /// Season ID + /// + [Description("seasonId")] + [EnumMember(Value = "seasonId")] + SeasonIdentifier, + + /// + /// Short-handed goals + /// + [Description("shGoals")] + [EnumMember(Value = "shGoals")] + ShortHandedGoals, + + /// + /// Short-handed points + /// + [Description("shPoints")] + [EnumMember(Value = "shPoints")] + ShortHandedPoints, + + /// + /// Shooting percentage + /// + [Description("shootingPct")] + [EnumMember(Value = "shootingPct")] + ShootingPercentage, + + /// + /// Shoots/Catches + /// + [Description("shootsCatches")] + [EnumMember(Value = "shootsCatches")] + ShootsCatches, + + /// + /// Shots + /// + [Description("shots")] + [EnumMember(Value = "shots")] + Shots, + + /// + /// Skater full name + /// + [Description("skaterFullName")] + [EnumMember(Value = "skaterFullName")] + SkaterFullName, + + /// + /// Team abbreviations + /// + [Description("teamAbbrevs")] + [EnumMember(Value = "teamAbbrevs")] + TeamAbbreviation, + + /// + /// Time on ice per game + /// + [Description("timeOnIcePerGame")] + [EnumMember(Value = "timeOnIcePerGame")] + TimeOnIcePerGame, + + /// + /// Weight + /// + [Description("weight")] + [EnumMember(Value = "weight")] + Weight +} diff --git a/Nhl.Api.Domain/Models/Player/ShootsCatches.cs b/Nhl.Api.Domain/Models/Player/ShootsCatches.cs new file mode 100644 index 00000000..9e7fc63d --- /dev/null +++ b/Nhl.Api.Domain/Models/Player/ShootsCatches.cs @@ -0,0 +1,17 @@ +namespace Nhl.Api.Models.Player; + +/// +/// A class representing the a player's or goalie's shooting or catching hand +/// +public static class ShootsCatches +{ + /// + /// Shoots and/or catches left + /// + public const string Left = "L"; + + /// + /// Shoots and/or catches right + /// + public const string Right = "R"; +} diff --git a/Nhl.Api.Domain/Models/Season/SeasonYears.cs b/Nhl.Api.Domain/Models/Season/SeasonYears.cs index 75f1d6e1..068e8149 100644 --- a/Nhl.Api.Domain/Models/Season/SeasonYears.cs +++ b/Nhl.Api.Domain/Models/Season/SeasonYears.cs @@ -450,4 +450,28 @@ public class SeasonYear /// The NHL season 2028-2029 /// public const string season20282029 = "20282029"; + /// + /// The NHL season 2029-2030 + /// + public const string season20292030 = "20292030"; + /// + /// The NHL season 2030-2031 + /// + public const string season20302031 = "20302031"; + /// + /// The NHL season 2031-2032 + /// + public const string season20312032 = "20312032"; + /// + /// The NHL season 2032-2033 + /// + public const string season20322033 = "20322033"; + /// + /// The NHL season 2033-2034 + /// + public const string season20332034 = "20332034"; + /// + /// The NHL season 2034-2035 + /// + public const string season20342035 = "20342035"; } diff --git a/Nhl.Api.Domain/Models/Statistics/GoalieStatisticsFilterResult.cs b/Nhl.Api.Domain/Models/Statistics/GoalieStatisticsFilterResult.cs new file mode 100644 index 00000000..93b76685 --- /dev/null +++ b/Nhl.Api.Domain/Models/Statistics/GoalieStatisticsFilterResult.cs @@ -0,0 +1,190 @@ +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace Nhl.Api.Models.Statistics; + +/// +/// The returned results of the NHL goalie statistics summary search with filters +/// +public class GoalieStatisticsFilterResult +{ + /// + /// The NHL goalie statistics result by summary of statistics for a goalie and season + /// + [JsonProperty("data")] + public List GoalieStatisticsResults { get; set; } + + /// + /// The total number of results based on the search criteria
+ /// Example: 42 + ///
+ [JsonProperty("total")] + public int Total { get; set; } +} + +/// +/// The NHL goalie statistics result by summary of statistics for a goalie and season +/// +public class GoalieStatisticsResult +{ + /// + /// The number of assists made by the NHL goalie in the season.
+ /// Example: 1 + ///
+ [JsonProperty("assists")] + public int Assists { get; set; } + + /// + /// The number of games played by the NHL goalie in the season.
+ /// Example: 42 + ///
+ [JsonProperty("gamesPlayed")] + public int GamesPlayed { get; set; } + + /// + /// The number of games started by the NHL goalie in the season.
+ /// Example: 42 + ///
+ [JsonProperty("gamesStarted")] + public int GamesStarted { get; set; } + + /// + /// The full name of the NHL goalie.
+ /// Example: "Connor Hellebuyck" + ///
+ [JsonProperty("goalieFullName")] + public string GoalieFullName { get; set; } + + /// + /// The number of goals scored by the NHL goalie in the season.
+ /// Example: 0 + ///
+ [JsonProperty("goals")] + public int Goals { get; set; } + + /// + /// The number of goals scored against the NHL goalie in the season.
+ /// Example: 102 + ///
+ [JsonProperty("goalsAgainst")] + public int GoalsAgainst { get; set; } + + /// + /// The average number of goals scored against the NHL goalie per game in the season.
+ /// Example: 2.21119 + ///
+ [JsonProperty("goalsAgainstAverage")] + public double GoalsAgainstAverage { get; set; } + + /// + /// The last name of the NHL goalie
+ /// Example: "Hellebuyck" + ///
+ [JsonProperty("lastName")] + public string LastName { get; set; } + + /// + /// The number of losses by the NHL goalie in the season
+ /// Example: 20 + ///
+ [JsonProperty("losses")] + public int Losses { get; set; } + + /// + /// The number of losses in overtime by the NHL goalie in the season
+ /// Example: 2 + ///
+ [JsonProperty("otLosses")] + public int OvertimeLosses { get; set; } + + /// + /// The total number of penalty minutes served by the NHL goalie in the season
+ /// Example: 2 + ///
+ [JsonProperty("penaltyMinutes")] + public int PenaltyMinutes { get; set; } + + /// + /// The unique identifier of the NHL goalie
+ /// Example: 8479973 + ///
+ [JsonProperty("playerId")] + public int PlayerId { get; set; } + + /// + /// The total number of points earned by the NHL goalie in the season
+ /// Example: 2 + ///
+ [JsonProperty("points")] + public int Points { get; set; } + + /// + /// The percentage of shots saved by the NHL goalie in the season
+ /// Example: 0.91711 + ///
+ [JsonProperty("savePct")] + public double SavePercentage { get; set; } + + /// + /// The total number of saves made by the NHL goalie in the season
+ /// Example: 102 + ///
+ [JsonProperty("saves")] + public int Saves { get; set; } + + /// + /// The identifier of the season for which the statistics are recorded
+ /// Example: 20232024 + ///
+ [JsonProperty("seasonId")] + public int SeasonId { get; set; } + + /// + /// Indicates whether the NHL goalie catches with the left or right hand
+ /// Example: "L" + ///
+ [JsonProperty("shootsCatches")] + public string ShootsCatches { get; set; } + + /// + /// The total number of shots faced by the NHL goalie in the season
+ /// Example: 1342 + ///
+ [JsonProperty("shotsAgainst")] + public int ShotsAgainst { get; set; } + + /// + /// The total number of shutouts recorded by the NHL goalie in the season
+ /// Example: 2 + ///
+ [JsonProperty("shutouts")] + public int Shutouts { get; set; } + + /// + /// The abbreviated name of the team the NHL goalie plays for
+ /// Example: "TOR, CGY" + ///
+ [JsonProperty("teamAbbrevs")] + public string TeamAbbreviations { get; set; } + + /// + /// The number of ties recorded by the NHL goalie in the season
+ /// Example: 2 + ///
+ [JsonProperty("ties")] + public object? Ties { get; set; } + + /// + /// The total time on ice for the NHL goalie in the season, in seconds
+ /// Example: 50591 + ///
+ [JsonProperty("timeOnIce")] + public int TimeOnIce { get; set; } + + /// + /// The number of wins recorded by the NHL goalie in the season
+ /// Example: 20 + ///
+ [JsonProperty("wins")] + public int Wins { get; set; } +} diff --git a/Nhl.Api.Domain/Models/Statistics/PlayerStatisticsFilterResult.cs b/Nhl.Api.Domain/Models/Statistics/PlayerStatisticsFilterResult.cs new file mode 100644 index 00000000..1dce0401 --- /dev/null +++ b/Nhl.Api.Domain/Models/Statistics/PlayerStatisticsFilterResult.cs @@ -0,0 +1,211 @@ +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace Nhl.Api.Models.Statistics; + +/// +/// The returned results of the NHL player statistics summary search with filters +/// +public class PlayerStatisticsFilterResult +{ + /// + /// The NHL player statistics result by summary of statistics for a player and season + /// + [JsonProperty("data")] + public List PlayerStatisticsResults { get; set; } + + /// + /// The total number of results based on the search criteria
+ /// Example: 4 + ///
+ [JsonProperty("total")] + public int Total { get; set; } +} + +/// +/// The NHL player statistics result by summary of statistics for a player and season +/// +public class PlayerStatisticsResult +{ + /// + /// The NHL player assists
+ /// Example: 4 + ///
+ [JsonProperty("assists")] + public int Assists { get; set; } + + /// + /// The NHL player even strength goals
+ /// Example: 5 + ///
+ [JsonProperty("evGoals")] + public int EvenStrengthGoals { get; set; } + + /// + /// The NHL player even strength points
+ /// Example: 6 + ///
+ [JsonProperty("evPoints")] + public int EvenStrengthPoints { get; set; } + + /// + /// The NHL player faceoff win percentage
+ /// Example: 0.543012 + ///
+ [JsonProperty("faceoffWinPct")] + public decimal? FaceoffWinPercentage { get; set; } + + /// + /// The NHL player game winning goals
+ /// Example: 2 + ///
+ [JsonProperty("gameWinningGoals")] + public int GameWinningGoals { get; set; } + + /// + /// The NHL player games played
+ /// Example: 78 + ///
+ [JsonProperty("gamesPlayed")] + public int GamesPlayed { get; set; } + + /// + /// The NHL player goals
+ /// Example: 10 + ///
+ [JsonProperty("goals")] + public int Goals { get; set; } + + /// + /// The NHL player last name
+ /// Example: "Smith" + ///
+ [JsonProperty("lastName")] + public string LastName { get; set; } + + /// + /// The NHL overtime goals
+ /// Example: 1 + ///
+ [JsonProperty("otGoals")] + public int OvertimeGoals { get; set; } + + /// + /// The NHL player penalty minutes
+ /// Example: 20 + ///
+ [JsonProperty("penaltyMinutes")] + public int PenaltyMinutes { get; set; } + + /// + /// The NHL player player identifier
+ /// Example: 8471234 + ///
+ [JsonProperty("playerId")] + public int PlayerId { get; set; } + + /// + /// The NHL player plus minus
+ /// Example: 5 + ///
+ [JsonProperty("plusMinus")] + public int PlusMinus { get; set; } + + /// + /// The NHL player points
+ /// Example: 20 + ///
+ [JsonProperty("points")] + public int Points { get; set; } + + /// + /// The NHL player points per game
+ /// Example: 0.356732 + ///
+ [JsonProperty("pointsPerGame")] + public decimal PointsPerGame { get; set; } + + /// + /// The NHL player position code
+ /// Example: "C" + ///
+ [JsonProperty("positionCode")] + public string PositionCode { get; set; } + + /// + /// The NHL player power play goals
+ /// Example: 3 + ///
+ [JsonProperty("ppGoals")] + public int PowerPlayGoals { get; set; } + + /// + /// The NHL player power play points
+ /// Example: 4 + ///
+ [JsonProperty("ppPoints")] + public int PowerPlayPoints { get; set; } + + /// + /// The NHL player season identifier
+ /// Example: 20202021 + ///
+ [JsonProperty("seasonId")] + public int SeasonId { get; set; } + + /// + /// The NHL player short handed goals
+ /// Example: 1 + ///
+ [JsonProperty("shGoals")] + public int ShortHandedGoals { get; set; } + + /// + /// The NHL player short handed points
+ /// Example: 2 + ///
+ [JsonProperty("shPoints")] + public int ShortHandedPoints { get; set; } + + /// + /// The NHL player shooting percentage
+ /// Example: 0.1234561 + ///
+ [JsonProperty("shootingPct")] + public decimal? ShootingPercentage { get; set; } + + /// + /// The NHL player shoots catches handedness
+ /// Example: "L" + ///
+ [JsonProperty("shootsCatches")] + public string ShootsCatches { get; set; } + + /// + /// The NHL player number of shots
+ /// Example: 100 + ///
+ [JsonProperty("shots")] + public int? Shots { get; set; } + + /// + /// The NHL player skater full name
+ /// Example: "John Smith" + ///
+ [JsonProperty("skaterFullName")] + public string SkaterFullName { get; set; } + + /// + /// The NHL player team abbreviations
+ /// Example: "TOR" + ///
+ [JsonProperty("teamAbbrevs")] + public string TeamAbbreviations { get; set; } + + /// + /// The NHL player time on ice per game
+ /// Example: 1234.45 + ///
+ [JsonProperty("timeOnIcePerGame")] + public decimal? TimeOnIcePerGame { get; set; } +} diff --git a/Nhl.Api.Domain/Nhl.Api.Domain.csproj b/Nhl.Api.Domain/Nhl.Api.Domain.csproj index 19868e38..8c1e447f 100644 --- a/Nhl.Api.Domain/Nhl.Api.Domain.csproj +++ b/Nhl.Api.Domain/Nhl.Api.Domain.csproj @@ -1,8 +1,8 @@  - 3.3.0 - net6.0;net7.0;net8.0 + 3.4.0 + net8.0 true diff --git a/Nhl.Api.Domain/Services/NhlStatisticsService.cs b/Nhl.Api.Domain/Services/NhlStatisticsService.cs deleted file mode 100644 index 5f282702..00000000 --- a/Nhl.Api.Domain/Services/NhlStatisticsService.cs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Nhl.Api.Tests/GlobalUsings.cs b/Nhl.Api.Tests/GlobalUsings.cs index 3c216335..17080eeb 100644 --- a/Nhl.Api.Tests/GlobalUsings.cs +++ b/Nhl.Api.Tests/GlobalUsings.cs @@ -2,4 +2,8 @@ global using Nhl.Api.Tests.Helpers.Attributes; global using System; global using System.Collections.Generic; +global using System.IO; +global using System.Text; global using System.Threading.Tasks; + +global using Nhl.Api.Models.Enumerations.Player; diff --git a/Nhl.Api.Tests/Nhl.Api.Tests.csproj b/Nhl.Api.Tests/Nhl.Api.Tests.csproj index 3ec5d8f0..9087c1a2 100644 --- a/Nhl.Api.Tests/Nhl.Api.Tests.csproj +++ b/Nhl.Api.Tests/Nhl.Api.Tests.csproj @@ -1,23 +1,31 @@  - 3.3.0 + 3.4.0 net8.0 false + true - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + + + + + + + + - - + + diff --git a/Nhl.Api.Tests/PlayerTests.cs b/Nhl.Api.Tests/PlayerTests.cs index d760b336..19d157e7 100644 --- a/Nhl.Api.Tests/PlayerTests.cs +++ b/Nhl.Api.Tests/PlayerTests.cs @@ -1,8 +1,7 @@ -using Nhl.Api.Enumerations.Game; -using Nhl.Api.Models.Enumerations.Player; +using Newtonsoft.Json; +using Nhl.Api.Enumerations.Game; using Nhl.Api.Models.Season; using System.Linq; -using System.Net.Http; namespace Nhl.Api.Tests; @@ -148,6 +147,79 @@ public async Task SearchAllActivePlayersAsync_Returns_Valid_Information(string q } + [TestMethod] + public async Task GetPlayerHeadshotImageAsync_PlayerEnum_InvalidSeasonYear_ThrowsArgumentException() + { + // Arrange + await using var nhlApi = new NhlApi(); + + // Act & Assert + await Assert.ThrowsExceptionAsync(async () => await nhlApi.GetPlayerHeadshotImageAsync(PlayerEnum.ConnorMcDavid8478402, "invalidYear")); + } + + [TestMethod] + public async Task GetPlayerHeadshotImageAsync_PlayerEnum_InvalidSeasonYear_ThrowsArgumentException_PlayerId() + { + // Arrange + await using var nhlApi = new NhlApi(); + + // Act & Assert + await Assert.ThrowsExceptionAsync(async () => await nhlApi.GetPlayerHeadshotImageAsync(8478402, "invalidYear")); + } + + [TestMethod] + public async Task GetPlayerHeadshotImageAsync_PlayerEnum_InvalidSeasonYear_layerId_Incorrect_Season_Year() + { + // Arrange + await using var nhlApi = new NhlApi(); + + // Act + var headshot = await nhlApi.GetPlayerHeadshotImageAsync(8478402, SeasonYear.season19971998); + + // Assert + Assert.IsNotNull(headshot); + Assert.AreEqual(headshot.Length, 0); + } + + [TestMethod] + public async Task GetPlayerHeadshotImageAsync_PlayerEnum_InvalidSeasonYear_PlayerEnum_Incorrect_Season_Year() + { + // Arrange + await using var nhlApi = new NhlApi(); + + // Act + var headshot = await nhlApi.GetPlayerHeadshotImageAsync(PlayerEnum.ConnorMcDavid8478402, SeasonYear.season19971998); + + // Assert + Assert.IsNotNull(headshot); + Assert.AreEqual(headshot.Length, 0); + } + + [TestMethod] + public async Task GetPlayerSeasonGameLogsBySeasonAndGameTypeAsync_ThrowsArgumentException_ForNullSeasonYear() + { + // Arrange + await using var nhlApi = new NhlApi(); + var playerId = 8478402; + var gameType = GameType.PreSeason; + + // Act & Assert + await Assert.ThrowsExceptionAsync(async () => await nhlApi.GetPlayerSeasonGameLogsBySeasonAndGameTypeAsync(playerId, null, gameType)); + } + + [TestMethod] + public async Task GetPlayerSeasonGameLogsBySeasonAndGameTypeAsync_ThrowsArgumentException_ForEmptySeasonYear() + { + // Arrange + await using var nhlApi = new NhlApi(); + var playerId = 8478402; + var gameType = GameType.RegularSeason; + var emptySeasonYear = ""; + + // Act & Assert + await Assert.ThrowsExceptionAsync(async () => await nhlApi.GetPlayerSeasonGameLogsBySeasonAndGameTypeAsync(playerId, emptySeasonYear, gameType)); + } + [TestMethodWithRetry(RetryCount = 5)] [DataRow(PlayerEnum.ConnorMcDavid8478402, SeasonYear.season20222023, GameType.RegularSeason)] [DataRow(PlayerEnum.SidneyCrosby8471675, SeasonYear.season20182019, GameType.RegularSeason)] @@ -490,6 +562,20 @@ public async Task GetGoalieInformationAsync_Test_PlayerId(int playerId) } + [TestMethodWithRetry(RetryCount = 5)] + [DataRow(8478402)] + public async Task GetGoalieInformationAsync_Test_ThrowsArgumentExceptionWithPlayerId(int playerId) + { + // Arrange + await using var nhlApi = new NhlApi(); + + // Act / Assert + await Assert.ThrowsExceptionAsync(async () => + { + await nhlApi.GetGoalieInformationAsync(playerId); + }); + } + [TestMethodWithRetry(RetryCount = 5)] [DataRow(PlayerEnum.ConnorMcDavid8478402)] @@ -643,33 +729,34 @@ public async Task TestSearchAllActivePlayersNoResultsAsync() } [TestMethodWithRetry(RetryCount = 5)] - [DataRow(PlayerHeadshotImageSize.Small)] - [DataRow(PlayerHeadshotImageSize.Medium)] - [DataRow(PlayerHeadshotImageSize.Large)] - public async Task TestDownloadPlayerHeadshotImageAsync(PlayerHeadshotImageSize playerHeadShotImageSize) + [DataRow("20222023")] + [DataRow("20182019")] + [DataRow("20202021")] + public async Task TestDownloadPlayerHeadshotImageAsync(string seasonYear) { // Arrange await using var nhlApi = new NhlApi(); // Act - var image = await nhlApi.GetPlayerHeadshotImageAsync(PlayerEnum.ZackKassian8475178, playerHeadShotImageSize); + var image = await nhlApi.GetPlayerHeadshotImageAsync(PlayerEnum.ConnorMcDavid8478402, seasonYear); // Assert Assert.IsNotNull(image); Assert.IsTrue(image.Length > 5000); } + [TestMethodWithRetry(RetryCount = 5)] - [DataRow(PlayerHeadshotImageSize.Small)] - [DataRow(PlayerHeadshotImageSize.Medium)] - [DataRow(PlayerHeadshotImageSize.Large)] - public async Task GetPlayerHeadshotImageAsync_TestDownload_PlayerHeadshot_ImageWithId(PlayerHeadshotImageSize playerHeadShotImageSize) + [DataRow("20222023")] + [DataRow("20182019")] + [DataRow("20202021")] + public async Task GetPlayerHeadshotImageAsync_TestDownload_PlayerHeadshot_ImageWithId(string seasonYear) { // Arrange await using var nhlApi = new NhlApi(); // Act - var image = await nhlApi.GetPlayerHeadshotImageAsync(8477932, playerHeadShotImageSize); + var image = await nhlApi.GetPlayerHeadshotImageAsync(8477932, seasonYear); // Assert Assert.IsNotNull(image); @@ -684,9 +771,9 @@ public async Task GetPlayerHeadshotImageAsync_Test_Download_PlayerHeadshotImage_ // Act / Assert - await Assert.ThrowsExceptionAsync(async () => + await Assert.ThrowsExceptionAsync(async () => { - var image = await nhlApi.GetPlayerHeadshotImageAsync(999999, PlayerHeadshotImageSize.Large); + var image = await nhlApi.GetPlayerHeadshotImageAsync(999999, SeasonYear.season20232024); }); } diff --git a/Nhl.Api.Tests/ProjectStructureTests.cs b/Nhl.Api.Tests/ProjectStructureTests.cs new file mode 100644 index 00000000..5de77aa8 --- /dev/null +++ b/Nhl.Api.Tests/ProjectStructureTests.cs @@ -0,0 +1,105 @@ +using Microsoft.Build.Locator; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.MSBuild; +using System.Linq; + +namespace Nhl.Api.Tests; + +[TestClass] +public class ProjectStructureTests +{ + + #region constants + private const string Nhl = "Nhl"; + private string[] _whiteListedFiles = ["AssemblyInfo.cs", "Program.cs", "Startup.cs", "GlobalUsings.cs", "InternalPlayerEnum.cs", "Microsoft.NET.Test.Sdk.Program.cs"]; + + #endregion + + [TestInitialize] + public void TestInitialize() + { + if (!MSBuildLocator.IsRegistered) + { + MSBuildLocator.RegisterDefaults(); + } + + RootDirectoryFolder.Refresh(); + } + + [TestMethod] + public void ValidateProjectStructure_Should_Be_Always_Contain_Nhl() + { + + var getSolutionFile = RootDirectoryFolder.GetFiles("*.sln", SearchOption.AllDirectories); + Assert.IsTrue(getSolutionFile.Length > 0); + + var projectFiles = RootDirectoryFolder.GetFiles("*.csproj", SearchOption.AllDirectories); + + CollectionAssert.AllItemsAreNotNull(projectFiles); + + foreach (var projectFile in projectFiles) + { + Assert.IsTrue(projectFile.Name.Contains(Nhl)); + Assert.IsTrue(projectFile.Length > 0); + } + } + + [TestMethod] + public void ValidateProjectStructure_Should_Never_Have_Domain_In_Namespace() + { + var errors = new StringBuilder(); + + var getSourceCSharpFiles = RootDirectoryFolder.GetFiles("*.cs", SearchOption.AllDirectories); + foreach (var sourceCSharpFile in getSourceCSharpFiles) + { + if (sourceCSharpFile.FullName.Contains("Tests")) + { + continue; + } + + var sourceCode = File.ReadAllText(sourceCSharpFile.FullName); + + if (sourceCode.Contains("namespace Nhl.Api.Domain")) + { + errors.Append("Domain namespace found in file: " + sourceCSharpFile.FullName + "\n"); + } + } + + Assert.IsTrue(errors.Length == 0, errors.ToString()); + } + + [TestMethod] + public async Task ValidateProjectStructure_Should_Never_Have_Non_File_Scoped_Namespace() + { + using var workspace = MSBuildWorkspace.Create(); + var errors = new StringBuilder(); + + var solutionFiles = RootDirectoryFolder.GetFiles("*.sln", SearchOption.AllDirectories); + var solution = await workspace.OpenSolutionAsync($"{solutionFiles.First().FullName}"); + + foreach (var project in solution.Projects) + { + var files = project.Documents; + + foreach (var file in files.Where(f => !_whiteListedFiles.Contains(f.Name))) + { + var syntaxTree = await file.GetSyntaxTreeAsync(); + var namespaceDeclaration = syntaxTree.GetRoot().DescendantNodes().FirstOrDefault(n => n.IsKind(SyntaxKind.FileScopedNamespaceDeclaration)); + + if (namespaceDeclaration is null) + { + errors.AppendLine($"{file.Name} has non-file scoped namespace\n"); + } + } + } + + var allErrors = errors.ToString(); + Assert.IsTrue(errors.Length == 0, errors.ToString()); + } + + #region Private Methods + private DirectoryInfo RootDirectoryFolder => Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent; + + #endregion +} diff --git a/Nhl.Api.Tests/StatisticsTests.cs b/Nhl.Api.Tests/StatisticsTests.cs index ff7329c3..a14cea9b 100644 --- a/Nhl.Api.Tests/StatisticsTests.cs +++ b/Nhl.Api.Tests/StatisticsTests.cs @@ -2,9 +2,12 @@ using Nhl.Api.Enumerations.Game; using Nhl.Api.Enumerations.Statistic; using Nhl.Api.Models.Game; +using Nhl.Api.Models.Player; using Nhl.Api.Models.Season; +using Nhl.Api.Models.Team; using System.Collections.Concurrent; using System.Linq; +using System.Threading; namespace Nhl.Api.Tests; @@ -23,7 +26,7 @@ public class StatisticsTests [DataRow(PlayerStatisticsType.TotalTimeOnIce, GameType.RegularSeason, SeasonYear.season20222023, 10)] [DataRow(PlayerStatisticsType.FaceOffPercentage, GameType.RegularSeason, SeasonYear.season20222023, 10)] - public async Task GetSkaterStatsisticsLeadersAsync_Returns_Valid_Information(PlayerStatisticsType playerStatisticsType, GameType gameType, string seasonYear, int limit) + public async Task GetSkaterStatisticsLeadersAsync_Returns_Valid_Information(PlayerStatisticsType playerStatisticsType, GameType gameType, string seasonYear, int limit) { // Arrange await using var nhlApi = new NhlApi(); @@ -87,7 +90,7 @@ public async Task GetSkaterStatsisticsLeadersAsync_Returns_Valid_Information(Pla [DataRow(GoalieStatisticsType.SavePercentage, GameType.RegularSeason, SeasonYear.season20222023, 10)] [DataRow(GoalieStatisticsType.Shutouts, GameType.RegularSeason, SeasonYear.season20222023, 10)] [DataRow(GoalieStatisticsType.Wins, GameType.RegularSeason, SeasonYear.season20222023, 10)] - public async Task GetGoalieStatsisticsLeadersAsync_Returns_Valid_Information(GoalieStatisticsType goalieStatisticsType, GameType gameType, string seasonYear, int limit) + public async Task GetGoalieStatisticsLeadersAsync_Returns_Valid_Information(GoalieStatisticsType goalieStatisticsType, GameType gameType, string seasonYear, int limit) { // Arrange await using var nhlApi = new NhlApi(); @@ -221,6 +224,7 @@ public async Task GetTotalPlayerStatisticValueByTypeAndSeasonAsync_Returns_Valid Assert.AreEqual(result.StatisticsTotals[PlayerGameCenterStatistic.HitGiven], 25); Assert.AreEqual(result.StatisticsTotals[PlayerGameCenterStatistic.HitReceived], 54); Assert.AreEqual(result.StatisticsTotals[PlayerGameCenterStatistic.FaceOffLost], 553); + Assert.AreEqual(result.StatisticsTotals[PlayerGameCenterStatistic.ShotOnGoal], 161); Assert.AreEqual(result.StatisticsTotals[PlayerGameCenterStatistic.MissedShot], 62); Assert.AreEqual(result.StatisticsTotals[PlayerGameCenterStatistic.Giveaway], 69); @@ -229,6 +233,7 @@ public async Task GetTotalPlayerStatisticValueByTypeAndSeasonAsync_Returns_Valid Assert.AreEqual(result.StatisticsTotals[PlayerGameCenterStatistic.CommittedPenalty], 12); break; + case 8479400: Assert.AreEqual(result.StatisticsTotals[PlayerGameCenterStatistic.FaceOffWon], 544); Assert.AreEqual(result.StatisticsTotals[PlayerGameCenterStatistic.BlockedShot], 59); @@ -424,4 +429,553 @@ public async Task GetTotalPlayerStatisticValuesByTypeAndSeasonAsync_Returns_Vali var item = JsonConvert.SerializeObject(list); } + + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetPlayerStatisticsBySeasonAndFilterAsync_Returns_Valid_Results_Based_On_Filter_Query() + { + // Arrange + var expressionFilter = new PlayerFilterExpressionBuilder(); + + // Act + var expression = expressionFilter + .AddFilter(PlayerStatisticsFilter.Assists) + .GreaterThan(10) + .And() + .AddFilter(PlayerStatisticsFilter.ShootsCatches) + .EqualTo(ShootsCatches.Left) + .And() + .AddFilter(PlayerStatisticsFilter.TeamAbbreviation) + .EqualTo(TeamCodes.TorontoMapleLeafs) + .Build(); + + await using var nhlApi = new NhlApi(); + + var result = await nhlApi.GetPlayerStatisticsBySeasonAndFilterExpressionAsync(SeasonYear.season20232024, expression); + + // Act + Assert.IsNotNull(expression); + Assert.IsNotNull(result); + Assert.IsTrue(result.Total >= 9); + + foreach (var player in result.PlayerStatisticsResults) + { + Assert.IsTrue(player.Assists > 10); + Assert.IsTrue(player.TeamAbbreviations == TeamCodes.TorontoMapleLeafs); + Assert.IsTrue(player.ShootsCatches == ShootsCatches.Left); + } + } + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetPlayerStatisticsBySeasonAndFilterAsync_Returns_Valid_Results_Based_On_Filter_Query_For_2000_Season() + { + // Arrange + await using var nhlApi = new NhlApi(); + var expressionFilter = new PlayerFilterExpressionBuilder(); + + // Act + var expression = expressionFilter + .AddFilter(PlayerStatisticsFilter.OvertimeGoals) + .GreaterThan(1) + .And() + .AddFilter(PlayerStatisticsFilter.ShootsCatches) + .EqualTo(ShootsCatches.Right) + .Build(); + + + var result = await nhlApi.GetPlayerStatisticsBySeasonAndFilterExpressionAsync(SeasonYear.season19992000, expression); + + // Act + Assert.IsNotNull(expression); + Assert.IsNotNull(result); + Assert.IsTrue(result.Total >= 8); + + foreach (var player in result.PlayerStatisticsResults) + { + Assert.IsTrue(player.OvertimeGoals > 1); + Assert.IsTrue(player.ShootsCatches == ShootsCatches.Right); + } + } + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetPlayerStatisticsBySeasonAndFilterAsync_Returns_Valid_Results_Based_On_Empty_Expression() + { + // Arrange + await using var nhlApi = new NhlApi(); + var expressionFilter = new PlayerFilterExpressionBuilder(); + + // Act + var expression = expressionFilter.Build(); + + var result = await nhlApi.GetPlayerStatisticsBySeasonAndFilterExpressionAsync(SeasonYear.season20102011, expression); + + // Act + Assert.IsNotNull(expression); + Assert.IsNotNull(result); + Assert.IsTrue(result.Total >= 800); + } + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetPlayerStatisticsBySeasonAndFilterAsync_Returns_Valid_Results_Based_On_Filter_Query_For_Complex_Query_1() + { + // Arrange + await using var nhlApi = new NhlApi(); + var expressionFilter = new PlayerFilterExpressionBuilder(); + + // Act + var expression = expressionFilter + .AddFilter(PlayerStatisticsFilter.OvertimeGoals) + .GreaterThan(1) + .And() + .AddFilter(PlayerStatisticsFilter.ShootsCatches) + .EqualTo(ShootsCatches.Right) + .And() + .AddFilter(PlayerStatisticsFilter.PointsPerGame) + .GreaterThan(0.7) + .And() + .AddFilter(PlayerStatisticsFilter.Goals) + .GreaterThanOrEqualTo(20) + .And() + .AddFilter(PlayerStatisticsFilter.Assists) + .GreaterThanOrEqualTo(20) + .And() + .AddFilter(PlayerStatisticsFilter.PlusMinus) + .GreaterThanOrEqualTo(10) + .Build(); + + + var result = await nhlApi.GetPlayerStatisticsBySeasonAndFilterExpressionAsync(SeasonYear.season20232024, expression); + + // Act + Assert.IsNotNull(expression); + Assert.IsNotNull(result); + Assert.IsTrue(result.Total >= 2); + + foreach (var player in result.PlayerStatisticsResults) + { + Assert.IsTrue(player.OvertimeGoals > 1); + Assert.IsTrue(player.ShootsCatches == ShootsCatches.Right); + Assert.IsTrue(player.PointsPerGame > 0.7m); + Assert.IsTrue(player.Goals >= 20); + Assert.IsTrue(player.Assists >= 20); + Assert.IsTrue(player.PlusMinus >= 10); + } + } + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetPlayerStatisticsBySeasonAndFilterAsync_Returns_Valid_Results_Based_On_Filter_Query_For_Complex_Query_2() + { + // Arrange + await using var nhlApi = new NhlApi(); + var expressionFilter = new PlayerFilterExpressionBuilder(); + + // Act + var expression = expressionFilter + .AddFilter(PlayerStatisticsFilter.OvertimeGoals) + .GreaterThan(1) + .And() + .AddFilter(PlayerStatisticsFilter.ShootsCatches) + .EqualTo(ShootsCatches.Right) + .And() + .AddFilter(PlayerStatisticsFilter.PointsPerGame) + .GreaterThan(0.7) + .And() + .AddFilter(PlayerStatisticsFilter.Goals) + .GreaterThanOrEqualTo(20) + .And() + .AddFilter(PlayerStatisticsFilter.Assists) + .GreaterThanOrEqualTo(20) + .And() + .AddFilter(PlayerStatisticsFilter.PlusMinus) + .GreaterThanOrEqualTo(10) + .And() + .StartGroup() + .AddFilter(PlayerStatisticsFilter.PenaltyMinutes) + .LessThanOrEqualTo(50) + .Or() + .AddFilter(PlayerStatisticsFilter.EvenGoals) + .GreaterThan(10) + .EndGroup() + .Build(); + + var result = await nhlApi.GetPlayerStatisticsBySeasonAndFilterExpressionAsync(SeasonYear.season20232024, expression); + + // Act + Assert.IsNotNull(expression); + Assert.IsNotNull(result); + Assert.IsTrue(result.Total >= 2); + + foreach (var player in result.PlayerStatisticsResults) + { + Assert.IsTrue(player.OvertimeGoals > 1); + Assert.IsTrue(player.ShootsCatches == ShootsCatches.Right); + Assert.IsTrue(player.PointsPerGame > 0.7m); + Assert.IsTrue(player.Goals >= 20); + Assert.IsTrue(player.Assists >= 20); + Assert.IsTrue(player.PlusMinus >= 10); + Assert.IsTrue(player.PenaltyMinutes <= 50 || player.EvenStrengthGoals > 10); + } + } + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetGoalieStatisticsBySeasonAndFilterAsync_Returns_Valid_Results_Based_On_Filter_With_No_Query() + { + // Arrange + await using var nhlApi = new NhlApi(); + + // Act + var result = await nhlApi.GetPlayerStatisticsBySeasonAndFilterExpressionAsync(SeasonYear.season20232024, ExpressionPlayerFilter.Empty); + + // Act + Assert.IsNotNull(result); + Assert.IsTrue(result.Total > 800); + + } + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetGoalieStatisticsBySeasonAndFilterAsync_Returns_Valid_Results_Based_On_Filter_Query_For_Simple_Query() + { + // Arrange + await using var nhlApi = new NhlApi(); + var expressionFilter = new GoalieFilterExpressionBuilder(); + + // Act + var expression = expressionFilter + .AddFilter(GoalieStatisticsFilter.Wins) + .GreaterThan(30) + .And() + .AddFilter(GoalieStatisticsFilter.GoalsAgainstAverage) + .LessThanOrEqualTo(3.15) + .Build(); + + var result = await nhlApi.GetGoalieStatisticsBySeasonAndFilterExpressionAsync(SeasonYear.season20232024, expression); + + // Act + Assert.IsNotNull(expression); + Assert.IsNotNull(result); + Assert.IsTrue(result.Total >= 1); + + foreach (var player in result.GoalieStatisticsResults) + { + Assert.IsTrue(player.Wins > 30); + Assert.IsTrue(player.GoalsAgainstAverage <= 3.15); + } + } + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetGoalieStatisticsBySeasonAndFilterAsync_Returns_Valid_Results_Based_On_Filter_Query_For_Empty_Query() + { + // Arrange + await using var nhlApi = new NhlApi(); + var expressionFilter = new GoalieFilterExpressionBuilder(); + + // Act + var result = await nhlApi.GetGoalieStatisticsBySeasonAndFilterExpressionAsync(SeasonYear.season20232024, ExpressionGoalieFilter.Empty); + + // Act + Assert.IsNotNull(result); + Assert.IsTrue(result.Total >= 81); + + } + + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetGoalieStatisticsBySeasonAndFilterAsync_Returns_Valid_Results_Based_On_Filter_Query_For_Complex_Query() + { + // Arrange + await using var nhlApi = new NhlApi(); + var expressionFilter = new GoalieFilterExpressionBuilder(); + + // Act + var expression = expressionFilter + .AddFilter(GoalieStatisticsFilter.Wins) + .GreaterThan(10) + .And() + .AddFilter(GoalieStatisticsFilter.GoalsAgainstAverage) + .LessThanOrEqualTo(3.5) + .And() + .AddFilter(GoalieStatisticsFilter.Shutouts) + .GreaterThan(0) + .And() + .StartGroup() + .AddFilter(GoalieStatisticsFilter.SavePercentage) + .GreaterThanOrEqualTo(0.901) + .Or() + .AddFilter(GoalieStatisticsFilter.PenaltyMinutes) + .GreaterThan(0) + .EndGroup() + .Build(); + + var result = await nhlApi.GetGoalieStatisticsBySeasonAndFilterExpressionAsync(SeasonYear.season20232024, expression); + + // Act + Assert.IsNotNull(expression); + Assert.IsNotNull(result); + Assert.IsTrue(result.Total >= 1); + + foreach (var player in result.GoalieStatisticsResults) + { + Assert.IsTrue(player.Wins > 10); + Assert.IsTrue(player.GoalsAgainstAverage <= 3.5); + Assert.IsTrue(player.Shutouts > 0); + Assert.IsTrue(player.SavePercentage >= 0.9 || player.PenaltyMinutes > 0); + } + } + + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetGoalieStatisticsBySeasonAndFilterAsync_Returns_Valid_Results_Based_On_Filter_Query_For_Complex_Query_2() + { + // Arrange + await using var nhlApi = new NhlApi(); + var expressionFilter = new GoalieFilterExpressionBuilder(); + + // Act + var expression = expressionFilter + .AddFilter(GoalieStatisticsFilter.Wins) + .LessThan(40) + .And() + .AddFilter(GoalieStatisticsFilter.GoalsAgainstAverage) + .LessThanOrEqualTo(3.5) + .And() + .AddFilter(GoalieStatisticsFilter.Shutouts) + .GreaterThan(0) + .And() + .StartGroup() + .AddFilter(GoalieStatisticsFilter.SavePercentage) + .GreaterThanOrEqualTo(0.900) + .Or() + .AddFilter(GoalieStatisticsFilter.PenaltyMinutes) + .GreaterThan(0) + .EndGroup() + .And() + .AddFilter(GoalieStatisticsFilter.GoalieFullName) + .Contains("An") + .And() + .AddFilter(GoalieStatisticsFilter.GoalieFullName) + .NotContains("Ze") + .And() + .AddFilter(GoalieStatisticsFilter.PlayerId) + .NotEqualTo(8471214) + .Build(); + + var result = await nhlApi.GetGoalieStatisticsBySeasonAndFilterExpressionAsync(SeasonYear.season20182019, expression); + + // Act + Assert.IsNotNull(expression); + Assert.IsNotNull(result); + Assert.IsTrue(result.Total >= 6); + + foreach (var player in result.GoalieStatisticsResults) + { + Assert.IsTrue(player.Wins < 40); + Assert.IsTrue(player.GoalsAgainstAverage <= 3.5); + Assert.IsTrue(player.Shutouts > 0); + Assert.IsTrue(player.SavePercentage >= 0.9 || player.Assists > 0); + Assert.IsTrue(player.GoalieFullName.Contains("An")); + Assert.IsTrue(!player.GoalieFullName.Contains("Ze")); + Assert.IsTrue(player.PlayerId != 8471214); + } + } + + [TestMethodWithRetry(RetryCount = 5)] + [ExpectedException(typeof(ArgumentException))] + public async Task GetGoalieStatisticsLeadersAsync_EmptySeasonYear_ThrowsArgumentException() + { + // Arrange + await using var nhlApi = new NhlApi(); + + var goalieStatisticsType = GoalieStatisticsType.Wins; + var gameType = GameType.RegularSeason; + string seasonYear = string.Empty; + var limit = 10; + var cancellationToken = CancellationToken.None; + + // Act / Assert + await nhlApi.GetGoalieStatisticsLeadersAsync(goalieStatisticsType, gameType, seasonYear, limit, cancellationToken); + } + + [TestMethodWithRetry(RetryCount = 5)] + [ExpectedException(typeof(ArgumentException))] + public async Task GetGoalieStatisticsLeadersAsync_InvalidSeasonYearLength_ThrowsArgumentException() + { + // Arrange + await using var nhlApi = new NhlApi(); + + var goalieStatisticsType = GoalieStatisticsType.Wins; + var gameType = GameType.RegularSeason; + var seasonYear = "2023"; // Invalid length + var limit = 10; + var cancellationToken = CancellationToken.None; + + // Act / Assert + await nhlApi.GetGoalieStatisticsLeadersAsync(goalieStatisticsType, gameType, seasonYear, limit, cancellationToken); + } + + [TestMethodWithRetry(RetryCount = 5)] + [ExpectedException(typeof(ArgumentException))] + public async Task GetGoalieStatisticsLeadersAsync_LimitLessThanOne_ThrowsArgumentException() + { + // Arrange + await using var nhlApi = new NhlApi(); + + var goalieStatisticsType = GoalieStatisticsType.Wins; + var gameType = GameType.RegularSeason; + var seasonYear = "20232024"; + var limit = 0; // Invalid limit + var cancellationToken = CancellationToken.None; + + // Act / Assert + await nhlApi.GetGoalieStatisticsLeadersAsync(goalieStatisticsType, gameType, seasonYear, limit, cancellationToken); + } + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetPlayerStatisticsBySeasonAndFilterExpressionAsync_ValidInput_ReturnsPlayerStatistics() + { + // Arrange + await using var nhlApi = new NhlApi(); + string seasonYear = "2023"; // Example season year + var expressionPlayerFilter = ExpressionPlayerFilter.Empty; // Example filter + PlayerStatisticsFilter playerStatisticsFilterToSortBy = PlayerStatisticsFilter.Points; // Example filter to sort by + int limit = 10; // Example limit + int offsetStart = 0; // Example offset + CancellationToken cancellationToken = default; + + // Act + var result = await nhlApi.GetPlayerStatisticsBySeasonAndFilterExpressionAsync(seasonYear, expressionPlayerFilter, playerStatisticsFilterToSortBy, limit, offsetStart, cancellationToken); + + // Assert + Assert.IsNotNull(result); + // Add more assertions based on expected result + } + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetPlayerStatisticsBySeasonAndFilterExpressionAsync_NullSeasonYear_ThrowsArgumentException() + { + // Arrange + await using var nhlApi = new NhlApi(); + string seasonYear = null; + var expressionPlayerFilter = ExpressionPlayerFilter.Empty; + PlayerStatisticsFilter playerStatisticsFilterToSortBy = PlayerStatisticsFilter.Points; + + int limit = 10; + int offsetStart = 0; + CancellationToken cancellationToken = default; + + // Act & Assert + await Assert.ThrowsExceptionAsync(() => nhlApi.GetPlayerStatisticsBySeasonAndFilterExpressionAsync(seasonYear, expressionPlayerFilter, playerStatisticsFilterToSortBy, limit, offsetStart, cancellationToken)); + } + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetPlayerStatisticsBySeasonAndFilterExpressionAsync_NullPlayerFilter_ThrowsArgumentException() + { + // Arrange + await using var nhlApi = new NhlApi(); + string seasonYear = "2023"; + ExpressionPlayerFilter expressionPlayerFilter = null; + PlayerStatisticsFilter playerStatisticsFilterToSortBy = PlayerStatisticsFilter.Points; + int limit = 10; + int offsetStart = 0; + CancellationToken cancellationToken = default; + + // Act & Assert + await Assert.ThrowsExceptionAsync(() => nhlApi.GetPlayerStatisticsBySeasonAndFilterExpressionAsync(seasonYear, expressionPlayerFilter, playerStatisticsFilterToSortBy, limit, offsetStart, cancellationToken)); + } + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetPlayerStatisticsBySeasonAndFilterExpressionAsync_InvalidLimit_ThrowsArgumentException() + { + // Arrange + await using var nhlApi = new NhlApi(); + string seasonYear = "2023"; + var expressionPlayerFilter = ExpressionPlayerFilter.Empty; + var playerStatisticsFilterToSortBy = PlayerStatisticsFilter.Points; + int limit = -5; // Invalid limit + int offsetStart = 0; + CancellationToken cancellationToken = default; + + // Act & Assert + await Assert.ThrowsExceptionAsync(() => nhlApi.GetPlayerStatisticsBySeasonAndFilterExpressionAsync(seasonYear, expressionPlayerFilter, playerStatisticsFilterToSortBy, limit, offsetStart, cancellationToken)); + } + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetPlayerStatisticsBySeasonAndFilterExpressionAsync_InvalidOffsetStart_ThrowsArgumentException() + { + // Arrange + await using var nhlApi = new NhlApi(); + string seasonYear = "2023"; + var expressionPlayerFilter = ExpressionPlayerFilter.Empty; + PlayerStatisticsFilter playerStatisticsFilterToSortBy = PlayerStatisticsFilter.Points; + int limit = 10; + int offsetStart = -3; // Invalid offset + CancellationToken cancellationToken = default; + + // Act & Assert + await Assert.ThrowsExceptionAsync(() => nhlApi.GetPlayerStatisticsBySeasonAndFilterExpressionAsync(seasonYear, expressionPlayerFilter, playerStatisticsFilterToSortBy, limit, offsetStart, cancellationToken)); + } + + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetGoalieStatisticsBySeasonAndFilterExpressionAsync_NullSeasonYear_ThrowsArgumentException() + { + // Arrange + await using var nhlApi = new NhlApi(); + string seasonYear = null; + var expressionPlayerFilter = ExpressionGoalieFilter.Empty; + GoalieStatisticsFilter playerStatisticsFilterToSortBy = GoalieStatisticsFilter.Wins; + + int limit = 10; + int offsetStart = 0; + CancellationToken cancellationToken = default; + + // Act & Assert + await Assert.ThrowsExceptionAsync(() => nhlApi.GetGoalieStatisticsBySeasonAndFilterExpressionAsync(seasonYear, expressionPlayerFilter, playerStatisticsFilterToSortBy, limit, offsetStart, cancellationToken)); + } + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetGoalieStatisticsBySeasonAndFilterExpressionAsync_NullPlayerFilter_ThrowsArgumentException() + { + // Arrange + await using var nhlApi = new NhlApi(); + string seasonYear = "2023"; + ExpressionGoalieFilter expressionPlayerFilter = null; + GoalieStatisticsFilter playerStatisticsFilterToSortBy = GoalieStatisticsFilter.Wins; + int limit = 10; + int offsetStart = 0; + CancellationToken cancellationToken = default; + + // Act & Assert + await Assert.ThrowsExceptionAsync(() => nhlApi.GetGoalieStatisticsBySeasonAndFilterExpressionAsync(seasonYear, expressionPlayerFilter, playerStatisticsFilterToSortBy, limit, offsetStart, cancellationToken)); + } + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetGoalieStatisticsBySeasonAndFilterExpressionAsync_InvalidLimit_ThrowsArgumentException() + { + // Arrange + await using var nhlApi = new NhlApi(); + string seasonYear = "2023"; + var expressionPlayerFilter = ExpressionGoalieFilter.Empty; + GoalieStatisticsFilter playerStatisticsFilterToSortBy = GoalieStatisticsFilter.Wins; + int limit = -5; // Invalid limit + int offsetStart = 0; + CancellationToken cancellationToken = default; + + // Act & Assert + await Assert.ThrowsExceptionAsync(() => nhlApi.GetGoalieStatisticsBySeasonAndFilterExpressionAsync(seasonYear, expressionPlayerFilter, playerStatisticsFilterToSortBy, limit, offsetStart, cancellationToken)); + } + + [TestMethodWithRetry(RetryCount = 5)] + public async Task GetGoalieStatisticsBySeasonAndFilterExpressionAsync_InvalidOffsetStart_ThrowsArgumentException() + { + // Arrange + await using var nhlApi = new NhlApi(); + string seasonYear = "2023"; + var expressionPlayerFilter = ExpressionGoalieFilter.Empty; + GoalieStatisticsFilter playerStatisticsFilterToSortBy = GoalieStatisticsFilter.Wins; + int limit = 10; + int offsetStart = -3; // Invalid offset + CancellationToken cancellationToken = default; + + // Act & Assert + await Assert.ThrowsExceptionAsync(() => nhlApi.GetGoalieStatisticsBySeasonAndFilterExpressionAsync(seasonYear, expressionPlayerFilter, playerStatisticsFilterToSortBy, limit, offsetStart, cancellationToken)); + } } diff --git a/Nhl.Api.Tests/StringTests.cs b/Nhl.Api.Tests/StringTests.cs index 1686555b..fcc9abdc 100644 --- a/Nhl.Api.Tests/StringTests.cs +++ b/Nhl.Api.Tests/StringTests.cs @@ -1,5 +1,4 @@ using Nhl.Api.Common.Extensions; -using Nhl.Api.Models.Enumerations.Player; namespace Nhl.Api.Tests; @@ -18,6 +17,34 @@ public class StringTests [DataRow("mønitor", "monitor")] [DataRow("éléphant", "elephant")] [DataRow("wôrld", "world")] + [DataRow("ÀÁÂÃÄÅ", "AAAAAA")] + [DataRow("Æ", "AE")] + [DataRow("ÇĆ", "CC")] + [DataRow("ÈÉÊË", "EEEE")] + [DataRow("ÌÍÎÏ", "IIII")] + [DataRow("ÐĐ", "DD")] + [DataRow("Ñ", "N")] + [DataRow("ÒÓÔÕÖ", "OOOOO")] + [DataRow("Ø", "O")] + [DataRow("ÙÚÛÜ", "UUUU")] + [DataRow("Š", "S")] + [DataRow("ÝŸ", "YY")] + [DataRow("Ž", "Z")] + [DataRow("àáâãä", "aaaaa")] + [DataRow("å", "a")] + [DataRow("æ", "ae")] + [DataRow("çć", "cc")] + [DataRow("đ", "d")] + [DataRow("èéêë", "eeee")] + [DataRow("ìíîï", "iiii")] + [DataRow("ð", "d")] + [DataRow("ñ", "n")] + [DataRow("òóôõö", "ooooo")] + [DataRow("ø", "o")] + [DataRow("ùúûü", "uuuu")] + [DataRow("š", "s")] + [DataRow("ýÿ", "yy")] + [DataRow("ž", "z")] public void ReplaceNonAsciiWithAscii_Returns_Correct_Ascii_String(string input, string expected) { var actual = PlayerEnumFileGeneratorHelper.ReplaceNonAsciiWithAscii(input); @@ -40,4 +67,73 @@ public void ReplaceNonAsciiWithAscii_Returns_Correct_Ascii_String_Extension(stri { Assert.AreEqual(input.ReplaceNonAsciiWithAscii(), expected); } + + [TestMethod] + [DataRow("ÀÁÂÃÄÅ", "AAAAAA")] + [DataRow("Æ", "AE")] + [DataRow("ÇĆ", "CC")] + [DataRow("ÈÉÊË", "EEEE")] + [DataRow("ÌÍÎÏ", "IIII")] + [DataRow("ÐĐ", "DD")] + [DataRow("Ñ", "N")] + [DataRow("ÒÓÔÕÖ", "OOOOO")] + [DataRow("Ø", "O")] + [DataRow("ÙÚÛÜ", "UUUU")] + [DataRow("Š", "S")] + [DataRow("ÝŸ", "YY")] + [DataRow("Ž", "Z")] + [DataRow("àáâãä", "aaaaa")] + [DataRow("å", "a")] + [DataRow("æ", "ae")] + [DataRow("çć", "cc")] + [DataRow("đ", "d")] + [DataRow("èéêë", "eeee")] + [DataRow("ìíîï", "iiii")] + [DataRow("ð", "d")] + [DataRow("ñ", "n")] + [DataRow("òóôõö", "ooooo")] + [DataRow("ø", "o")] + [DataRow("ùúûü", "uuuu")] + [DataRow("š", "s")] + [DataRow("ýÿ", "yy")] + [DataRow("ž", "z")] + public void ReplaceNonAsciiWithAscii_Test(string input, string expected) + { + // Arrange + // No need for arrange as we have input and expected values + + // Act + var result = input.ReplaceNonAsciiWithAscii(); + + // Assert + Assert.AreEqual(expected, result); + } + + [TestMethod] + public void ReplaceNonAsciiWithAscii_WithEmptyString_Test() + { + // Arrange + var input = ""; + var expected = ""; + + // Act + string result = input.ReplaceNonAsciiWithAscii(); + + // Assert + Assert.AreEqual(expected, result); + } + + [TestMethod] + public void ReplaceNonAsciiWithAscii_WithOnlyAsciiCharacters_Test() + { + // Arrange + var input = "HelloWorld"; + var expected = "HelloWorld"; + + // Act + string result = input.ReplaceNonAsciiWithAscii(); + + // Assert + Assert.AreEqual(expected, result); + } } diff --git a/Nhl.Api.Tests/TeamTests.cs b/Nhl.Api.Tests/TeamTests.cs index 1193db49..6e3c25c4 100644 --- a/Nhl.Api.Tests/TeamTests.cs +++ b/Nhl.Api.Tests/TeamTests.cs @@ -2,6 +2,7 @@ using Nhl.Api.Models.Enumerations.Team; using Nhl.Api.Models.Season; using Nhl.Api.Models.Team; +using Nhl.Api.Services; using System.Linq; namespace Nhl.Api.Tests; @@ -490,4 +491,45 @@ public void TeamNames_Ensure_Each_Name_Is_Correct() Assert.AreEqual(TeamNames.TorontoMapleLeafs, "Toronto Maple Leafs"); Assert.AreEqual(TeamNames.SeattleKraken, "Seattle Kraken"); } + + [TestMethodWithRetry(RetryCount = 5)] + [DataRow("Tampa Bay Lightning")] + [DataRow("Boston Bruins")] + [DataRow("New York Islanders")] + [DataRow("New York Rangers")] + [DataRow("Philadelphia Flyers")] + [DataRow("Pittsburgh Penguins")] + [DataRow("Washington Capitals")] + [DataRow("Carolina Hurricanes")] + [DataRow("Columbus Blue Jackets")] + [DataRow("Detroit Red Wings")] + [DataRow("Chicago Blackhawks")] + [DataRow("Nashville Predators")] + [DataRow("St. Louis Blues")] + [DataRow("Calgary Flames")] + [DataRow("Colorado Avalanche")] + [DataRow("Edmonton Oilers")] + [DataRow("Vancouver Canucks")] + [DataRow("Vegas Golden Knights")] + [DataRow("Anaheim Ducks")] + [DataRow("Dallas Stars")] + [DataRow("Los Angeles Kings")] + [DataRow("San Jose Sharks")] + [DataRow("Arizona Coyotes")] + [DataRow("Minnesota Wild")] + [DataRow("Winnipeg Jets")] + [DataRow("Buffalo Sabres")] + [DataRow("Florida Panthers")] + [DataRow("Montreal Canadiens")] + [DataRow("Ottawa Senators")] + [DataRow("Toronto Maple Leafs")] + [DataRow("Seattle Kraken")] + public void TeamNames_Ensure_Each_TeamAbbreviation_Is_Correct(string teamName) + { + var nhlTeamService = new NhlTeamService(); + var teamAbbreviation = nhlTeamService.GetTeamCodeIdentifierByTeamName(teamName); + + Assert.IsNotNull(teamAbbreviation); + Assert.AreEqual(teamAbbreviation.Length, 3); + } } diff --git a/Nhl.Api/Nhl.Api.csproj b/Nhl.Api/Nhl.Api.csproj index 9aa1cc6d..e5c1fefa 100644 --- a/Nhl.Api/Nhl.Api.csproj +++ b/Nhl.Api/Nhl.Api.csproj @@ -1,8 +1,8 @@  - 3.3.0 - net6.0;net7.0;net8.0 + 3.4.0 + net8.0 Nhl.Api Nhl.Api Copyright (c) 2024 Andre Fischbacher diff --git a/Nhl.Api/README.md b/Nhl.Api/README.md index fea34603..0addc470 100644 --- a/Nhl.Api/README.md +++ b/Nhl.Api/README.md @@ -122,6 +122,7 @@ Thank you to all the people in the hockey community, especially: - [Dispose()](#M-Nhl-Api-NhlApi-Dispose 'Nhl.Api.NhlApi.Dispose') - [DisposeAsync()](#M-Nhl-Api-NhlApi-DisposeAsync 'Nhl.Api.NhlApi.DisposeAsync') - [GetAllPlayersAsync(cancellationToken)](#M-Nhl-Api-NhlApi-GetAllPlayersAsync-System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetAllPlayersAsync(System.Threading.CancellationToken)') + - [GetAllPlayersStatisticValuesBySeasonAsync(seasonYear,gameType,cancellationToken)](#M-Nhl-Api-NhlApi-GetAllPlayersStatisticValuesBySeasonAsync-System-String,System-Nullable{Nhl-Api-Enumerations-Game-GameType},System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetAllPlayersStatisticValuesBySeasonAsync(System.String,System.Nullable{Nhl.Api.Enumerations.Game.GameType},System.Threading.CancellationToken)') - [GetAllRosterSeasonsByTeamAsync(teamId,cancellationToken)](#M-Nhl-Api-NhlApi-GetAllRosterSeasonsByTeamAsync-System-Int32,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetAllRosterSeasonsByTeamAsync(System.Int32,System.Threading.CancellationToken)') - [GetAllRosterSeasonsByTeamAsync(team,cancellationToken)](#M-Nhl-Api-NhlApi-GetAllRosterSeasonsByTeamAsync-Nhl-Api-Models-Enumerations-Team-TeamEnum,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetAllRosterSeasonsByTeamAsync(Nhl.Api.Models.Enumerations.Team.TeamEnum,System.Threading.CancellationToken)') - [GetAllSeasonsAsync()](#M-Nhl-Api-NhlApi-GetAllSeasonsAsync-System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetAllSeasonsAsync(System.Threading.CancellationToken)') @@ -139,6 +140,7 @@ Thank you to all the people in the hockey community, especially: - [GetGoalieInformationAsync(player,cancellationToken)](#M-Nhl-Api-NhlApi-GetGoalieInformationAsync-PlayerEnum,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetGoalieInformationAsync(PlayerEnum,System.Threading.CancellationToken)') - [GetGoalieSeasonGameLogsBySeasonAndGameTypeAsync(player,seasonYear,gameType,cancellationToken)](#M-Nhl-Api-NhlApi-GetGoalieSeasonGameLogsBySeasonAndGameTypeAsync-PlayerEnum,System-String,Nhl-Api-Enumerations-Game-GameType,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetGoalieSeasonGameLogsBySeasonAndGameTypeAsync(PlayerEnum,System.String,Nhl.Api.Enumerations.Game.GameType,System.Threading.CancellationToken)') - [GetGoalieSeasonGameLogsBySeasonAndGameTypeAsync(playerId,seasonYear,gameType,cancellationToken)](#M-Nhl-Api-NhlApi-GetGoalieSeasonGameLogsBySeasonAndGameTypeAsync-System-Int32,System-String,Nhl-Api-Enumerations-Game-GameType,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetGoalieSeasonGameLogsBySeasonAndGameTypeAsync(System.Int32,System.String,Nhl.Api.Enumerations.Game.GameType,System.Threading.CancellationToken)') + - [GetGoalieStatisticsBySeasonAndFilterExpressionAsync(seasonYear,expressionGoalieFilter,goalieStatisticsFilterToSortBy,limit,offsetStart,cancellationToken)](#M-Nhl-Api-NhlApi-GetGoalieStatisticsBySeasonAndFilterExpressionAsync-System-String,Nhl-Api-Models-Player-ExpressionGoalieFilter,Nhl-Api-Models-Player-GoalieStatisticsFilter,System-Int32,System-Int32,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetGoalieStatisticsBySeasonAndFilterExpressionAsync(System.String,Nhl.Api.Models.Player.ExpressionGoalieFilter,Nhl.Api.Models.Player.GoalieStatisticsFilter,System.Int32,System.Int32,System.Threading.CancellationToken)') - [GetGoalieStatisticsLeadersAsync(goalieStatisticsType,seasonYear,gameType,limit,cancellationToken)](#M-Nhl-Api-NhlApi-GetGoalieStatisticsLeadersAsync-Nhl-Api-Enumerations-Statistic-GoalieStatisticsType,Nhl-Api-Enumerations-Game-GameType,System-String,System-Int32,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetGoalieStatisticsLeadersAsync(Nhl.Api.Enumerations.Statistic.GoalieStatisticsType,Nhl.Api.Enumerations.Game.GameType,System.String,System.Int32,System.Threading.CancellationToken)') - [GetLeagueGameWeekScheduleByDateAsync(date,cancellationToken)](#M-Nhl-Api-NhlApi-GetLeagueGameWeekScheduleByDateAsync-System-DateOnly,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetLeagueGameWeekScheduleByDateAsync(System.DateOnly,System.Threading.CancellationToken)') - [GetLeagueMetadataInformationAsync(playerIds,teamIds,cancellationToken)](#M-Nhl-Api-NhlApi-GetLeagueMetadataInformationAsync-System-Collections-Generic-List{System-Int32},System-Collections-Generic-List{System-String},System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetLeagueMetadataInformationAsync(System.Collections.Generic.List{System.Int32},System.Collections.Generic.List{System.String},System.Threading.CancellationToken)') @@ -148,13 +150,14 @@ Thank you to all the people in the hockey community, especially: - [GetLeagueStandingsSeasonInformationAsync(cancellationToken)](#M-Nhl-Api-NhlApi-GetLeagueStandingsSeasonInformationAsync-System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetLeagueStandingsSeasonInformationAsync(System.Threading.CancellationToken)') - [GetLeagueWeekScheduleByDateAsync(date,cancellationToken)](#M-Nhl-Api-NhlApi-GetLeagueWeekScheduleByDateAsync-System-DateOnly,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetLeagueWeekScheduleByDateAsync(System.DateOnly,System.Threading.CancellationToken)') - [GetLiveGameFeedPlayerShiftsAsync(gameId,cancellationToken)](#M-Nhl-Api-NhlApi-GetLiveGameFeedPlayerShiftsAsync-System-Int32,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetLiveGameFeedPlayerShiftsAsync(System.Int32,System.Threading.CancellationToken)') - - [GetPlayerHeadshotImageAsync(player,playerHeadshotImageSize,cancellationToken)](#M-Nhl-Api-NhlApi-GetPlayerHeadshotImageAsync-PlayerEnum,Nhl-Api-Models-Enumerations-Player-PlayerHeadshotImageSize,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetPlayerHeadshotImageAsync(PlayerEnum,Nhl.Api.Models.Enumerations.Player.PlayerHeadshotImageSize,System.Threading.CancellationToken)') - - [GetPlayerHeadshotImageAsync(playerId,playerHeadshotImageSize,cancellationToken)](#M-Nhl-Api-NhlApi-GetPlayerHeadshotImageAsync-System-Int32,Nhl-Api-Models-Enumerations-Player-PlayerHeadshotImageSize,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetPlayerHeadshotImageAsync(System.Int32,Nhl.Api.Models.Enumerations.Player.PlayerHeadshotImageSize,System.Threading.CancellationToken)') + - [GetPlayerHeadshotImageAsync(player,seasonYear,cancellationToken)](#M-Nhl-Api-NhlApi-GetPlayerHeadshotImageAsync-PlayerEnum,System-String,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetPlayerHeadshotImageAsync(PlayerEnum,System.String,System.Threading.CancellationToken)') + - [GetPlayerHeadshotImageAsync(playerId,seasonYear,cancellationToken)](#M-Nhl-Api-NhlApi-GetPlayerHeadshotImageAsync-System-Int32,System-String,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetPlayerHeadshotImageAsync(System.Int32,System.String,System.Threading.CancellationToken)') - [GetPlayerInformationAsync(playerId,cancellationToken)](#M-Nhl-Api-NhlApi-GetPlayerInformationAsync-System-Int32,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetPlayerInformationAsync(System.Int32,System.Threading.CancellationToken)') - [GetPlayerInformationAsync(player,cancellationToken)](#M-Nhl-Api-NhlApi-GetPlayerInformationAsync-PlayerEnum,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetPlayerInformationAsync(PlayerEnum,System.Threading.CancellationToken)') - [GetPlayerSeasonGameLogsBySeasonAndGameTypeAsync(player,seasonYear,gameType,cancellationToken)](#M-Nhl-Api-NhlApi-GetPlayerSeasonGameLogsBySeasonAndGameTypeAsync-PlayerEnum,System-String,Nhl-Api-Enumerations-Game-GameType,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetPlayerSeasonGameLogsBySeasonAndGameTypeAsync(PlayerEnum,System.String,Nhl.Api.Enumerations.Game.GameType,System.Threading.CancellationToken)') - [GetPlayerSeasonGameLogsBySeasonAndGameTypeAsync(playerId,seasonYear,gameType,cancellationToken)](#M-Nhl-Api-NhlApi-GetPlayerSeasonGameLogsBySeasonAndGameTypeAsync-System-Int32,System-String,Nhl-Api-Enumerations-Game-GameType,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetPlayerSeasonGameLogsBySeasonAndGameTypeAsync(System.Int32,System.String,Nhl.Api.Enumerations.Game.GameType,System.Threading.CancellationToken)') - [GetPlayerSpotlightAsync(cancellationToken)](#M-Nhl-Api-NhlApi-GetPlayerSpotlightAsync-System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetPlayerSpotlightAsync(System.Threading.CancellationToken)') + - [GetPlayerStatisticsBySeasonAndFilterExpressionAsync(seasonYear,expressionPlayerFilter,playerStatisticsFilterToSortBy,limit,offsetStart,cancellationToken)](#M-Nhl-Api-NhlApi-GetPlayerStatisticsBySeasonAndFilterExpressionAsync-System-String,Nhl-Api-Models-Player-ExpressionPlayerFilter,Nhl-Api-Models-Player-PlayerStatisticsFilter,System-Int32,System-Int32,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetPlayerStatisticsBySeasonAndFilterExpressionAsync(System.String,Nhl.Api.Models.Player.ExpressionPlayerFilter,Nhl.Api.Models.Player.PlayerStatisticsFilter,System.Int32,System.Int32,System.Threading.CancellationToken)') - [GetSkaterStatisticsLeadersAsync(playerStatisticsType,seasonYear,gameType,limit,cancellationToken)](#M-Nhl-Api-NhlApi-GetSkaterStatisticsLeadersAsync-Nhl-Api-Enumerations-Statistic-PlayerStatisticsType,Nhl-Api-Enumerations-Game-GameType,System-String,System-Int32,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetSkaterStatisticsLeadersAsync(Nhl.Api.Enumerations.Statistic.PlayerStatisticsType,Nhl.Api.Enumerations.Game.GameType,System.String,System.Int32,System.Threading.CancellationToken)') - [GetSourcesToWatchGamesAsync(cancellationToken)](#M-Nhl-Api-NhlApi-GetSourcesToWatchGamesAsync-System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetSourcesToWatchGamesAsync(System.Threading.CancellationToken)') - [GetTeamColorsAsync(team,cancellationToken)](#M-Nhl-Api-NhlApi-GetTeamColorsAsync-Nhl-Api-Models-Enumerations-Team-TeamEnum,System-Threading-CancellationToken- 'Nhl.Api.NhlApi.GetTeamColorsAsync(Nhl.Api.Models.Enumerations.Team.TeamEnum,System.Threading.CancellationToken)') @@ -239,8 +242,8 @@ Thank you to all the people in the hockey community, especially: - [GetGoalieInformationAsync(player,cancellationToken)](#M-Nhl-Api-NhlPlayerApi-GetGoalieInformationAsync-PlayerEnum,System-Threading-CancellationToken- 'Nhl.Api.NhlPlayerApi.GetGoalieInformationAsync(PlayerEnum,System.Threading.CancellationToken)') - [GetGoalieSeasonGameLogsBySeasonAndGameTypeAsync(player,seasonYear,gameType,cancellationToken)](#M-Nhl-Api-NhlPlayerApi-GetGoalieSeasonGameLogsBySeasonAndGameTypeAsync-PlayerEnum,System-String,Nhl-Api-Enumerations-Game-GameType,System-Threading-CancellationToken- 'Nhl.Api.NhlPlayerApi.GetGoalieSeasonGameLogsBySeasonAndGameTypeAsync(PlayerEnum,System.String,Nhl.Api.Enumerations.Game.GameType,System.Threading.CancellationToken)') - [GetGoalieSeasonGameLogsBySeasonAndGameTypeAsync(playerId,seasonYear,gameType,cancellationToken)](#M-Nhl-Api-NhlPlayerApi-GetGoalieSeasonGameLogsBySeasonAndGameTypeAsync-System-Int32,System-String,Nhl-Api-Enumerations-Game-GameType,System-Threading-CancellationToken- 'Nhl.Api.NhlPlayerApi.GetGoalieSeasonGameLogsBySeasonAndGameTypeAsync(System.Int32,System.String,Nhl.Api.Enumerations.Game.GameType,System.Threading.CancellationToken)') - - [GetPlayerHeadshotImageAsync(player,playerHeadshotImageSize,cancellationToken)](#M-Nhl-Api-NhlPlayerApi-GetPlayerHeadshotImageAsync-PlayerEnum,Nhl-Api-Models-Enumerations-Player-PlayerHeadshotImageSize,System-Threading-CancellationToken- 'Nhl.Api.NhlPlayerApi.GetPlayerHeadshotImageAsync(PlayerEnum,Nhl.Api.Models.Enumerations.Player.PlayerHeadshotImageSize,System.Threading.CancellationToken)') - - [GetPlayerHeadshotImageAsync(playerId,playerHeadshotImageSize,cancellationToken)](#M-Nhl-Api-NhlPlayerApi-GetPlayerHeadshotImageAsync-System-Int32,Nhl-Api-Models-Enumerations-Player-PlayerHeadshotImageSize,System-Threading-CancellationToken- 'Nhl.Api.NhlPlayerApi.GetPlayerHeadshotImageAsync(System.Int32,Nhl.Api.Models.Enumerations.Player.PlayerHeadshotImageSize,System.Threading.CancellationToken)') + - [GetPlayerHeadshotImageAsync(player,seasonYear,cancellationToken)](#M-Nhl-Api-NhlPlayerApi-GetPlayerHeadshotImageAsync-PlayerEnum,System-String,System-Threading-CancellationToken- 'Nhl.Api.NhlPlayerApi.GetPlayerHeadshotImageAsync(PlayerEnum,System.String,System.Threading.CancellationToken)') + - [GetPlayerHeadshotImageAsync(playerId,seasonYear,cancellationToken)](#M-Nhl-Api-NhlPlayerApi-GetPlayerHeadshotImageAsync-System-Int32,System-String,System-Threading-CancellationToken- 'Nhl.Api.NhlPlayerApi.GetPlayerHeadshotImageAsync(System.Int32,System.String,System.Threading.CancellationToken)') - [GetPlayerInformationAsync(playerId,cancellationToken)](#M-Nhl-Api-NhlPlayerApi-GetPlayerInformationAsync-System-Int32,System-Threading-CancellationToken- 'Nhl.Api.NhlPlayerApi.GetPlayerInformationAsync(System.Int32,System.Threading.CancellationToken)') - [GetPlayerInformationAsync(player,cancellationToken)](#M-Nhl-Api-NhlPlayerApi-GetPlayerInformationAsync-PlayerEnum,System-Threading-CancellationToken- 'Nhl.Api.NhlPlayerApi.GetPlayerInformationAsync(PlayerEnum,System.Threading.CancellationToken)') - [GetPlayerSeasonGameLogsBySeasonAndGameTypeAsync(player,seasonYear,gameType,cancellationToken)](#M-Nhl-Api-NhlPlayerApi-GetPlayerSeasonGameLogsBySeasonAndGameTypeAsync-PlayerEnum,System-String,Nhl-Api-Enumerations-Game-GameType,System-Threading-CancellationToken- 'Nhl.Api.NhlPlayerApi.GetPlayerSeasonGameLogsBySeasonAndGameTypeAsync(PlayerEnum,System.String,Nhl.Api.Enumerations.Game.GameType,System.Threading.CancellationToken)') @@ -250,9 +253,12 @@ Thank you to all the people in the hockey community, especially: - [SearchAllPlayersAsync(query,limit,cancellationToken)](#M-Nhl-Api-NhlPlayerApi-SearchAllPlayersAsync-System-String,System-Int32,System-Threading-CancellationToken- 'Nhl.Api.NhlPlayerApi.SearchAllPlayersAsync(System.String,System.Int32,System.Threading.CancellationToken)') - [NhlStatisticsApi](#T-Nhl-Api-NhlStatisticsApi 'Nhl.Api.NhlStatisticsApi') - [#ctor()](#M-Nhl-Api-NhlStatisticsApi-#ctor 'Nhl.Api.NhlStatisticsApi.#ctor') + - [GetAllPlayersStatisticValuesBySeasonAsync(seasonYear,gameType,cancellationToken)](#M-Nhl-Api-NhlStatisticsApi-GetAllPlayersStatisticValuesBySeasonAsync-System-String,System-Nullable{Nhl-Api-Enumerations-Game-GameType},System-Threading-CancellationToken- 'Nhl.Api.NhlStatisticsApi.GetAllPlayersStatisticValuesBySeasonAsync(System.String,System.Nullable{Nhl.Api.Enumerations.Game.GameType},System.Threading.CancellationToken)') - [GetAllTotalPlayerStatisticValuesBySeasonAsync(playerEnum,seasonYear,gameType,cancellationToken)](#M-Nhl-Api-NhlStatisticsApi-GetAllTotalPlayerStatisticValuesBySeasonAsync-PlayerEnum,System-String,System-Nullable{Nhl-Api-Enumerations-Game-GameType},System-Threading-CancellationToken- 'Nhl.Api.NhlStatisticsApi.GetAllTotalPlayerStatisticValuesBySeasonAsync(PlayerEnum,System.String,System.Nullable{Nhl.Api.Enumerations.Game.GameType},System.Threading.CancellationToken)') - [GetAllTotalPlayerStatisticValuesBySeasonAsync(playerId,seasonYear,gameType,cancellationToken)](#M-Nhl-Api-NhlStatisticsApi-GetAllTotalPlayerStatisticValuesBySeasonAsync-System-Int32,System-String,System-Nullable{Nhl-Api-Enumerations-Game-GameType},System-Threading-CancellationToken- 'Nhl.Api.NhlStatisticsApi.GetAllTotalPlayerStatisticValuesBySeasonAsync(System.Int32,System.String,System.Nullable{Nhl.Api.Enumerations.Game.GameType},System.Threading.CancellationToken)') + - [GetGoalieStatisticsBySeasonAndFilterExpressionAsync(seasonYear,expressionGoalieFilter,goalieStatisticsFilterToSortBy,limit,offsetStart,cancellationToken)](#M-Nhl-Api-NhlStatisticsApi-GetGoalieStatisticsBySeasonAndFilterExpressionAsync-System-String,Nhl-Api-Models-Player-ExpressionGoalieFilter,Nhl-Api-Models-Player-GoalieStatisticsFilter,System-Int32,System-Int32,System-Threading-CancellationToken- 'Nhl.Api.NhlStatisticsApi.GetGoalieStatisticsBySeasonAndFilterExpressionAsync(System.String,Nhl.Api.Models.Player.ExpressionGoalieFilter,Nhl.Api.Models.Player.GoalieStatisticsFilter,System.Int32,System.Int32,System.Threading.CancellationToken)') - [GetGoalieStatisticsLeadersAsync(goalieStatisticsType,seasonYear,gameType,limit,cancellationToken)](#M-Nhl-Api-NhlStatisticsApi-GetGoalieStatisticsLeadersAsync-Nhl-Api-Enumerations-Statistic-GoalieStatisticsType,Nhl-Api-Enumerations-Game-GameType,System-String,System-Int32,System-Threading-CancellationToken- 'Nhl.Api.NhlStatisticsApi.GetGoalieStatisticsLeadersAsync(Nhl.Api.Enumerations.Statistic.GoalieStatisticsType,Nhl.Api.Enumerations.Game.GameType,System.String,System.Int32,System.Threading.CancellationToken)') + - [GetPlayerStatisticsBySeasonAndFilterExpressionAsync(seasonYear,expressionPlayerFilter,playerStatisticsFilterToSortBy,limit,offsetStart,cancellationToken)](#M-Nhl-Api-NhlStatisticsApi-GetPlayerStatisticsBySeasonAndFilterExpressionAsync-System-String,Nhl-Api-Models-Player-ExpressionPlayerFilter,Nhl-Api-Models-Player-PlayerStatisticsFilter,System-Int32,System-Int32,System-Threading-CancellationToken- 'Nhl.Api.NhlStatisticsApi.GetPlayerStatisticsBySeasonAndFilterExpressionAsync(System.String,Nhl.Api.Models.Player.ExpressionPlayerFilter,Nhl.Api.Models.Player.PlayerStatisticsFilter,System.Int32,System.Int32,System.Threading.CancellationToken)') - [GetSkaterStatisticsLeadersAsync(playerStatisticsType,seasonYear,gameType,limit,cancellationToken)](#M-Nhl-Api-NhlStatisticsApi-GetSkaterStatisticsLeadersAsync-Nhl-Api-Enumerations-Statistic-PlayerStatisticsType,Nhl-Api-Enumerations-Game-GameType,System-String,System-Int32,System-Threading-CancellationToken- 'Nhl.Api.NhlStatisticsApi.GetSkaterStatisticsLeadersAsync(Nhl.Api.Enumerations.Statistic.PlayerStatisticsType,Nhl.Api.Enumerations.Game.GameType,System.String,System.Int32,System.Threading.CancellationToken)') - [GetTeamStatisticsBySeasonAndGameTypeAsync(team,seasonYear,gameType,cancellationToken)](#M-Nhl-Api-NhlStatisticsApi-GetTeamStatisticsBySeasonAndGameTypeAsync-Nhl-Api-Models-Enumerations-Team-TeamEnum,System-String,Nhl-Api-Enumerations-Game-GameType,System-Threading-CancellationToken- 'Nhl.Api.NhlStatisticsApi.GetTeamStatisticsBySeasonAndGameTypeAsync(Nhl.Api.Models.Enumerations.Team.TeamEnum,System.String,Nhl.Api.Enumerations.Game.GameType,System.Threading.CancellationToken)') - [GetTeamStatisticsBySeasonAndGameTypeAsync(teamId,seasonYear,gameType,cancellationToken)](#M-Nhl-Api-NhlStatisticsApi-GetTeamStatisticsBySeasonAndGameTypeAsync-System-Int32,System-String,Nhl-Api-Enumerations-Game-GameType,System-Threading-CancellationToken- 'Nhl.Api.NhlStatisticsApi.GetTeamStatisticsBySeasonAndGameTypeAsync(System.Int32,System.String,Nhl.Api.Enumerations.Game.GameType,System.Threading.CancellationToken)') @@ -326,6 +332,25 @@ Returns all the NHL players to ever play in the NHL | ---- | ---- | ----------- | | cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token that can be used by other objects or threads to receive notice of cancellation | + +### GetAllPlayersStatisticValuesBySeasonAsync(seasonYear,gameType,cancellationToken) `method` + +##### Summary + +Returns the all the NHL players game center statistics for the entire NHL league for a specific season and game type + +##### Returns + +Returns the all the NHL players game center statistics for the entire NHL league for a specific season and game type + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| seasonYear | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | The NHL season year to retrieve the team statistics, see [SeasonYear](#T-Nhl-Api-Models-Season-SeasonYear 'Nhl.Api.Models.Season.SeasonYear') for more information on valid season years | +| gameType | [System.Nullable{Nhl.Api.Enumerations.Game.GameType}](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Nullable 'System.Nullable{Nhl.Api.Enumerations.Game.GameType}') | The NHL game type to retrieve the team statistics, see [GameType](#T-Nhl-Api-Enumerations-Game-GameType 'Nhl.Api.Enumerations.Game.GameType') for more information on valid game types | +| cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token to cancel the asynchronous operation | + ### GetAllRosterSeasonsByTeamAsync(teamId,cancellationToken) `method` @@ -636,6 +661,28 @@ The collection of player season game logs with each game played including statis | gameType | [Nhl.Api.Enumerations.Game.GameType](#T-Nhl-Api-Enumerations-Game-GameType 'Nhl.Api.Enumerations.Game.GameType') | The game type parameter for determining the game type for the type of player season logs | | cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token that can be used by other objects or threads to receive notice of cancellation | + +### GetGoalieStatisticsBySeasonAndFilterExpressionAsync(seasonYear,expressionGoalieFilter,goalieStatisticsFilterToSortBy,limit,offsetStart,cancellationToken) `method` + +##### Summary + +Returns all the NHL goalie statistics for a specific player for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + +##### Returns + +Returns all the NHL goalie statistics for a specific goalie for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| seasonYear | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | The NHL season year to retrieve the team statistics, see [SeasonYear](#T-Nhl-Api-Models-Season-SeasonYear 'Nhl.Api.Models.Season.SeasonYear') for more information on valid season years | +| expressionGoalieFilter | [Nhl.Api.Models.Player.ExpressionGoalieFilter](#T-Nhl-Api-Models-Player-ExpressionGoalieFilter 'Nhl.Api.Models.Player.ExpressionGoalieFilter') | The expression goalie filter to filter the goalie statistics by, see [GoalieFilterExpressionBuilder](#T-Nhl-Api-Models-Player-GoalieFilterExpressionBuilder 'Nhl.Api.Models.Player.GoalieFilterExpressionBuilder') for more information on valid goalie filters | +| goalieStatisticsFilterToSortBy | [Nhl.Api.Models.Player.GoalieStatisticsFilter](#T-Nhl-Api-Models-Player-GoalieStatisticsFilter 'Nhl.Api.Models.Player.GoalieStatisticsFilter') | The goalie statistics filter to sort the goalie statistics by, see [GoalieStatisticsFilter](#T-Nhl-Api-Models-Player-GoalieStatisticsFilter 'Nhl.Api.Models.Player.GoalieStatisticsFilter') for more information on valid goalie statistics filters | +| limit | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | The limit to the number of results returned when reviewing the NHL player statistics, by default -1 represents no limit applied to results | +| offsetStart | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | The offset to start the results from when reviewing the NHL goalie statistics | +| cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token to cancel the asynchronous operation | + ### GetGoalieStatisticsLeadersAsync(goalieStatisticsType,seasonYear,gameType,limit,cancellationToken) `method` @@ -802,27 +849,27 @@ A collection of all the NHL player game shifts for a specific game, including st | gameId | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | The game id, Example: 2021020087 | | cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token that can be used by other objects or threads to receive notice of cancellation | - -### GetPlayerHeadshotImageAsync(player,playerHeadshotImageSize,cancellationToken) `method` + +### GetPlayerHeadshotImageAsync(player,seasonYear,cancellationToken) `method` ##### Summary -Returns the NHL player's head shot image by the selected size +Returns the NHL player's head shot image by season year ##### Returns -A byte array content of an NHL player head shot image +A URI endpoint with the image of an NHL player head shot image ##### Parameters | Name | Type | Description | | ---- | ---- | ----------- | | player | [PlayerEnum](#T-PlayerEnum 'PlayerEnum') | An NHL player id, Example: 8478402 - Connor McDavid, see [PlayerEnum](#T-PlayerEnum 'PlayerEnum') for more information on NHL players | -| playerHeadshotImageSize | [Nhl.Api.Models.Enumerations.Player.PlayerHeadshotImageSize](#T-Nhl-Api-Models-Enumerations-Player-PlayerHeadshotImageSize 'Nhl.Api.Models.Enumerations.Player.PlayerHeadshotImageSize') | The size of the head shot image, see [PlayerHeadshotImageSize](#T-Nhl-Api-Models-Enumerations-Player-PlayerHeadshotImageSize 'Nhl.Api.Models.Enumerations.Player.PlayerHeadshotImageSize') for more information | +| seasonYear | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | The season year parameter for determining the season for the season, [SeasonYear](#T-Nhl-Api-Models-Season-SeasonYear 'Nhl.Api.Models.Season.SeasonYear') for all available seasons | | cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token that can be used by other objects or threads to receive notice of cancellation | - -### GetPlayerHeadshotImageAsync(playerId,playerHeadshotImageSize,cancellationToken) `method` + +### GetPlayerHeadshotImageAsync(playerId,seasonYear,cancellationToken) `method` ##### Summary @@ -837,7 +884,7 @@ A byte array content of an NHL player head shot image | Name | Type | Description | | ---- | ---- | ----------- | | playerId | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | An NHL player id, Example: 8478402 - Connor McDavid | -| playerHeadshotImageSize | [Nhl.Api.Models.Enumerations.Player.PlayerHeadshotImageSize](#T-Nhl-Api-Models-Enumerations-Player-PlayerHeadshotImageSize 'Nhl.Api.Models.Enumerations.Player.PlayerHeadshotImageSize') | The size of the head shot image, see [PlayerHeadshotImageSize](#T-Nhl-Api-Models-Enumerations-Player-PlayerHeadshotImageSize 'Nhl.Api.Models.Enumerations.Player.PlayerHeadshotImageSize') for more information | +| seasonYear | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | The season year parameter for determining the season for the season, [SeasonYear](#T-Nhl-Api-Models-Season-SeasonYear 'Nhl.Api.Models.Season.SeasonYear') for all available seasons | | cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token that can be used by other objects or threads to receive notice of cancellation | @@ -933,6 +980,28 @@ A collection of players and their information for players in the NHL spotlight | ---- | ---- | ----------- | | cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token that can be used by other objects or threads to receive notice of cancellation | + +### GetPlayerStatisticsBySeasonAndFilterExpressionAsync(seasonYear,expressionPlayerFilter,playerStatisticsFilterToSortBy,limit,offsetStart,cancellationToken) `method` + +##### Summary + +Returns all the NHL player game center statistics for a specific player for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + +##### Returns + +Returns all the NHL player game center statistics for a specific player for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| seasonYear | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | The NHL season year to retrieve the team statistics, see [SeasonYear](#T-Nhl-Api-Models-Season-SeasonYear 'Nhl.Api.Models.Season.SeasonYear') for more information on valid season years | +| expressionPlayerFilter | [Nhl.Api.Models.Player.ExpressionPlayerFilter](#T-Nhl-Api-Models-Player-ExpressionPlayerFilter 'Nhl.Api.Models.Player.ExpressionPlayerFilter') | The expression player filter to filter the player statistics by, see [PlayerFilterExpressionBuilder](#T-Nhl-Api-Models-Player-PlayerFilterExpressionBuilder 'Nhl.Api.Models.Player.PlayerFilterExpressionBuilder') for more information on valid player filters | +| playerStatisticsFilterToSortBy | [Nhl.Api.Models.Player.PlayerStatisticsFilter](#T-Nhl-Api-Models-Player-PlayerStatisticsFilter 'Nhl.Api.Models.Player.PlayerStatisticsFilter') | The player statistics filter to sort the player statistics by, see [PlayerStatisticsFilter](#T-Nhl-Api-Models-Player-PlayerStatisticsFilter 'Nhl.Api.Models.Player.PlayerStatisticsFilter') for more information on valid player statistics filters | +| limit | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | The limit to the number of results returned when reviewing the NHL player statistics, by default -1 represents no limit applied to results | +| offsetStart | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | The offset to start the results from when reviewing the NHL player statistics | +| cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token to cancel the asynchronous operation | + ### GetSkaterStatisticsLeadersAsync(playerStatisticsType,seasonYear,gameType,limit,cancellationToken) `method` @@ -2435,12 +2504,12 @@ The collection of player season game logs with each game played including statis | gameType | [Nhl.Api.Enumerations.Game.GameType](#T-Nhl-Api-Enumerations-Game-GameType 'Nhl.Api.Enumerations.Game.GameType') | The game type parameter for determining the game type for the type of player season logs | | cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token that can be used by other objects or threads to receive notice of cancellation | - -### GetPlayerHeadshotImageAsync(player,playerHeadshotImageSize,cancellationToken) `method` + +### GetPlayerHeadshotImageAsync(player,seasonYear,cancellationToken) `method` ##### Summary -Returns the NHL player's head shot image by the selected size +Returns the NHL player's head shot image by season year ##### Returns @@ -2451,15 +2520,15 @@ A URI endpoint with the image of an NHL player head shot image | Name | Type | Description | | ---- | ---- | ----------- | | player | [PlayerEnum](#T-PlayerEnum 'PlayerEnum') | An NHL player id, Example: 8478402 - Connor McDavid, see [PlayerEnum](#T-PlayerEnum 'PlayerEnum') for more information on NHL players | -| playerHeadshotImageSize | [Nhl.Api.Models.Enumerations.Player.PlayerHeadshotImageSize](#T-Nhl-Api-Models-Enumerations-Player-PlayerHeadshotImageSize 'Nhl.Api.Models.Enumerations.Player.PlayerHeadshotImageSize') | The size of the head shot image, see [PlayerHeadshotImageSize](#T-Nhl-Api-Models-Enumerations-Player-PlayerHeadshotImageSize 'Nhl.Api.Models.Enumerations.Player.PlayerHeadshotImageSize') for more information | +| seasonYear | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | The season year parameter for determining the season for the season, [SeasonYear](#T-Nhl-Api-Models-Season-SeasonYear 'Nhl.Api.Models.Season.SeasonYear') for all available seasons | | cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token that can be used by other objects or threads to receive notice of cancellation | - -### GetPlayerHeadshotImageAsync(playerId,playerHeadshotImageSize,cancellationToken) `method` + +### GetPlayerHeadshotImageAsync(playerId,seasonYear,cancellationToken) `method` ##### Summary -Returns the NHL player's head shot image by the selected size +Returns the NHL player's head shot image by season year ##### Returns @@ -2470,7 +2539,7 @@ A URI endpoint with the image of an NHL player head shot image | Name | Type | Description | | ---- | ---- | ----------- | | playerId | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | An NHL player id, Example: 8478402 - Connor McDavid | -| playerHeadshotImageSize | [Nhl.Api.Models.Enumerations.Player.PlayerHeadshotImageSize](#T-Nhl-Api-Models-Enumerations-Player-PlayerHeadshotImageSize 'Nhl.Api.Models.Enumerations.Player.PlayerHeadshotImageSize') | The size of the head shot image, see [PlayerHeadshotImageSize](#T-Nhl-Api-Models-Enumerations-Player-PlayerHeadshotImageSize 'Nhl.Api.Models.Enumerations.Player.PlayerHeadshotImageSize') for more information | +| seasonYear | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | The season year parameter for determining the season for the season, [SeasonYear](#T-Nhl-Api-Models-Season-SeasonYear 'Nhl.Api.Models.Season.SeasonYear') for all available seasons | | cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token that can be used by other objects or threads to receive notice of cancellation | @@ -2626,6 +2695,25 @@ The official unofficial NHL Statistics API providing various NHL information abo This constructor has no parameters. + +### GetAllPlayersStatisticValuesBySeasonAsync(seasonYear,gameType,cancellationToken) `method` + +##### Summary + +Returns the all the NHL players game center statistics for the entire NHL league for a specific season and game type + +##### Returns + +Returns the all the NHL player statistics for all of a players for a specific season + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| seasonYear | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | The NHL season year to retrieve the team statistics, see [SeasonYear](#T-Nhl-Api-Models-Season-SeasonYear 'Nhl.Api.Models.Season.SeasonYear') for more information on valid season years | +| gameType | [System.Nullable{Nhl.Api.Enumerations.Game.GameType}](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Nullable 'System.Nullable{Nhl.Api.Enumerations.Game.GameType}') | The NHL game type to retrieve the team statistics, see [GameType](#T-Nhl-Api-Enumerations-Game-GameType 'Nhl.Api.Enumerations.Game.GameType') for more information on valid game types | +| cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token to cancel the asynchronous operation | + ### GetAllTotalPlayerStatisticValuesBySeasonAsync(playerEnum,seasonYear,gameType,cancellationToken) `method` @@ -2666,6 +2754,28 @@ Returns the number of total number of a player statistics for a player for a spe | gameType | [System.Nullable{Nhl.Api.Enumerations.Game.GameType}](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Nullable 'System.Nullable{Nhl.Api.Enumerations.Game.GameType}') | The NHL game type to retrieve the team statistics, see [GameType](#T-Nhl-Api-Enumerations-Game-GameType 'Nhl.Api.Enumerations.Game.GameType') for more information on valid game types | | cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token to cancel the asynchronous operation | + +### GetGoalieStatisticsBySeasonAndFilterExpressionAsync(seasonYear,expressionGoalieFilter,goalieStatisticsFilterToSortBy,limit,offsetStart,cancellationToken) `method` + +##### Summary + +Returns all the NHL goalie statistics for a specific player for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + +##### Returns + +Returns all the NHL goalie statistics for a specific goalie for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| seasonYear | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | The NHL season year to retrieve the team statistics, see [SeasonYear](#T-Nhl-Api-Models-Season-SeasonYear 'Nhl.Api.Models.Season.SeasonYear') for more information on valid season years | +| expressionGoalieFilter | [Nhl.Api.Models.Player.ExpressionGoalieFilter](#T-Nhl-Api-Models-Player-ExpressionGoalieFilter 'Nhl.Api.Models.Player.ExpressionGoalieFilter') | The expression goalie filter to filter the goalie statistics by, see [GoalieFilterExpressionBuilder](#T-Nhl-Api-Models-Player-GoalieFilterExpressionBuilder 'Nhl.Api.Models.Player.GoalieFilterExpressionBuilder') for more information on valid goalie filters | +| goalieStatisticsFilterToSortBy | [Nhl.Api.Models.Player.GoalieStatisticsFilter](#T-Nhl-Api-Models-Player-GoalieStatisticsFilter 'Nhl.Api.Models.Player.GoalieStatisticsFilter') | The goalie statistics filter to sort the goalie statistics by, see [GoalieStatisticsFilter](#T-Nhl-Api-Models-Player-GoalieStatisticsFilter 'Nhl.Api.Models.Player.GoalieStatisticsFilter') for more information on valid goalie statistics filters | +| limit | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | The limit to the number of results returned when reviewing the NHL player statistics, by default -1 represents no limit applied to results | +| offsetStart | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | The offset to start the results from when reviewing the NHL goalie statistics | +| cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token to cancel the asynchronous operation | + ### GetGoalieStatisticsLeadersAsync(goalieStatisticsType,seasonYear,gameType,limit,cancellationToken) `method` @@ -2687,6 +2797,28 @@ Returns the current NHL player statistics leaders in the NHL for a specific play | limit | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | The limit to the number of results returned when reviewing the NHL player statistics | | cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token that can be used by other objects or threads to receive notice of cancellation | + +### GetPlayerStatisticsBySeasonAndFilterExpressionAsync(seasonYear,expressionPlayerFilter,playerStatisticsFilterToSortBy,limit,offsetStart,cancellationToken) `method` + +##### Summary + +Returns all the NHL player game center statistics for a specific player for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + +##### Returns + +Returns all the NHL player game center statistics for a specific player for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| seasonYear | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | The NHL season year to retrieve the team statistics, see [SeasonYear](#T-Nhl-Api-Models-Season-SeasonYear 'Nhl.Api.Models.Season.SeasonYear') for more information on valid season years | +| expressionPlayerFilter | [Nhl.Api.Models.Player.ExpressionPlayerFilter](#T-Nhl-Api-Models-Player-ExpressionPlayerFilter 'Nhl.Api.Models.Player.ExpressionPlayerFilter') | The expression player filter to filter the player statistics by, see [PlayerFilterExpressionBuilder](#T-Nhl-Api-Models-Player-PlayerFilterExpressionBuilder 'Nhl.Api.Models.Player.PlayerFilterExpressionBuilder') for more information on valid player filters | +| playerStatisticsFilterToSortBy | [Nhl.Api.Models.Player.PlayerStatisticsFilter](#T-Nhl-Api-Models-Player-PlayerStatisticsFilter 'Nhl.Api.Models.Player.PlayerStatisticsFilter') | The player statistics filter to sort the player statistics by, see [PlayerStatisticsFilter](#T-Nhl-Api-Models-Player-PlayerStatisticsFilter 'Nhl.Api.Models.Player.PlayerStatisticsFilter') for more information on valid player statistics filters | +| limit | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | The limit to the number of results returned when reviewing the NHL player statistics, by default -1 represents no limit applied to results | +| offsetStart | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | The offset to start the results from when reviewing the NHL player statistics | +| cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token to cancel the asynchronous operation | + ### GetSkaterStatisticsLeadersAsync(playerStatisticsType,seasonYear,gameType,limit,cancellationToken) `method` @@ -2824,4 +2956,4 @@ Returns the number of total number of a player statistics for a player for a spe | playerGameCenterStatistic | [Nhl.Api.Enumerations.Statistic.PlayerGameCenterStatistic](#T-Nhl-Api-Enumerations-Statistic-PlayerGameCenterStatistic 'Nhl.Api.Enumerations.Statistic.PlayerGameCenterStatistic') | The NHL player game center statistic type, [PlayerGameCenterStatistic](#T-Nhl-Api-Enumerations-Statistic-PlayerGameCenterStatistic 'Nhl.Api.Enumerations.Statistic.PlayerGameCenterStatistic') for more information on valid game center statistics | | seasonYear | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | The NHL season year to retrieve the team statistics, see [SeasonYear](#T-Nhl-Api-Models-Season-SeasonYear 'Nhl.Api.Models.Season.SeasonYear') for more information on valid season years | | gameType | [System.Nullable{Nhl.Api.Enumerations.Game.GameType}](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Nullable 'System.Nullable{Nhl.Api.Enumerations.Game.GameType}') | The NHL game type to retrieve the team statistics, see [GameType](#T-Nhl-Api-Enumerations-Game-GameType 'Nhl.Api.Enumerations.Game.GameType') for more information on valid game types | -| cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token to cancel the asynchronous operation | +| cancellationToken | [System.Threading.CancellationToken](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Threading.CancellationToken 'System.Threading.CancellationToken') | A cancellation token to cancel the asynchronous operation | \ No newline at end of file diff --git a/Nhl.Api/Src/Api/NhlApi.cs b/Nhl.Api/Src/Api/NhlApi.cs index 4ecb3b55..14c1eaab 100644 --- a/Nhl.Api/Src/Api/NhlApi.cs +++ b/Nhl.Api/Src/Api/NhlApi.cs @@ -1,28 +1,14 @@ -using Nhl.Api.Enumerations.Game; -using Nhl.Api.Enumerations.Statistic; -using Nhl.Api.Models.Enumerations.Player; -using Nhl.Api.Models.Enumerations.Team; -using Nhl.Api.Models.Game; -using Nhl.Api.Models.League; -using Nhl.Api.Models.Player; -using Nhl.Api.Models.Schedule; -using Nhl.Api.Models.Season; -using Nhl.Api.Models.Standing; -using Nhl.Api.Models.Statistics; -using Nhl.Api.Models.Team; -using System.Threading; - -namespace Nhl.Api; +namespace Nhl.Api; /// /// The official unofficial Nhl.Api providing various NHL information about players, teams, conferences, divisions, statistics and more /// public class NhlApi : INhlApi { - private static readonly INhlLeagueApi _nhlLeagueApi = new NhlLeagueApi(); - private static readonly INhlGameApi _nhlGameApi = new NhlGameApi(); - private static readonly INhlPlayerApi _nhlPlayerApi = new NhlPlayerApi(); - private static readonly INhlStatisticsApi _nhlStatisticsApi = new NhlStatisticsApi(); + private static readonly NhlLeagueApi _nhlLeagueApi = new(); + private static readonly NhlGameApi _nhlGameApi = new(); + private static readonly NhlPlayerApi _nhlPlayerApi = new(); + private static readonly NhlStatisticsApi _nhlStatisticsApi = new(); /// /// The official unofficial Nhl.Api providing various NHL information about players, teams, conferences, divisions, statistics and more @@ -78,28 +64,29 @@ public async Task GetTeamColorsAsync(int teamId, CancellationToken c return await _nhlLeagueApi.GetTeamColorsAsync(teamId, cancellationToken); } + /// - /// Returns the NHL player's head shot image by the selected size + /// Returns the NHL player's head shot image by season year /// /// An NHL player id, Example: 8478402 - Connor McDavid, see for more information on NHL players - /// The size of the head shot image, see for more information + /// The season year parameter for determining the season for the season, for all available seasons /// A cancellation token that can be used by other objects or threads to receive notice of cancellation - /// A byte array content of an NHL player head shot image - public async Task GetPlayerHeadshotImageAsync(PlayerEnum player, PlayerHeadshotImageSize playerHeadshotImageSize = PlayerHeadshotImageSize.Small, CancellationToken cancellationToken = default) + /// A URI endpoint with the image of an NHL player head shot image + public async Task GetPlayerHeadshotImageAsync(PlayerEnum player, string seasonYear, CancellationToken cancellationToken = default) { - return await _nhlPlayerApi.GetPlayerHeadshotImageAsync(player, playerHeadshotImageSize, cancellationToken); + return await _nhlPlayerApi.GetPlayerHeadshotImageAsync(player, seasonYear, cancellationToken); } /// /// Returns the NHL player's head shot image by the selected size /// /// An NHL player id, Example: 8478402 - Connor McDavid - /// The size of the head shot image, see for more information + /// The season year parameter for determining the season for the season, for all available seasons /// A cancellation token that can be used by other objects or threads to receive notice of cancellation /// A byte array content of an NHL player head shot image - public async Task GetPlayerHeadshotImageAsync(int playerId, PlayerHeadshotImageSize playerHeadshotImageSize = PlayerHeadshotImageSize.Small, CancellationToken cancellationToken = default) + public async Task GetPlayerHeadshotImageAsync(int playerId, string seasonYear, CancellationToken cancellationToken = default) { - return await _nhlPlayerApi.GetPlayerHeadshotImageAsync(playerId, playerHeadshotImageSize, cancellationToken); + return await _nhlPlayerApi.GetPlayerHeadshotImageAsync(playerId, seasonYear, cancellationToken); } /// @@ -795,6 +782,36 @@ public async Task + /// Returns all the NHL player game center statistics for a specific player for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + /// + /// The NHL season year to retrieve the team statistics, see for more information on valid season years + /// The expression player filter to filter the player statistics by, see for more information on valid player filters + /// The player statistics filter to sort the player statistics by, see for more information on valid player statistics filters + /// The limit to the number of results returned when reviewing the NHL player statistics, by default -1 represents no limit applied to results + /// The offset to start the results from when reviewing the NHL player statistics + /// A cancellation token to cancel the asynchronous operation + /// Returns all the NHL player game center statistics for a specific player for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + public async Task GetPlayerStatisticsBySeasonAndFilterExpressionAsync(string seasonYear, ExpressionPlayerFilter expressionPlayerFilter, PlayerStatisticsFilter playerStatisticsFilterToSortBy = PlayerStatisticsFilter.Points, int limit = -1, int offsetStart = 0, CancellationToken cancellationToken = default) + { + return await _nhlStatisticsApi.GetPlayerStatisticsBySeasonAndFilterExpressionAsync(seasonYear, expressionPlayerFilter, playerStatisticsFilterToSortBy, limit, offsetStart, cancellationToken); + } + + /// + /// Returns all the NHL goalie statistics for a specific player for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + /// + /// The NHL season year to retrieve the team statistics, see for more information on valid season years + /// The expression goalie filter to filter the goalie statistics by, see for more information on valid goalie filters + /// The goalie statistics filter to sort the goalie statistics by, see for more information on valid goalie statistics filters + /// The limit to the number of results returned when reviewing the NHL player statistics, by default -1 represents no limit applied to results + /// The offset to start the results from when reviewing the NHL goalie statistics + /// A cancellation token to cancel the asynchronous operation + /// Returns all the NHL goalie statistics for a specific goalie for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + public async Task GetGoalieStatisticsBySeasonAndFilterExpressionAsync(string seasonYear, ExpressionGoalieFilter expressionGoalieFilter, GoalieStatisticsFilter goalieStatisticsFilterToSortBy = GoalieStatisticsFilter.Wins, int limit = -1, int offsetStart = 0, CancellationToken cancellationToken = default) + { + return await _nhlStatisticsApi.GetGoalieStatisticsBySeasonAndFilterExpressionAsync(seasonYear, expressionGoalieFilter, goalieStatisticsFilterToSortBy, limit, offsetStart, cancellationToken); + } + /// /// Releases and disposes all unused or garbage collected resources for the Nhl.Api /// @@ -805,4 +822,5 @@ public async Task /// The await-able result of the asynchronous operation public async ValueTask DisposeAsync() => await Task.Run(() => _nhlPlayerApi?.Dispose()); + } diff --git a/Nhl.Api/Src/GameApi/INhlGameApi.cs b/Nhl.Api/Src/GameApi/INhlGameApi.cs index 3b3b0d11..09f62b16 100644 --- a/Nhl.Api/Src/GameApi/INhlGameApi.cs +++ b/Nhl.Api/Src/GameApi/INhlGameApi.cs @@ -1,11 +1,4 @@ -using Nhl.Api.Models.Enumerations.Team; -using Nhl.Api.Models.Game; -using Nhl.Api.Models.Player; -using Nhl.Api.Models.Schedule; -using Nhl.Api.Models.Season; -using System.Threading; - -namespace Nhl.Api; +namespace Nhl.Api; /// /// The official unofficial NHL Game API providing various NHL information game information, game schedules, live game feeds and more diff --git a/Nhl.Api/Src/GameApi/NhlGameApi.cs b/Nhl.Api/Src/GameApi/NhlGameApi.cs index f2e1b897..31065277 100644 --- a/Nhl.Api/Src/GameApi/NhlGameApi.cs +++ b/Nhl.Api/Src/GameApi/NhlGameApi.cs @@ -1,11 +1,4 @@ -using Nhl.Api.Common.Http; -using Nhl.Api.Models.Enumerations.Team; -using Nhl.Api.Models.Game; -using Nhl.Api.Models.Player; -using Nhl.Api.Models.Schedule; -using Nhl.Api.Models.Season; -using Nhl.Api.Services; -using System.Threading; +using Nhl.Api.Services; namespace Nhl.Api; @@ -14,9 +7,9 @@ namespace Nhl.Api; /// public class NhlGameApi : INhlGameApi { - private static readonly INhlApiHttpClient _nhlShiftChartHttpClient = new NhlShiftChartHttpClient(); - private static readonly INhlApiHttpClient _nhlApiWebHttpClient = new NhlApiWebHttpClient(); - private static readonly INhlTeamService _nhlTeamService = new NhlTeamService(); + private static readonly NhlShiftChartHttpClient _nhlShiftChartHttpClient = new(); + private static readonly NhlApiWebHttpClient _nhlApiWebHttpClient = new(); + private static readonly NhlTeamService _nhlTeamService = new(); /// /// The official unofficial NHL Game API providing various NHL information game information, game schedules, live game feeds and more diff --git a/Nhl.Api/Src/GlobalUsings.cs b/Nhl.Api/Src/GlobalUsings.cs index 355263ba..e11421c6 100644 --- a/Nhl.Api/Src/GlobalUsings.cs +++ b/Nhl.Api/Src/GlobalUsings.cs @@ -1,3 +1,24 @@ -global using System; +// System +// Nhl.Api.Common +global using Nhl.Api.Common.Extensions; +global using Nhl.Api.Common.Helpers; +global using Nhl.Api.Common.Http; +global using Nhl.Api.Models.Enumerations.Player; +global using Nhl.Api.Enumerations.Game; +global using Nhl.Api.Enumerations.Statistic; +global using Nhl.Api.Models.Enumerations.Team; +global using Nhl.Api.Models.Game; +global using Nhl.Api.Models.League; +global using Nhl.Api.Models.Player; +global using Nhl.Api.Models.Schedule; +global using Nhl.Api.Models.Season; +global using Nhl.Api.Models.Standing; +global using Nhl.Api.Models.Statistics; +global using Nhl.Api.Models.Team; + +global using System; global using System.Collections.Generic; +global using System.Linq; +global using System.Text; +global using System.Threading; global using System.Threading.Tasks; diff --git a/Nhl.Api/Src/LeagueApi/INhlLeagueApi.cs b/Nhl.Api/Src/LeagueApi/INhlLeagueApi.cs index b97d5dc7..04c42767 100644 --- a/Nhl.Api/Src/LeagueApi/INhlLeagueApi.cs +++ b/Nhl.Api/Src/LeagueApi/INhlLeagueApi.cs @@ -1,14 +1,4 @@ -using Nhl.Api.Models.Enumerations.Team; -using Nhl.Api.Models.Game; -using Nhl.Api.Models.League; -using Nhl.Api.Models.Player; -using Nhl.Api.Models.Schedule; -using Nhl.Api.Models.Season; -using Nhl.Api.Models.Standing; -using Nhl.Api.Models.Team; -using System.Threading; - -namespace Nhl.Api; +namespace Nhl.Api; /// /// The official unofficial NHL League API providing various NHL league information including teams, franchises, standings, awards and more @@ -147,7 +137,7 @@ public interface INhlLeagueApi /// /// The NHL team identifier, Example: 55 - Seattle Kraken /// A cancellation token that can be used by other objects or threads to receive notice of cancellation - /// + /// Returns all the NHL prospects for the specified NHL team including forwards, defense men and goalies public Task GetTeamProspectsByTeamAsync(int teamId, CancellationToken cancellationToken = default); /// @@ -155,7 +145,7 @@ public interface INhlLeagueApi /// /// The NHL team identifier, see for more information, Example: 10 - Toronto Maple Leafs /// A cancellation token that can be used by other objects or threads to receive notice of cancellation - /// + /// Returns all the NHL prospects for the specified NHL team including forwards, defense men and goalies public Task GetTeamProspectsByTeamAsync(TeamEnum team, CancellationToken cancellationToken = default); /// diff --git a/Nhl.Api/Src/LeagueApi/NhlLeagueApi.cs b/Nhl.Api/Src/LeagueApi/NhlLeagueApi.cs index 8f3bbb07..ad23419d 100644 --- a/Nhl.Api/Src/LeagueApi/NhlLeagueApi.cs +++ b/Nhl.Api/Src/LeagueApi/NhlLeagueApi.cs @@ -1,16 +1,4 @@ -using Nhl.Api.Common.Http; -using Nhl.Api.Models.Enumerations.Team; -using Nhl.Api.Models.Game; -using Nhl.Api.Models.League; -using Nhl.Api.Models.Player; -using Nhl.Api.Models.Schedule; -using Nhl.Api.Models.Season; -using Nhl.Api.Models.Standing; -using Nhl.Api.Models.Team; -using Nhl.Api.Services; -using System.Linq; -using System.Text; -using System.Threading; +using Nhl.Api.Services; namespace Nhl.Api; @@ -19,9 +7,9 @@ namespace Nhl.Api; /// public class NhlLeagueApi : INhlLeagueApi { - private static readonly INhlApiHttpClient _nhlStaticAssetsApiHttpClient = new NhlStaticAssetsApiHttpClient(); - private static readonly INhlTeamService _nhlTeamService = new NhlTeamService(); - private static readonly INhlApiHttpClient _nhlWebApiHttpClient = new NhlApiWebHttpClient(); + private static readonly NhlStaticAssetsApiHttpClient _nhlStaticAssetsApiHttpClient = new(); + private static readonly NhlTeamService _nhlTeamService = new(); + private static readonly NhlApiWebHttpClient _nhlWebApiHttpClient = new(); /// /// The official unofficial NHL League API providing various NHL league information including teams, franchises, standings, awards and more @@ -124,12 +112,7 @@ public async Task GetTeamScheduleBySeasonAsync(string teamAbbrevia throw new Exception($"The team abbreviation {teamAbbreviation} is not valid"); } - if (string.IsNullOrWhiteSpace(seasonYear)) - { - throw new ArgumentException("The season year is required"); - } - - if (seasonYear.Length != 8) + if (seasonYear?.Length != 8) { throw new ArgumentException("The season year must be in the eight digit format, Example: 20232024"); } @@ -471,12 +454,9 @@ public async Task GetLeagueStandingsSeasonInfo /// Returns the NHL team roster for a specific team by the team identifier and season year public async Task GetTeamRosterBySeasonYearAsync(int teamId, string seasonYear, CancellationToken cancellationToken = default) { - if (string.IsNullOrWhiteSpace(seasonYear)) - { - throw new ArgumentException("The season year is required"); - } - if (seasonYear.Length != 8) + + if (seasonYear?.Length != 8) { throw new ArgumentException("The season year must be in the eight digit format, Example: 20232024"); } @@ -494,12 +474,7 @@ public async Task GetTeamRosterBySeasonYearAsync(int teamId, s /// Returns the NHL team roster for a specific team by the team identifier and season year public async Task GetTeamRosterBySeasonYearAsync(TeamEnum team, string seasonYear, CancellationToken cancellationToken = default) { - if (string.IsNullOrWhiteSpace(seasonYear)) - { - throw new ArgumentException("The season year is required"); - } - - if (seasonYear.Length != 8) + if (seasonYear?.Length != 8) { throw new ArgumentException("The season year must be in the eight digit format, Example: 20232024"); } diff --git a/Nhl.Api/Src/PlayerApi/INhlPlayerApi.cs b/Nhl.Api/Src/PlayerApi/INhlPlayerApi.cs index 5d8181c8..61cbc489 100644 --- a/Nhl.Api/Src/PlayerApi/INhlPlayerApi.cs +++ b/Nhl.Api/Src/PlayerApi/INhlPlayerApi.cs @@ -1,11 +1,4 @@ -using Nhl.Api.Enumerations.Game; -using Nhl.Api.Models.Enumerations.Player; -using Nhl.Api.Models.Game; -using Nhl.Api.Models.Player; -using Nhl.Api.Models.Season; -using System.Threading; - -namespace Nhl.Api; +namespace Nhl.Api; /// /// The official unofficial NHL Player API providing various NHL information about players, draft prospects, rosters and more @@ -32,22 +25,22 @@ public interface INhlPlayerApi : IDisposable public Task> SearchAllActivePlayersAsync(string query, int limit = 25, CancellationToken cancellationToken = default); /// - /// Returns the NHL player's head shot image by the selected size + /// Returns the NHL player's head shot image by season year /// - /// An NHL player id, Example: 8478402 - Connor McDavid, see for more information on NHL players - /// The size of the head shot image, see for more information + /// An NHL player, Example: 8478402 - Connor McDavid + /// The season year parameter for determining the season for the season, for all available seasons /// A cancellation token that can be used by other objects or threads to receive notice of cancellation - /// A byte array content of an NHL player head shot image - public Task GetPlayerHeadshotImageAsync(PlayerEnum player, PlayerHeadshotImageSize playerHeadshotImageSize = PlayerHeadshotImageSize.Small, CancellationToken cancellationToken = default); + /// A URI endpoint with the image of an NHL player head shot image + public Task GetPlayerHeadshotImageAsync(PlayerEnum player, string seasonYear, CancellationToken cancellationToken = default); /// - /// Returns the NHL player's head shot image by the selected size + /// Returns the NHL player's head shot image by season year /// /// An NHL player id, Example: 8478402 - Connor McDavid - /// The size of the head shot image, see for more information + /// The season year parameter for determining the season for the season, for all available seasons /// A cancellation token that can be used by other objects or threads to receive notice of cancellation - /// A byte array content of an NHL player head shot image - public Task GetPlayerHeadshotImageAsync(int playerId, PlayerHeadshotImageSize playerHeadshotImageSize = PlayerHeadshotImageSize.Small, CancellationToken cancellationToken = default); + /// A URI endpoint with the image of an NHL player head shot image + public Task GetPlayerHeadshotImageAsync(int playerId, string seasonYear, CancellationToken cancellationToken = default); /// /// The player season game log for an NHL player for a specific season and game type including stats such as goals, assists, points, plus/minus and more @@ -94,7 +87,7 @@ public interface INhlPlayerApi : IDisposable /// /// An NHL player id, Example: 8480313 - Logan Thompson /// A cancellation token that can be used by other objects or threads to receive notice of cancellation - /// Returns the NHL goalie's profile information + /// Returns the NHL goalie's profile information including their birth date, birth city, height, weight, position and much more public Task GetGoalieInformationAsync(int playerId, CancellationToken cancellationToken = default); /// @@ -102,7 +95,7 @@ public interface INhlPlayerApi : IDisposable /// /// An NHL player id, Example: 8480313 - Logan Thompson, see for more information on NHL players /// A cancellation token that can be used by other objects or threads to receive notice of cancellation - /// Returns the NHL goalie's profile information + /// Returns the NHL goalie's profile information including their birth date, birth city, height, weight, position and much more public Task GetGoalieInformationAsync(PlayerEnum player, CancellationToken cancellationToken = default); /// diff --git a/Nhl.Api/Src/PlayerApi/NhlPlayerApi.cs b/Nhl.Api/Src/PlayerApi/NhlPlayerApi.cs index e5b51e32..0ea0cdfc 100644 --- a/Nhl.Api/Src/PlayerApi/NhlPlayerApi.cs +++ b/Nhl.Api/Src/PlayerApi/NhlPlayerApi.cs @@ -1,12 +1,5 @@ -using Nhl.Api.Common.Http; -using Nhl.Api.Common.Services; -using Nhl.Api.Enumerations.Game; -using Nhl.Api.Models.Enumerations.Player; -using Nhl.Api.Models.Game; -using Nhl.Api.Models.Player; -using Nhl.Api.Models.Season; -using System.Linq; -using System.Threading; +using Nhl.Api.Common.Services; +using Nhl.Api.Services; namespace Nhl.Api; @@ -15,12 +8,12 @@ namespace Nhl.Api; /// public class NhlPlayerApi : INhlPlayerApi { - private static readonly INhlApiHttpClient _nhlStatsApiHttpClient = new NhlStatsApiHttpClient(); - private static readonly INhlApiHttpClient _nhlEWebApiHttpClient = new NhlEApiHttpClient(); - private static readonly INhlApiHttpClient _nhlApiWebHttpClient = new NhlApiWebHttpClient(); - private static readonly INhlApiHttpClient _nhlSuggestionApiHttpClient = new NhlSuggestionApiHttpClient(); - private static readonly INhlApiHttpClient _nhlCmsHttpClient = new NhlCmsHttpClient(); - private static readonly ICachingService _cachingService = new CachingService(); + private static readonly NhlEApiHttpClient _nhlEWebApiHttpClient = new(); + private static readonly NhlApiWebHttpClient _nhlApiWebHttpClient = new(); + private static readonly NhlSuggestionApiHttpClient _nhlSuggestionApiHttpClient = new(); + private static readonly NhlStaticAssetsApiHttpClient _nhlStaticAssetsApiHttpClient = new(); + private static readonly CachingService _cachingService = new(); + private static readonly NhlTeamService _nhlTeamService = new(); /// /// The official unofficial NHL Player API providing various NHL information about players, draft prospects, rosters and more @@ -65,39 +58,55 @@ public async Task> SearchAllActivePlayersAsync(string q } /// - /// Returns the NHL player's head shot image by the selected size + /// Returns the NHL player's head shot image by season year /// /// An NHL player id, Example: 8478402 - Connor McDavid, see for more information on NHL players - /// The size of the head shot image, see for more information + /// The season year parameter for determining the season for the season, for all available seasons /// A cancellation token that can be used by other objects or threads to receive notice of cancellation /// A URI endpoint with the image of an NHL player head shot image - public async Task GetPlayerHeadshotImageAsync(PlayerEnum player, PlayerHeadshotImageSize playerHeadshotImageSize = PlayerHeadshotImageSize.Small, CancellationToken cancellationToken = default) + public async Task GetPlayerHeadshotImageAsync(PlayerEnum player, string seasonYear, CancellationToken cancellationToken = default) { - return playerHeadshotImageSize switch + if (seasonYear?.Length != 8) + { + throw new ArgumentException($"The {nameof(seasonYear)} parameter must be in the format of yyyyyyyy, example: 20232024", nameof(seasonYear)); + } + + var playerInformation = await GetPlayerInformationAsync(player, cancellationToken); + var teamName = playerInformation.SeasonTotals.FirstOrDefault(x => x.Season == int.Parse(seasonYear))?.TeamName?.Default; + if (string.IsNullOrWhiteSpace(teamName)) { - PlayerHeadshotImageSize.Small => await _nhlCmsHttpClient.GetByteArrayAsync($"images/headshots/current/168x168/{(int)player}.png", cancellationToken), - PlayerHeadshotImageSize.Medium => await _nhlCmsHttpClient.GetByteArrayAsync($"images/headshots/current/168x168/{(int)player}@2x.png", cancellationToken), - PlayerHeadshotImageSize.Large => await _nhlCmsHttpClient.GetByteArrayAsync($"images/headshots/current/168x168/{(int)player}@3x.png", cancellationToken), - _ => null, - }; + return Array.Empty(); + } + + var teamAbbreviation = _nhlTeamService.GetTeamCodeIdentifierByTeamName(teamName); + + return await _nhlStaticAssetsApiHttpClient.GetByteArrayAsync($"mugs/nhl/{seasonYear}/{teamAbbreviation}/{(int)player}.png", cancellationToken); } /// - /// Returns the NHL player's head shot image by the selected size + /// Returns the NHL player's head shot image by season year /// /// An NHL player id, Example: 8478402 - Connor McDavid - /// The size of the head shot image, see for more information + /// The season year parameter for determining the season for the season, for all available seasons /// A cancellation token that can be used by other objects or threads to receive notice of cancellation /// A URI endpoint with the image of an NHL player head shot image - public async Task GetPlayerHeadshotImageAsync(int playerId, PlayerHeadshotImageSize playerHeadshotImageSize = PlayerHeadshotImageSize.Small, CancellationToken cancellationToken = default) + public async Task GetPlayerHeadshotImageAsync(int playerId, string seasonYear, CancellationToken cancellationToken = default) { - return playerHeadshotImageSize switch + if (seasonYear?.Length != 8) + { + throw new ArgumentException($"The {nameof(seasonYear)} parameter must be in the format of yyyyyyyy, example: 20232024", nameof(seasonYear)); + } + + var playerInformation = await GetPlayerInformationAsync(playerId, cancellationToken); + var teamName = playerInformation.SeasonTotals.FirstOrDefault(x => x.Season == int.Parse(seasonYear))?.TeamName?.Default; + if (string.IsNullOrWhiteSpace(teamName)) { - PlayerHeadshotImageSize.Small => await _nhlCmsHttpClient.GetByteArrayAsync($"images/headshots/current/168x168/{playerId}.png", cancellationToken), - PlayerHeadshotImageSize.Medium => await _nhlCmsHttpClient.GetByteArrayAsync($"images/headshots/current/168x168/{playerId}@2x.png", cancellationToken), - PlayerHeadshotImageSize.Large => await _nhlCmsHttpClient.GetByteArrayAsync($"images/headshots/current/168x168/{playerId}@3x.png", cancellationToken), - _ => null, - }; + return Array.Empty(); + } + + var teamAbbreviation = _nhlTeamService.GetTeamCodeIdentifierByTeamName(teamName); + + return await _nhlStaticAssetsApiHttpClient.GetByteArrayAsync($"mugs/nhl/{seasonYear}/{teamAbbreviation}/{playerId}.png", cancellationToken); } /// @@ -115,7 +124,7 @@ public async Task GetPlayerSeasonGameLogsBySeasonAndGameTyp throw new ArgumentException($"The {nameof(seasonYear)} parameter is required", nameof(seasonYear)); } - if (seasonYear.Length != 8) + if (seasonYear?.Length != 8) { throw new ArgumentException($"The {nameof(seasonYear)} parameter must be in the format of yyyyyyyy, example: 20232024", nameof(seasonYear)); } @@ -138,7 +147,7 @@ public async Task GetPlayerSeasonGameLogsBySeasonAndGameTyp throw new ArgumentException($"The {nameof(seasonYear)} parameter is required", nameof(seasonYear)); } - if (seasonYear.Length != 8) + if (seasonYear?.Length != 8) { throw new ArgumentException($"The {nameof(seasonYear)} parameter must be in the format of yyyyyyyy, example: 20232024", nameof(seasonYear)); } @@ -161,7 +170,7 @@ public async Task GetGoalieSeasonGameLogsBySeasonAndGameTyp throw new ArgumentException($"The {nameof(seasonYear)} parameter is required", nameof(seasonYear)); } - if (seasonYear.Length != 8) + if (seasonYear?.Length != 8) { throw new ArgumentException($"The {nameof(seasonYear)} parameter must be in the format of yyyyyyyy, example: 20232024", nameof(seasonYear)); } @@ -184,7 +193,7 @@ public async Task GetGoalieSeasonGameLogsBySeasonAndGameTyp throw new ArgumentException($"The {nameof(seasonYear)} parameter is required", nameof(seasonYear)); } - if (seasonYear.Length != 8) + if (seasonYear?.Length != 8) { throw new ArgumentException($"The {nameof(seasonYear)} parameter must be in the format of yyyyyyyy, example: 20232024", nameof(seasonYear)); } diff --git a/Nhl.Api/Src/StatisticsApi/INhlStatisticsApi.cs b/Nhl.Api/Src/StatisticsApi/INhlStatisticsApi.cs index fcc75686..53af429a 100644 --- a/Nhl.Api/Src/StatisticsApi/INhlStatisticsApi.cs +++ b/Nhl.Api/Src/StatisticsApi/INhlStatisticsApi.cs @@ -1,13 +1,4 @@ -using Nhl.Api.Enumerations.Game; -using Nhl.Api.Enumerations.Statistic; -using Nhl.Api.Models.Enumerations.Team; -using Nhl.Api.Models.Player; -using Nhl.Api.Models.Season; -using Nhl.Api.Models.Statistics; -using Nhl.Api.Models.Team; -using System.Threading; - -namespace Nhl.Api; +namespace Nhl.Api; /// /// The official unofficial NHL Statistics API providing various NHL information about in-depth player statistics, team statistics and more @@ -122,4 +113,29 @@ public interface INhlStatisticsApi /// A cancellation token to cancel the asynchronous operation /// Returns the all the NHL player statistics for all of a players for a specific season public Task>> GetAllPlayersStatisticValuesBySeasonAsync(string seasonYear, GameType? gameType = null, CancellationToken cancellationToken = default); + + /// + /// Returns all the NHL player game center statistics for a specific player for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + /// + /// The NHL season year to retrieve the team statistics, see for more information on valid season years + /// The expression player filter to filter the player statistics by, see for more information on valid player filters + /// The player statistics filter to sort the player statistics by, see for more information on valid player statistics filters + /// The limit to the number of results returned when reviewing the NHL player statistics, by default -1 represents no limit applied to results + /// The offset to start the results from when reviewing the NHL player statistics + /// A cancellation token to cancel the asynchronous operation + /// Returns all the NHL player game center statistics for a specific player for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + public Task GetPlayerStatisticsBySeasonAndFilterExpressionAsync(string seasonYear, ExpressionPlayerFilter expressionPlayerFilter, PlayerStatisticsFilter playerStatisticsFilterToSortBy = PlayerStatisticsFilter.Points, int limit = -1, int offsetStart = 0, CancellationToken cancellationToken = default); + + /// + /// Returns all the NHL goalie statistics for a specific player for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + /// + /// The NHL season year to retrieve the team statistics, see for more information on valid season years + /// The expression goalie filter to filter the goalie statistics by, see for more information on valid goalie filters + /// The goalie statistics filter to sort the goalie statistics by, see for more information on valid goalie statistics filters + /// The limit to the number of results returned when reviewing the NHL player statistics, by default -1 represents no limit applied to results + /// The offset to start the results from when reviewing the NHL goalie statistics + /// A cancellation token to cancel the asynchronous operation + /// Returns all the NHL goalie statistics for a specific goalie for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + public Task GetGoalieStatisticsBySeasonAndFilterExpressionAsync(string seasonYear, ExpressionGoalieFilter expressionGoalieFilter, GoalieStatisticsFilter goalieStatisticsFilterToSortBy = GoalieStatisticsFilter.Wins, int limit = -1, int offsetStart = 0, CancellationToken cancellationToken = default); + } diff --git a/Nhl.Api/Src/StatisticsApi/NhlStatisticsApi.cs b/Nhl.Api/Src/StatisticsApi/NhlStatisticsApi.cs index 51f0be9d..a7d561ed 100644 --- a/Nhl.Api/Src/StatisticsApi/NhlStatisticsApi.cs +++ b/Nhl.Api/Src/StatisticsApi/NhlStatisticsApi.cs @@ -1,17 +1,4 @@ -using Nhl.Api.Common.Extensions; -using Nhl.Api.Common.Helpers; -using Nhl.Api.Common.Http; -using Nhl.Api.Enumerations.Game; -using Nhl.Api.Enumerations.Statistic; -using Nhl.Api.Models.Enumerations.Team; -using Nhl.Api.Models.Game; -using Nhl.Api.Models.Player; -using Nhl.Api.Models.Season; -using Nhl.Api.Models.Statistics; -using Nhl.Api.Models.Team; -using Nhl.Api.Services; -using System.Linq; -using System.Threading; +using Nhl.Api.Services; namespace Nhl.Api; @@ -20,11 +7,12 @@ namespace Nhl.Api; /// public class NhlStatisticsApi : INhlStatisticsApi { - private static readonly INhlTeamService _nhlTeamService = new NhlTeamService(); - private static readonly INhlApiHttpClient _nhlApiWebHttpClient = new NhlApiWebHttpClient(); - private static readonly INhlGameApi _nhlGameApi = new NhlGameApi(); - private static readonly INhlLeagueApi _nhlLeagueApi = new NhlLeagueApi(); - private static readonly INhlPlayerApi _nhlPlayerApi = new NhlPlayerApi(); + private static readonly NhlTeamService _nhlTeamService = new(); + private static readonly NhlApiWebHttpClient _nhlApiWebHttpClient = new(); + private static readonly NhlEApiHttpClient _nhlEApiWebHttpClient = new(); + private static readonly NhlGameApi _nhlGameApi = new(); + private static readonly NhlLeagueApi _nhlLeagueApi = new(); + private static readonly NhlPlayerApi _nhlPlayerApi = new(); /// @@ -51,7 +39,7 @@ public async Task GetGoalieStatisticsLeadersAsync(Goalie throw new ArgumentException("A season year must be provided to retrieve the NHL player statistics leaders for"); } - if (seasonYear.Length != 8) + if (seasonYear?.Length != 8) { throw new ArgumentException("The season year must be 8 digits in length"); } @@ -80,7 +68,7 @@ public async Task GetSkaterStatisticsLeadersAsync(Player throw new ArgumentException("A season year must be provided to retrieve the NHL player statistics leaders for"); } - if (seasonYear.Length != 8) + if (seasonYear?.Length != 8) { throw new ArgumentException("The season year must be 8 digits in length"); } @@ -157,7 +145,7 @@ public async Task> GetTeamStatisticsBySeasonAsync(int public async Task GetTotalPlayerStatisticValueByTypeAndSeasonAsync(PlayerEnum playerEnum, PlayerGameCenterStatistic playerGameCenterStatistic, string seasonYear, GameType? gameType = null, CancellationToken cancellationToken = default) { var statisticTotal = 0; - if (string.IsNullOrWhiteSpace(seasonYear) || seasonYear.Length != 8) + if (string.IsNullOrWhiteSpace(seasonYear) || seasonYear?.Length != 8) { throw new ArgumentException("The season year provided is invalid"); } @@ -223,7 +211,7 @@ public async Task GetTotalPlayerStatisticValueByTypeAndSeasonAsync(PlayerEn public async Task GetTotalPlayerStatisticValueByTypeAndSeasonAsync(int playerId, PlayerGameCenterStatistic playerGameCenterStatistic, string seasonYear, GameType? gameType = null, CancellationToken cancellationToken = default) { var statisticTotal = 0; - if (string.IsNullOrWhiteSpace(seasonYear) || seasonYear.Length != 8) + if (string.IsNullOrWhiteSpace(seasonYear) || seasonYear?.Length != 8) { throw new ArgumentException("The season year provided is invalid"); } @@ -546,6 +534,91 @@ public async Task + /// Returns all the NHL player game center statistics for a specific player for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + /// + /// The NHL season year to retrieve the team statistics, see for more information on valid season years + /// The expression player filter to filter the player statistics by, see for more information on valid player filters + /// The player statistics filter to sort the player statistics by, see for more information on valid player statistics filters + /// The limit to the number of results returned when reviewing the NHL player statistics, by default -1 represents no limit applied to results + /// The offset to start the results from when reviewing the NHL player statistics + /// A cancellation token to cancel the asynchronous operation + /// Returns all the NHL player game center statistics for a specific player for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + public async Task GetPlayerStatisticsBySeasonAndFilterExpressionAsync(string seasonYear, ExpressionPlayerFilter expressionPlayerFilter, PlayerStatisticsFilter playerStatisticsFilterToSortBy = PlayerStatisticsFilter.Points, int limit = -1, int offsetStart = 0, CancellationToken cancellationToken = default) + { + if (string.IsNullOrWhiteSpace(seasonYear)) + { + throw new ArgumentException("A season year must be provided to retrieve the NHL player statistics"); + } + + if (expressionPlayerFilter == null) + { + throw new ArgumentException("A player filter expression must be provided to retrieve the NHL player statistics"); + } + + // Validate limit and offsetStart values + if (limit < -1) + { + throw new ArgumentException("Limit must be greater than or equal to 0"); + } + + if (offsetStart < 0) + { + throw new ArgumentException("Offset start must be greater than or equal to 0"); + } + + var endpoint = new StringBuilder($"/skater/summary?cayenneExp=seasonId={seasonYear}&limit={limit}&start={offsetStart}&sort={playerStatisticsFilterToSortBy.GetEnumMemberValue()}"); + if (expressionPlayerFilter.IsValidExpression) + { + endpoint.Append($"&{expressionPlayerFilter}"); + } + + return await _nhlEApiWebHttpClient.GetAsync(endpoint.ToString(), cancellationToken); + } + + /// + /// Returns all the NHL goalie statistics for a specific player for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + /// + /// The NHL season year to retrieve the team statistics, see for more information on valid season years + /// The expression goalie filter to filter the goalie statistics by, see for more information on valid goalie filters + /// The goalie statistics filter to sort the goalie statistics by, see for more information on valid goalie statistics filters + /// The limit to the number of results returned when reviewing the NHL player statistics, by default -1 represents no limit applied to results + /// The offset to start the results from when reviewing the NHL goalie statistics + /// A cancellation token to cancel the asynchronous operation + /// Returns all the NHL goalie statistics for a specific goalie for a specific season including face off percentage, points per game, overtime goals, short handed points , power play points, shooting percentage, shots, time on ice per game and more + public async Task GetGoalieStatisticsBySeasonAndFilterExpressionAsync(string seasonYear, ExpressionGoalieFilter expressionGoalieFilter, GoalieStatisticsFilter goalieStatisticsFilterToSortBy = GoalieStatisticsFilter.Wins, int limit = -1, int offsetStart = 0, CancellationToken cancellationToken = default) + { + if (string.IsNullOrWhiteSpace(seasonYear)) + { + throw new ArgumentException("A season year must be provided to retrieve the NHL player statistics"); + } + + if (expressionGoalieFilter == null) + { + throw new ArgumentException("A goalie filter expression must be provided to retrieve the NHL goalie statistics"); + } + + // Validate limit and offsetStart values + if (limit < -1) + { + throw new ArgumentException("Limit must be greater than or equal to 0"); + } + + if (offsetStart < 0) + { + throw new ArgumentException("Offset start must be greater than or equal to 0"); + } + + var endpoint = new StringBuilder($"/goalie/summary?cayenneExp=seasonId={seasonYear}&limit={limit}&start={offsetStart}&sort={goalieStatisticsFilterToSortBy.GetEnumMemberValue()}"); + if (expressionGoalieFilter.IsValidExpression) + { + endpoint.Append($"&{expressionGoalieFilter}"); + } + + return await _nhlEApiWebHttpClient.GetAsync(endpoint.ToString(), cancellationToken); + } + private static void ValidateSeasonYear(string seasonYear) { if (string.IsNullOrEmpty(seasonYear)) @@ -553,7 +626,7 @@ private static void ValidateSeasonYear(string seasonYear) throw new ArgumentException("A season year must be provided to retrieve the NHL player statistics leaders for"); } - if (seasonYear.Length != 8) + if (seasonYear?.Length != 8) { throw new ArgumentException("The season year must be 8 digits in length"); } @@ -735,5 +808,4 @@ private static void GetPlayerStatisticTotal(int playerId, GameCenterPlay play, r break; } } - }