Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
EQuimper committed Sep 17, 2020
0 parents commit 45c2754
Show file tree
Hide file tree
Showing 18 changed files with 4,518 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
nhl_stats_api
.idea/
28 changes: 28 additions & 0 deletions README.md
@@ -0,0 +1,28 @@
This is an unofficial, Go API for the nhl api.

## WORK IN PROGRESS

## Getting Started

```go
import (
"github.com/equimper/nhl_stats_api"
)

func main() {
nhlClient := nhl_stats_api.NewClient()
}

```

## API

| Name | Description | Completed
| --- | --- | --- |
| GetTeams | Return all Team | true
| GetPositions | Return all Position | true
| GetSeasons | Return all Season | true
| GetCurrentSeason | Return current Season | true
| GetConferences | Return all Conference | true
| GetPlayerInfo | Return player info by id | true
| GetStats | Return players stats | false
5 changes: 5 additions & 0 deletions go.mod
@@ -0,0 +1,5 @@
module github.com/equimper/nhl_stats_api

go 1.15

require github.com/stretchr/testify v1.6.1
11 changes: 11 additions & 0 deletions go.sum
@@ -0,0 +1,11 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
21 changes: 21 additions & 0 deletions json_file.go
@@ -0,0 +1,21 @@
package nhl_stats_api

import (
"fmt"
"io/ioutil"
"os"
)

func getJsonFile(relativePath string) ([]byte, error) {
path, err := os.Getwd()
if err != nil {
return nil, err
}

file, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", path, relativePath))
if err != nil {
return nil, err
}

return file, nil
}
193 changes: 193 additions & 0 deletions models.go
@@ -0,0 +1,193 @@
package nhl_stats_api

type Conference struct {
ID int `json:"id"`
Name string `json:"name"`
Link string `json:"link"`
Abbreviation string `json:"abbreviation"`
ShortName string `json:"shortName"`
Active bool `json:"active"`
}

type Position struct {
Abbrev string `json:"abbrev"`
Code string `json:"code"`
FullName string `json:"fullName"`
Type string `json:"type"`
}

