in archive/src/main/scala/com/gu/footballtimemachine/ArchiveLambda.scala [35:58]
def process()(implicit logger: LambdaLogger): Future[Unit] = {
val paFootballClient = new PaFootballClient(configuration.paApiKey, configuration.paHost)
val today = LocalDate.now.format(DateTimeFormatter.BASIC_ISO_DATE)
val result = for {
matches <- paFootballClient.aroundToday
filteredMatches = matches.filter(inProgress)
} yield {
filteredMatches.foreach { theMatch =>
for {
matchInfo <- paFootballClient.matchInfoString(theMatch.id)
matchEvents <- paFootballClient.matchEventsString(theMatch.id)
} yield {
putFile(s"match/info/apiKey/${theMatch.id}", matchInfo)
putFile(s"match/events/apiKey/${theMatch.id}", matchEvents)
}
}
}
paFootballClient.matchDayString(today).map { matchDay =>
putFile(s"competitions/matchDay/apiKey/$today", matchDay)
}
result.recover {
case e: Exception => logger.log(s"Exception: ${e.getMessage} ${e.getStackTrace.toString}")
}
}