def parseContentIds()

in src/main/scala/com/gu/flexible/snapshotter/logic/ApiLogic.scala [31:48]


  def parseContentIds(json:JsValue): Seq[String] = (json \ "data").as[Seq[JsObject]].map(getId)

  def fiveMinutesAgo: DateTime = new DateTime().minusMinutes(5)

  private[snapshotter] def getId(doc: JsObject): String = (doc \ "data" \ "id").as[String]

  private[snapshotter] def jsonOnOKStatus(request: StandaloneWSRequest)(implicit context:ExecutionContext): Attempt[JsValue] = {
    val attempt = Attempt.Async.Right(request.get())
    attempt.flatMap { response =>
      response.status match {
        case 200 => Attempt.Right(Json.parse(response.body))
        case _ =>
          val message = s"${request.toString}: Response status was ${response.status}:${response.statusText}"
          log.warn(message)
          Attempt.Left(AttemptErrors(AttemptError(message)))
      }
    }
  }