package statsapi import ( "encoding/json" ) type FeedParams struct { GamePk string } type FeedResponse struct { GamePk string MetaData metadata GameData gamedata LiveData livedata } type metadata struct { TimeStamp string } type gamedata struct { Teams teams } type teams struct { Away team Home team } type team struct { LocationName string TeamName string } type livedata struct { Plays plays Linescore linescore } type plays struct { AllPlays []Play CurrentPlay Play ScoringPlays []json.Number } type Play struct { Result result About about AtBatIndex int } type result struct { Event string Description string RBI int AwayScore int HomeScore int } type about struct { AtBatIndex json.Number IsTopInning bool Inning json.Number IsScoringPlay bool CaptivatingIndex json.Number } type linescore struct { Teams teamLines } type teamLines struct { Home teamline Away teamline } type teamline struct { Runs json.Number Hits json.Number Errors json.Number LeftOnBase json.Number } func (p *Play) Patch(patch Patch) { instructions := patch.Diff stem := "/liveData/plays/currentPlay" for _, i := range instructions { if i.Op == "add" && i.Path == stem+"/result/description" { p.Result.Description = i.Value.(string) } else if i.Op == "replace" && i.Path == stem+"/about/isScoringPlay" { p.About.IsScoringPlay = i.Value.(bool) } else if i.Op == "replace" && i.Path == stem+"/result/homeScore" { p.Result.HomeScore = int(i.Value.(float64)) } else if i.Op == "replace" && i.Path == stem+"/result/awayScore" { p.Result.AwayScore = int(i.Value.(float64)) } else if i.Op == "add" && i.Path == stem+"/result/event" { p.Result.Event = i.Value.(string) } else if i.Op == "replace" && i.Path == stem+"/atBatIndex" { p.AtBatIndex = int(i.Value.(float64)) } } }