Skip to content

Commit

Permalink
Add draft ranking methods and update team status handling
Browse files Browse the repository at this point in the history
Enhanced the codebase with several key updates:
- Added new namespaces across multiple files for better organization.
- Introduced `TeamActive` attribute in `TeamEnum` to indicate team status.
- Removed the `Ranks` class and its properties.
- Updated `GameCenterPlayByPlay` property documentation and default value.
- Refactored test methods in `GameTests.cs` and `PlayerTests.cs` for improved validation.
- Added `GetPlayerDraftRankingByYearAsync` method in `NhlApi.cs`, `INhlPlayerApi.cs`, and `NhlPlayerApi.cs` to fetch draft rankings.
- Excluded `ArizonaCoyotes` from NHL teams for seasons 2024-2025 or later in `NhlStatisticsApi.cs`.
- Introduced new classes to represent NHL draft player rankings and categories.
  • Loading branch information
Afischbacher committed Nov 5, 2024
1 parent 965bfe5 commit 5e8c748
Show file tree
Hide file tree
Showing 13 changed files with 368 additions and 78 deletions.
19 changes: 19 additions & 0 deletions Nhl.Api.Common/Attributes/TeamActiveAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;

namespace Nhl.Api.Common.Attributes;

/// <summary>
/// An enumeration to specifically mark NHL teams active or inactive
/// </summary>
/// <remarks>
/// The constructor
/// </remarks>
/// <param name="isActive">Whether an NHL team is active in the leauge</param>
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
public class TeamActiveAttribute(bool isActive) : Attribute
{
/// <summary>
/// Determines if the NHL team is currently active
/// </summary>
public bool IsActive { get; } = isActive;
}
2 changes: 1 addition & 1 deletion Nhl.Api.Common/Extensions/EnumExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
Expand Down
35 changes: 35 additions & 0 deletions Nhl.Api.Domain/Enumerations/Team/TeamEnum.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Nhl.Api.Common.Attributes;

namespace Nhl.Api.Models.Enumerations.Team;

/// <summary>
Expand All @@ -8,133 +10,166 @@ public enum TeamEnum
/// <summary>
/// New Jersey Devils
/// </summary>
[TeamActive(true)]
NewJerseyDevils = 1,
/// <summary>
/// New York Islanders
/// </summary>
[TeamActive(true)]
NewYorkIslanders = 2,
/// <summary>
/// New York Rangers
/// </summary>
[TeamActive(true)]
NewYorkRangers = 3,
/// <summary>
/// Philadelphia Flyers
/// </summary>
[TeamActive(true)]
PhiladelphiaFlyers = 4,
/// <summary>
/// Pittsburgh Penguins
/// </summary>
[TeamActive(true)]
PittsburghPenguins = 5,
/// <summary>
/// Boston Bruins
/// </summary>
[TeamActive(true)]
BostonBruins = 6,
/// <summary>
/// Buffalo Sabres
/// </summary>
[TeamActive(true)]
BuffaloSabres = 7,
/// <summary>
/// Montreal Canadiens
/// </summary>
[TeamActive(true)]
MontrealCanadiens = 8,
/// <summary>
/// Ottawa Senators
/// </summary>
[TeamActive(true)]
OttawaSenators = 9,
/// <summary>
/// Toronto Maple Leafs
/// </summary>
[TeamActive(true)]
TorontoMapleLeafs = 10,
/// <summary>
/// Carolina Hurricanes
/// </summary>
[TeamActive(true)]
CarolinaHurricanes = 12,
/// <summary>
/// Florida Panthers
/// </summary>
[TeamActive(true)]
FloridaPanthers = 13,
/// <summary>
/// Tampa Bay Lightning
/// </summary>
[TeamActive(true)]
TampaBayLightning = 14,
/// <summary>
/// Washington Capitals
/// </summary>
[TeamActive(true)]
WashingtonCapitals = 15,
/// <summary>
/// Chicago Blackhawks
/// </summary>
[TeamActive(true)]
ChicagoBlackhawks = 16,
/// <summary>
/// Detroit Red Wings
/// </summary>
[TeamActive(true)]
DetroitRedWings = 17,
/// <summary>
/// Nashville Predators
/// </summary>
[TeamActive(true)]
NashvillePredators = 18,
/// <summary>
/// St.Louis Blues
/// </summary>
[TeamActive(true)]
StLouisBlues = 19,
/// <summary>
/// Calgary Flames
/// </summary>
[TeamActive(true)]
CalgaryFlames = 20,
/// <summary>
/// Colorado Avalanche
/// </summary>
[TeamActive(true)]
ColoradoAvalanche = 21,
/// <summary>
/// Edmonton Oilers
/// </summary>
[TeamActive(true)]
EdmontonOilers = 22,
/// <summary>
/// Vancouver Canucks
/// </summary>
[TeamActive(true)]
VancouverCanucks = 23,
/// <summary>
/// Anaheim Ducks
/// </summary>
[TeamActive(true)]
AnaheimDucks = 24,
/// <summary>
/// Dallas Stars
/// </summary>
[TeamActive(true)]
DallasStars = 25,
/// <summary>
/// Los Angeles Kings
/// </summary>
[TeamActive(true)]
LosAngelesKings = 26,
/// <summary>
/// San Jose Sharks
/// </summary>
[TeamActive(true)]
SanJoseSharks = 28,
/// <summary>
/// Columbus Blue Jackets
/// </summary>
[TeamActive(true)]
ColumbusBlueJackets = 29,
/// <summary>
/// Minnesota Wild
/// </summary>
[TeamActive(true)]
MinnesotaWild = 30,
/// <summary>
/// Winnipeg Jets
/// </summary>
[TeamActive(true)]
WinnipegJets = 52,
/// <summary>
/// Arizona Coyotes
/// </summary>
[TeamActive(false)]
ArizonaCoyotes = 53,
/// <summary>
/// Vegas Golden Knights
/// </summary>
[TeamActive(true)]
VegasGoldenKnights = 54,
/// <summary>
/// Seattle Kraken
/// </summary>
[TeamActive(true)]
SeattleKraken = 55,
/// <summary>
/// Utah Hockey Club
/// </summary>
[TeamActive(true)]
UtahHockeyClub = 59
}
2 changes: 1 addition & 1 deletion Nhl.Api.Domain/Models/Draft/DraftYear.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


