-
Notifications
You must be signed in to change notification settings - Fork 3
/
teams.go
67 lines (56 loc) · 1.75 KB
/
teams.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package mlb
import (
"strconv"
)
const (
Angels = 108 // Los Angeles Angels
Diamondbacks = 109 // Arizona Diamondbacks
Orioles = 110 // Baltimore Orioles
RedSox = 111 // Boston Red Sox
Cubs = 112 // Chicago Cubs
Reds = 113 // Cincinnati Reds
Indians = 114 // Cleveland Indians - renamed to Guardians
Guardians = 114 // Cleveland Guardians - formerly the Indians
Rockies = 115 // Colorado Rockies
Tigers = 116 // Detroit Tigers
Astros = 117 // Houston Astros
Royals = 118 // Kansas City Royals
Dodgers = 119 // Los Angeles Dodgers
Nationals = 120 // Washington Nationals
Mets = 121 // New York Mets
Athletics = 133 // Oakland Athletics
Pirates = 134 // Pittsburgh Pirates
Padres = 135 // San Diego Padres
Mariners = 136 // Seattle Mariners
Giants = 137 // San Francisco Giants
Cardinals = 138 // St. Louis Cardinals
Rays = 139 // Tampa Bay Rays
Rangers = 140 // Texas Rangers
BlueJays = 141 // Toronto Blue Jays
Twins = 142 // Minnesota Twins
Phillies = 143 // Philadelphia Phillies
Braves = 144 // Atlanta Braves
WhiteSox = 145 // Chicago White Sox
Marlins = 146 // Miami Marlins
Yankees = 147 // New York Yankees
Brewers = 158 // Milwaukee Brewers
)
func (m *Mlb) GetTeams(teamIds ...int) ([]Team, error) {
params := map[string]string{}
if params["sportId"] == "" {
params["sportId"] = "1"
}
if len(teamIds) > 0 {
for i := range teamIds {
params["teamId"] = strconv.Itoa(teamIds[i])
if i != len(teamIds)-1 {
params["teamId"] = params["teamId"] + ","
}
}
}
resp, err := m.Call("/teams", params)
if err != nil {
return []Team{}, err
}
return resp.Teams, nil
}