in src/main/scala/com/gu/zuora/fullexport/Impl.scala [158:175]
@tailrec def getJobResult(jobId: String): JobResults = {
val jobResults = HttpWithLongTimeout(s"$zuoraApiHost/v1/batch-query/jobs/$jobId")
.header("Authorization", s"Bearer ${accessToken()}")
.header("Content-Type", "application/json")
.asString
.tap(logError)
.body
.pipe(read[JobResults](_))
.tap(job => Assert(s"Job $jobId should not be aborted or cancelled", jobIsHealthy(job)))
if (jobResults.batches.forall(_.status == "completed"))
jobResults
else {
logger.info(s"Checking if job is done $jobResults ...")
Thread.sleep(30.seconds.toMillis)
getJobResult(jobId) // Keep trying until lambda timeout
}
}