def getTags()

in common-lib/src/main/scala/com/gu/workflow/lib/TagService.scala [23:37]


  def getTags(params: List[(String, String)]): Future[List[Tag]] = {
    for {
      response <- getRequest("hyper/tags", params)
      json <- parseBody(response.body).asFutureOption("Error extracting the tag response.")
    } yield {
      json.getOrElse(Json.Null).hcursor.downField("data").as[List[TagArrayItem]] match {
        case Right(tags) => tags.map(_.data)
        case Left(_) => List[Tag]()
      }
    }
  } recoverWith {
    case e: Exception =>
      logger.error(s"error in fetching tags: ${e.getMessage}", e)
      Future(List[Tag]())
  }