type PlayerInfo struct {
ID int `json:"id"`
FullName string `json:"fullName"`
Link string `json:"link"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
PrimaryNumber string `json:"primaryNumber"`
BirthDate string `json:"birthDate"`
BirthStateProvince *string `json:"birthStateProvince"`
CurrentAge int `json:"currentAge"`
BirthCity string `json:"birthCity"`
BirthCountry string `json:"birthCountry"`
Nationality string `json:"nationality"`
Height string `json:"height"`
Weight int `json:"weight"`
Active bool `json:"active"`
AlternateCaptain bool `json:"alternateCaptain"`
Captain bool `json:"captain"`
Rookie bool `json:"rookie"`
ShootsCatches string `json:"shootsCatches"`
RosterStatus string `json:"rosterStatus"`
CurrentTeam struct {
ID int `json:"id"`
Name string `json:"name"`
Link string `json:"link"`
} `json:"currentTeam"`
PrimaryPosition struct {
Code string `json:"code"`
Name string `json:"name"`
Type string `json:"type"`
Abbreviation string `json:"abbreviation"`
} `json:"primaryPosition"`
}

type Team struct {
ID int `json:"id"`
Name string `json:"name"`
Link string `json:"link"`
Venue struct {
Name string `json:"name"`
Link string `json:"link"`
City string `json:"city"`
TimeZone struct {
ID string `json:"id"`
Offset int `json:"offset"`
Tz string `json:"tz"`
} `json:"timeZone"`
} `json:"venue"`
Abbreviation string `json:"abbreviation"`
TeamName string `json:"teamName"`
LocationName string `json:"locationName"`
FirstYearOfPlay string `json:"firstYearOfPlay"`
Division struct {
ID int `json:"id"`
Name string `json:"name"`
NameShort string `json:"nameShort"`
Link string `json:"link"`
Abbreviation string `json:"abbreviation"`
} `json:"division"`
Conference struct {
ID int `json:"id"`
Name string `json:"name"`
Link string `json:"link"`
} `json:"conference"`
Franchise struct {
FranchiseID int `json:"franchiseId"`
TeamName string `json:"teamName"`
Link string `json:"link"`
} `json:"franchise"`
ShortName string `json:"shortName"`
OfficialSiteURL string `json:"officialSiteUrl"`
FranchiseID int `json:"franchiseId"`
Active bool `json:"active"`
}

type League struct {
ID *int `json:"id"`
Name string `json:"name"`
}

type Division struct {
ID int `json:"id"`
Name string `json:"name"`
NameShort string `json:"nameShort"`
Link string `json:"link"`
Abbreviation string `json:"abbreviation"`
Conference struct {
ID int `json:"id"`
Name string `json:"name"`
Link string `json:"link"`
} `json:"conference"`
Active bool `json:"active"`
}

type SeasonStat struct {
Season string `json:"season"`
Team Team `json:"team"`
League League `json:"league"`
}

type ForwardSeasonStat struct {
SeasonStat
Stat ForwardStat `json:"stat"`
}

// ForwardStats is the stats for a forward
type ForwardStat struct {
Assists int `json:"assists"`
Goals int `json:"goals"`
Pim int `json:"pim"`
Games int `json:"games"`
PowerPlayGoals int `json:"powerPlayGoals"`
PenaltyMinutes string `json:"penaltyMinutes"`
ShortHandedGoals int `json:"shortHandedGoals"`
PlusMinus int `json:"plusMinus"`
Points int `json:"points"`
TimeOnIce *string `json:"timeOnIce"`
Shots *int `json:"shots"`
Hits *int `json:"hits"`
PowerPlayPoints *int `json:"powerPlayPoints"`
PowerPlayTimeOnIce *string `json:"powerPlayTimeOnIce"`
EvenTimeOnIce *string `json:"evenTimeOnIce"`
FaceOffPct *float64 `json:"faceOffPct"`
ShotPct *float64 `json:"shotPct"`
GameWinningGoals *int `json:"gameWinningGoals"`
OverTimeGoals *int `json:"overTimeGoals"`
ShortHandedPoints *int `json:"shortHandedPoints"`
ShortHandedTimeOnIce *string `json:"shortHandedTimeOnIce"`
Blocked *int `json:"blocked"`
Shifts *int `json:"shifts"`
}

type GoalieSeasonStat struct {
SeasonStat
Stat GoalieStat `json:"stat"`
}

// GoalieStats is the stats for a goalie
type GoalieStat struct {
TimeOnIce string `json:"timeOnIce"`
Shutouts int `json:"shutouts"`
Wins int `json:"wins"`
Losses int `json:"losses"`
Saves int `json:"saves"`
SavePercentage float64 `json:"savePercentage"`
GoalAgainstAverage float64 `json:"goalAgainstAverage"`
Games int `json:"games"`
ShotsAgainst int `json:"shotsAgainst"`
GoalsAgainst int `json:"goalsAgainst"`
Ties *int `json:"ties"`
Ot *int `json:"ot"`
PowerPlaySaves *int `json:"powerPlaySaves"`
ShortHandedSaves *int `json:"shortHandedSaves"`
EvenSaves *int `json:"evenSaves"`
ShortHandedShots *int `json:"shortHandedShots"`
EvenShots *int `json:"evenShots"`
PowerPlayShots *int `json:"powerPlayShots"`
GamesStarted *int `json:"gamesStarted"`
PowerPlaySavePercentage *float64 `json:"powerPlaySavePercentage"`
ShortHandedSavePercentage *float64 `json:"shortHandedSavePercentage"`
EvenStrengthSavePercentage *float64 `json:"evenStrengthSavePercentage"`
}

type Season struct {
SeasonID string `json:"seasonId"`
RegularSeasonStartDate string `json:"regularSeasonStartDate"`
RegularSeasonEndDate string `json:"regularSeasonEndDate"`
SeasonEndDate string `json:"seasonEndDate"`
NumberOfGames int `json:"numberOfGames"`
TiesInUse bool `json:"tiesInUse"`
OlympicsParticipation bool `json:"olympicsParticipation"`
ConferencesInUse bool `json:"conferencesInUse"`
DivisionsInUse bool `json:"divisionsInUse"`
WildCardInUse bool `json:"wildCardInUse"`
}

0 comments on commit 45c2754

Please sign in to comment.