|
@@ -126,18 +126,17 @@ object EndpointResponse {
|
|
|
def getTeams(): ListOfTeams = {
|
|
def getTeams(): ListOfTeams = {
|
|
|
implicit val teamsResponseR: Reader[TeamsResponse] = macroR[TeamsResponse]
|
|
implicit val teamsResponseR: Reader[TeamsResponse] = macroR[TeamsResponse]
|
|
|
|
|
|
|
|
- def getAllData(endpoint: String) = {
|
|
|
|
|
- val response =
|
|
|
|
|
- doPaginatedRequest[TeamsResponse](endpoint, 1, teams_per_page)
|
|
|
|
|
- response.getNext() match {
|
|
|
|
|
- case Some(page) =>
|
|
|
|
|
- // TODO: This stops on the second page. This should be recursive
|
|
|
|
|
- response.data ++ (doPaginatedRequest[TeamsResponse](
|
|
|
|
|
- endpoint,
|
|
|
|
|
- page,
|
|
|
|
|
- teams_per_page
|
|
|
|
|
- )).data
|
|
|
|
|
- case None => response.data
|
|
|
|
|
|
|
+ def getAllData(
|
|
|
|
|
+ endpoint: String,
|
|
|
|
|
+ dataSoFar: ListOfTeams = Nil,
|
|
|
|
|
+ page: Option[Int] = Some(1)
|
|
|
|
|
+ ): ListOfTeams = {
|
|
|
|
|
+ page match {
|
|
|
|
|
+ case None => dataSoFar
|
|
|
|
|
+ case Some(value) =>
|
|
|
|
|
+ val response =
|
|
|
|
|
+ doPaginatedRequest[TeamsResponse](endpoint, value, teams_per_page)
|
|
|
|
|
+ getAllData(endpoint, response.data ++ dataSoFar, response.getNext())
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -147,19 +146,28 @@ object EndpointResponse {
|
|
|
def getGames(season: Int, teams: List[Int]): ListOfGames = {
|
|
def getGames(season: Int, teams: List[Int]): ListOfGames = {
|
|
|
implicit val gamesResponseR: Reader[GamesResponse] = macroR[GamesResponse]
|
|
implicit val gamesResponseR: Reader[GamesResponse] = macroR[GamesResponse]
|
|
|
|
|
|
|
|
- def getAllData(endpoint: String, params: Map[String, Any]) = {
|
|
|
|
|
- val response =
|
|
|
|
|
- doPaginatedRequest[GamesResponse](endpoint, 1, games_per_page, params)
|
|
|
|
|
- response.getNext() match {
|
|
|
|
|
- case Some(page) =>
|
|
|
|
|
- // TODO: This stops on the second page. This should be recursive
|
|
|
|
|
- response.data ++ (doPaginatedRequest[GamesResponse](
|
|
|
|
|
|
|
+ def getAllData(
|
|
|
|
|
+ endpoint: String,
|
|
|
|
|
+ params: Map[String, Any],
|
|
|
|
|
+ dataSoFar: ListOfGames = Nil,
|
|
|
|
|
+ page: Option[Int] = Some(1)
|
|
|
|
|
+ ): ListOfGames = {
|
|
|
|
|
+ page match {
|
|
|
|
|
+ case None => dataSoFar
|
|
|
|
|
+ case Some(value) =>
|
|
|
|
|
+ val response =
|
|
|
|
|
+ doPaginatedRequest[GamesResponse](
|
|
|
|
|
+ endpoint,
|
|
|
|
|
+ value,
|
|
|
|
|
+ teams_per_page,
|
|
|
|
|
+ params
|
|
|
|
|
+ )
|
|
|
|
|
+ getAllData(
|
|
|
endpoint,
|
|
endpoint,
|
|
|
- page,
|
|
|
|
|
- games_per_page,
|
|
|
|
|
- params
|
|
|
|
|
- )).data
|
|
|
|
|
- case None => response.data
|
|
|
|
|
|
|
+ params,
|
|
|
|
|
+ response.data ++ dataSoFar,
|
|
|
|
|
+ response.getNext()
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|