namespace Nhl.Api.Models.Draft;

/// <summary>
Expand Down
160 changes: 160 additions & 0 deletions Nhl.Api.Domain/Models/Draft/PlayerDraftRanking.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
using Newtonsoft.Json;
using System.Collections.Generic;

namespace Nhl.Api.Models.Draft;

/// <summary>
/// The NHL draft player category
/// </summary>
public class PlayerDraftCategory
{
/// <summary>
/// The ID of the player draft category
/// </summary>
[JsonProperty("id")]
public int? Id { get; set; }

/// <summary>
/// The name of the player draft category
/// </summary>
[JsonProperty("name")]
public string Name { get; set; }

/// <summary>
/// The consumer key of the player draft category
/// </summary>
[JsonProperty("consumerKey")]
public string ConsumerKey { get; set; }
}

/// <summary>
/// The NHL draft player ranking for each prospective player
/// </summary>
public class PlayerDraftRanking
{
/// <summary>
/// The last name of the player
/// </summary>
[JsonProperty("lastName")]
public string LastName { get; set; }

/// <summary>
/// The first name of the player
/// </summary>
[JsonProperty("firstName")]
public string FirstName { get; set; }

/// <summary>
/// The position code of the player
/// </summary>
[JsonProperty("positionCode")]
public string PositionCode { get; set; }

/// <summary>
/// The shooting or catching hand of the player
/// </summary>
[JsonProperty("shootsCatches")]
public string ShootsCatches { get; set; }

/// <summary>
/// The height of the player in inches
/// </summary>
[JsonProperty("heightInInches")]
public int? HeightInInches { get; set; }

/// <summary>
/// The weight of the player in pounds
/// </summary>
[JsonProperty("weightInPounds")]
public int? WeightInPounds { get; set; }

/// <summary>
/// The last amateur club of the player
/// </summary>
[JsonProperty("lastAmateurClub")]
public string LastAmateurClub { get; set; }

/// <summary>
/// The last amateur league of the player
/// </summary>
[JsonProperty("lastAmateurLeague")]
public string LastAmateurLeague { get; set; }

/// <summary>
/// The birth date of the player
/// </summary>
[JsonProperty("birthDate")]
public string BirthDate { get; set; }

/// <summary>
/// The birth city of the player
/// </summary>
[JsonProperty("birthCity")]
public string BirthCity { get; set; }

/// <summary>
/// The birth state or province of the player
/// </summary>
[JsonProperty("birthStateProvince")]
public string BirthStateProvince { get; set; }

/// <summary>
/// The birth country of the player
/// </summary>
[JsonProperty("birthCountry")]
public string BirthCountry { get; set; }

/// <summary>
/// The midterm rank of the player
/// </summary>
[JsonProperty("midtermRank")]
public int? MidtermRank { get; set; }

/// <summary>
/// The final rank of the player
/// </summary>
[JsonProperty("finalRank")]
public int? FinalRank { get; set; }
}

/// <summary>
/// The NHL draft player draft year with all players and their information and rankings
/// </summary>
public class PlayerDraftYear
{
/// <summary>
/// The draft year
/// </summary>
[JsonProperty("draftYear")]
public int? DraftYear { get; set; }

/// <summary>
/// The category ID
/// </summary>
[JsonProperty("categoryId")]
public int? CategoryId { get; set; }

/// <summary>
/// The category key
/// </summary>
[JsonProperty("categoryKey")]
public string? CategoryKey { get; set; }

/// <summary>
/// The list of draft years
/// </summary>
[JsonProperty("draftYears")]
public List<int?> DraftYears { get; set; } = [];

/// <summary>
/// The list of player draft categories
/// </summary>
[JsonProperty("categories")]
public List<PlayerDraftCategory> Categories { get; set; } = [];

/// <summary>
/// The list of player draft rankings
/// </summary>
[JsonProperty("rankings")]
public List<PlayerDraftRanking> Rankings { get; set; } = [];
}
22 changes: 0 additions & 22 deletions Nhl.Api.Domain/Models/Draft/Ranks.cs

This file was deleted.

Loading

0 comments on commit 5e8c748

Please sign in to comment.