I created a generic function to get from Bitbucket-API (It gives you the data in pages if there is to much data and the next page URL is under "next" in the response).
def getAggregatedDataWithNext[T](url: String)(implicit reader: Reads[T]): Future[Seq[T]]= {
val featureResponse = ws.url(url).withAuth(AuthUserName, AuthPassword, WSAuthScheme.BASIC).addQueryStringParameters("pagelen" -> "100").get()
featureResponse.map(response => {
val resJson = response.json
val tSequence = (resJson \ "values").as[Seq[T]]
(resJson \ "next").asOpt[String] match {
case None => tSequence
case Some(nextUrl) => getAggregatedDataWithNext(nextUrl).flatMap(tSequence ++ _)
}
})
}
I get an error:
type mismatch;
found : Seq[T]
required: scala.concurrent.Future[?]
