def read()

in app/com/gu/memsub/subsv2/reads/ChargeListReads.scala [130:135]


    def read(cat: PlanChargeMap, charges: List[ZuoraCharge]): ValidationNel[String, FreeCharge[P]] = charges match {
      case charge :: Nil => (product.read(cat, charge) |@| charge.pricing.prices.forall(_.amount == 0).option(charge.pricing)
        .toSuccess(NonEmptyList("Could not read free charge: Charge is paid"))).apply({ case (p, _) => FreeCharge(p, charge.pricing.currencies) })
      case charge :: others => Validation.failureNel(s"Too many charges! I got $charge and $others")
      case Nil => Validation.failureNel(s"No charges found!")
    }