Skip to content

Commit

Permalink
removed all failing endpoints and updated new endpoints, created an h…
Browse files Browse the repository at this point in the history
…ttp client and began building various endpoints
  • Loading branch information
Afischbacher committed Dec 10, 2023
1 parent d97a0b7 commit 49effcc
Show file tree
Hide file tree
Showing 45 changed files with 2,921 additions and 7,419 deletions.
53 changes: 53 additions & 0 deletions Nhl.Api.Common/Http/NhlApiWebHttpClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

using System.Net.Http;
using System;

namespace Nhl.Api.Common.Http
{
/// <summary>
/// The dedicated NHL Api Web HTTP Client for the Nhl.Api
/// </summary>
public class NhlApiWebHttpClient : NhlApiHttpClient
{
private static readonly object _lock = new object();
private static HttpClient _httpClient;

/// <summary>
/// The NHL web api for the NHL HTTP API Web NHL-e endpoint
/// </summary>
public const string ClientApiUrl = "https://api-web.nhle.com/";


/// <summary>
/// The dedicated NHL web api HTTP Client for the Nhl.Api
/// </summary>
public NhlApiWebHttpClient() : base(clientApiUri: ClientApiUrl, clientVersion: "v1", timeoutInSeconds: 30)
{

}

/// <summary>
/// The HTTP client for the Nhl.Api
/// </summary>
public override HttpClient HttpClient
{
get
{
lock (_lock)
{
if (_httpClient == null)
{
_httpClient = new HttpClient()
{
BaseAddress = new Uri($"{Client}{ClientVersion}"),
Timeout = Timeout
};

}

return _httpClient;
}
}
}
}
}
2 changes: 1 addition & 1 deletion Nhl.Api.Common/Nhl.Api.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>2.2.1</Version>
<Version>3.0.0</Version>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
Expand Down
18 changes: 18 additions & 0 deletions Nhl.Api.Domain/Enumerations/Game/GameType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Nhl.Api.Enumerations.Game
{
/// <summary>
/// The NHL game type for searching statistics, players, teams and more
/// </summary>
public enum GameType
{
/// <summary>
/// The NHL game type is a regular season game, see <see cref="GameType"/> for more information
/// </summary>
RegularSeason = 2,

/// <summary>
/// The NHL game type is a playoff game, see <see cref="GameType"/> for more information
/// </summary>
Playoffs = 3
}
}
31 changes: 0 additions & 31 deletions Nhl.Api.Domain/Models/Game/GameType.cs

This file was deleted.

215 changes: 215 additions & 0 deletions Nhl.Api.Domain/Models/Game/GoalieSeasonGameLog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
using Newtonsoft.Json;
using System.Collections.Generic;

