private[this] def decodeSectionsJson()

in src/main/scala/com/gu/contentapi/mostviewedvideo/OphanStore.scala [74:88]


  private[this] def decodeSectionsJson(json: String, edition: Option[String]): Either[CustomError, List[MostViewedVideoContainerModel]] = {
    import io.circe.generic.auto._
    decode[Map[String, List[MostViewedVideoModel]]](json).fold(
      { error => Left(CustomError(error.getMessage)) },
      { sections =>
        {
          val containers = sections map { sectionData =>
            val sectionId = sectionData._1
            val videos = sectionData._2
            MostViewedVideoContainerModel(buildId(edition, Some(sectionId)), videos)
          }
          Right(containers.toList)
        }
      })
  }