1
+ # ' Class representing an active session connected to the American Soccer Analysis public API.
2
+ # '
3
+ # ' Does not take any arguments to initialize.
1
4
# ' @export
2
5
AmericanSoccerAnalysis <- R6 :: R6Class(" AmericanSoccerAnalysis" ,
3
6
public = list (
7
+ # ' @field API_VERSION Latest API version.
4
8
API_VERSION = " v1" ,
9
+
10
+ # ' @field LEAGUES List of stylized league names.
5
11
LEAGUES = c(" nwsl" , " mls" , " uslc" , " usl1" , " nasl" ),
12
+
13
+ # ' @field BASE_URL API base URL.
6
14
BASE_URL = NULL ,
15
+
16
+ # ' @field players Data frame containing players from all leagues.
7
17
players = NULL ,
18
+
19
+ # ' @field teams Data frame containing teams from all leagues.
8
20
teams = NULL ,
21
+
22
+ # ' @field stadia Data frame containing stadia from all leagues.
9
23
stadia = NULL ,
24
+
25
+ # ' @field managers Data frame containing managers from all leagues.
10
26
managers = NULL ,
27
+
28
+ # ' @field referees Data frame containing referees from all leagues.
11
29
referees = NULL ,
30
+
31
+ # ' @description
32
+ # ' Creates a new `AmericanSoccerAnalysis` object.
33
+ # ' @return A new `AmericanSoccerAnalysis` object.
12
34
initialize = function () {
13
35
self $ BASE_URL <- glue :: glue(" https://app.americansocceranalysis.com/api/{self$API_VERSION}/" )
14
36
self $ players <- get_entity(" player" , self )
@@ -17,26 +39,65 @@ AmericanSoccerAnalysis <- R6::R6Class("AmericanSoccerAnalysis",
17
39
self $ managers <- get_entity(" manager" , self )
18
40
self $ referees <- get_entity(" referee" , self )
19
41
},
42
+
43
+ # ' @description
44
+ # ' Retrieves a data frame containing player names, IDs, and other metadata.
45
+ # ' @param leagues Leagues on which to filter. Accepts a character vector of length >= 1.
46
+ # ' @param ids Player IDs on which to filter. Accepts a character vector of length >= 1.
47
+ # ' @param names Player names on which to filter. Partial matches are accepted. Accepts a character vector of length >= 1.
20
48
get_players = function (leagues , ids , names ) {
21
49
players <- filter_entity(self $ players , self $ LEAGUES , leagues , ids , names )
22
50
return (players )
23
51
},
52
+
53
+ # ' @description
54
+ # ' Retrieves a data frame containing team names, abbreviations, and IDs.
55
+ # ' @param leagues Leagues on which to filter. Accepts a character vector of length >= 1.
56
+ # ' @param ids Team IDs on which to filter. Accepts a character vector of length >= 1.
57
+ # ' @param names Team names on which to filter. Partial matches and abbreviations are accepted. Accepts a character vector of length >= 1.
24
58
get_teams = function (leagues , ids , names ) {
25
59
teams <- filter_entity(self $ teams , self $ LEAGUES , leagues , ids , names )
26
60
return (teams )
27
61
},
62
+
63
+ # ' @description
64
+ # ' Retrieves a data frame containing stadium names, IDs, and other metadata.
65
+ # ' @param leagues Leagues on which to filter. Accepts a character vector of length >= 1.
66
+ # ' @param ids Stadium IDs on which to filter. Accepts a character vector of length >= 1.
67
+ # ' @param names Stadium names on which to filter. Partial matches are accepted. Accepts a character vector of length >= 1.
28
68
get_stadia = function (leagues , ids , names ) {
29
69
stadia <- filter_entity(self $ stadia , self $ LEAGUES , leagues , ids , names )
30
70
return (stadia )
31
71
},
72
+
73
+ # ' @description
74
+ # ' Retrieves a data frame containing manager names and IDs.
75
+ # ' @param leagues Leagues on which to filter. Accepts a character vector of length >= 1.
76
+ # ' @param ids Manager IDs on which to filter. Accepts a character vector of length >= 1.
77
+ # ' @param names Manager names on which to filter. Partial matches are accepted. Accepts a character vector of length >= 1.
32
78
get_managers = function (leagues , ids , names ) {
33
79
managers <- filter_entity(self $ managers , self $ LEAGUES , leagues , ids , names )
34
80
return (managers )
35
81
},
82
+
83
+ # ' @description
84
+ # ' Retrieves a data frame containing referee names and IDs.
85
+ # ' @param leagues Leagues on which to filter. Accepts a character vector of length >= 1.
86
+ # ' @param ids Referee IDs on which to filter. Accepts a character vector of length >= 1.
87
+ # ' @param names Referee names on which to filter. Partial matches are accepted. Accepts a character vector of length >= 1.
36
88
get_referees = function (leagues , ids , names ) {
37
89
referees <- filter_entity(self $ referees , self $ LEAGUES , leagues , ids , names )
38
90
return (referees )
39
91
},
92
+
93
+ # ' @description
94
+ # ' Retrieves a data frame containing game IDs, dates, opponents, scores, and other metadata.
95
+ # ' @param leagues Leagues on which to filter. Accepts a character vector of length >= 1.
96
+ # ' @param game_ids Game IDs on which to filter. Accepts a character vector of length >= 1.
97
+ # ' @param team_ids Team IDs on which to filter. Accepts a character vector of length >= 1.
98
+ # ' @param team_names Team names on which to filter. Partial matches and abbreviations are accepted. Accepts a character vector of length >= 1.
99
+ # ' @param seasons Seasons on which to filter. Accepts a character or integer vector of length >= 1.
100
+ # ' @param stages Stages (e.g., regular season, playoffs, etc.) on which to filter. See the \url{https://app.americansocceranalysis.com/api/v1/__swagger__/}{API documentation} for possible values. Accepts a character vector of length >= 1.
40
101
get_games = function (leagues , game_ids , team_ids , team_names , seasons , stages ) {
41
102
games <- get_games(self , leagues , game_ids , team_ids , team_names , seasons , stages )
42
103
return (games )
0 commit comments