def downloadCsvFile()

in src/main/scala/com/gu/zuora/fullexport/Impl.scala [177:189]


  def downloadCsvFile(batch: Batch, objectName: String, start: LocalDate) = {
    val chunkFile = file"$scratchDir/$objectName-$start.csv"
    Try(chunkFile.delete())
    logger.info(s"Downloading $batch ...")
    val fileId = batch.fileId.getOrElse(Assert(s"Batch should have fileId: $batch"))
    val binary = HttpWithLongTimeout(s"$zuoraApiHost/v1/file/$fileId")
      .header("Authorization", s"Bearer ${accessToken()}")
      .asBytes
      .body
    val tempFile = File.newTemporaryFile()
    tempFile.writeByteArray(binary).unGzipTo(chunkFile)
    chunkFile
  }