namespace Nhl.Api.Models.Game
{

/// <summary>
/// An NHL goalie's game log information for a specific season, game type and player
/// </summary>
public class GoalieSeasonGameLog
{
/// <summary>
/// The season identifier for the NHL season for the NHL golie season game log <br/>
/// Example: 20202021 for the 2020-2021 NHL season
/// </summary>
[JsonProperty("seasonId")]
public int SeasonId { get; set; }

/// <summary>
/// The game type identifier for the NHL goalie season game log <br/>
/// Example: 2 for the regular season or 3 for the playoffs
/// </summary>
[JsonProperty("gameTypeId")]
public int GameTypeId { get; set; }

/// <summary>
/// The goalie player collection of seasons and game types played for the NHL season <br/>
/// Example:
/// <code>
/// "playerStatsSeasons": [
/// {
/// "season": 20232024,
/// "gameTypes": [
/// 2
/// ]
/// },
/// {
/// "season": 20222023,
/// "gameTypes": [
/// 2,
/// 3
/// ]
/// },
/// {
/// "season": 20212022,
/// "gameTypes": [
/// 2
/// ]
/// }
/// ]
/// </code>
/// </summary>

[JsonProperty("playerStatsSeasons")]
public List<PlayerStatsSeason> GoalieStatsSeasons { get; set; }

/// <summary>
/// The collection of goalie game logs for the NHL season for an NHL goalie <br/>
/// Example:
/// <code>
/// {
/// "gameId": 2022021167,
/// "teamAbbrev": "TOR",
/// "homeRoadFlag": "R",
/// "gameDate": "2023-03-26",
/// "goals": 0,
/// "assists": 0,
/// "commonName": {
/// "default": "Maple Leafs"
/// },
/// "opponentCommonName": {
/// "default": "Predators"
/// },
/// "gamesStarted": 1,
/// "decision": "W",
/// "shotsAgainst": 25,
/// "goalsAgainst": 2,
/// "savePctg": 0.92,
/// "shutouts": 0,
/// "opponentAbbrev": "NSH",
/// "pim": 0,
/// "toi": "59:55"
/// }
/// </code>
/// </summary>
[JsonProperty("gameLog")]
public List<GoalieGameLog> GoalieGameLogs { get; set; }
}

/// <summary>
/// A goalie's game log information for a specific game, season, game type and player <br/>
/// includes stats such as wins, losses, goals against, save percentage and more
/// </summary>
public class GoalieGameLog
{
/// <summary>
/// The NHL game id for the game a goalie played in <br/>
/// Example: 2022021292
/// </summary>
[JsonProperty("gameId")]
public int GameId { get; set; }

/// <summary>
/// The NHL team abbreviation for the team a goalie plays for <br/>
/// Example: "EDM"
/// </summary>
[JsonProperty("teamAbbrev")]
public string TeamAbbrev { get; set; }

/// <summary>
/// The NHL team home or road flag for the team <br/>
/// Example: "H" or "R" for "Home" or "Road"
/// </summary>
[JsonProperty("homeRoadFlag")]
public string HomeRoadFlag { get; set; }

/// <summary>
/// The NHL game date for the game a player played in <br/>
/// Example: "2023-11-13"
/// </summary>
[JsonProperty("gameDate")]
public string GameDate { get; set; }

/// <summary>
/// The number of goals a player scored in the game <br/>
/// Example: 1
/// </summary>
[JsonProperty("goals")]
public int Goals { get; set; }

/// <summary>
/// The number of assists a player scored in the game <br/>
/// Example: 2
/// </summary>
[JsonProperty("assists")]
public int Assists { get; set; }

/// <summary>
/// The common name for the team a player plays for <br/>
/// Example: "Maple Leafs"
/// </summary>
[JsonProperty("commonName")]
public CommonName CommonName { get; set; }

/// <summary>
/// The opponent team common name information for the team a player plays against <br/>
/// Example: "Canucks"
/// </summary>
[JsonProperty("opponentCommonName")]
public OpponentCommonName OpponentCommonName { get; set; }

/// <summary>
/// The number of games a player started in the game <br/>
/// Example: 1
/// </summary>
[JsonProperty("gamesStarted")]
public int GamesStarted { get; set; }

/// <summary>
/// The outcome of the game for the goalie <br/>
/// Example: W for win, L for loss, O for overtime
/// </summary>
[JsonProperty("decision")]
public string Decision { get; set; }

/// <summary>
/// The number of shots against the goalie <br/>
/// Example: 32
/// </summary>
[JsonProperty("shotsAgainst")]
public int ShotsAgainst { get; set; }

/// <summary>
/// The number of goals against the goalie <br/>
/// Example: 2
/// </summary>
[JsonProperty("goalsAgainst")]
public int GoalsAgainst { get; set; }

/// <summary>
/// The save percentage for the goalie <br/>
/// Example: 0.909091
/// </summary>
[JsonProperty("savePctg")]
public decimal SavePctg { get; set; }

/// <summary>
/// The number of shutouts for the goalie <br/>
/// Example: 0
/// </summary>
[JsonProperty("shutouts")]
public int Shutouts { get; set; }

/// <summary>
/// The oppenent team abbreviation for the team a player plays against <br/>
/// Example: "VAN"
/// </summary>
[JsonProperty("opponentAbbrev")]
public string OpponentAbbrev { get; set; }

/// <summary>
/// The number of penalty minutes a player received in the game <br/>
/// Example : 2
/// </summary>
[JsonProperty("pim")]
public int Pim { get; set; }

/// <summary>
/// The total number of time on ice a player played in the game <br/>
/// Example: "20:00"
/// </summary>
[JsonProperty("toi")]
public string Toi { get; set; }
}
}
Loading

0 comments on commit 49effcc

Please sign in to comment.