in support-workers/src/main/scala/com/gu/acquisitions/AcquisitionDataRowBuilder.scala [131:184]
private def printOptionsFromProduct(product: ProductType, deliveryCountry: Option[Country]): Option[PrintOptions] = {
def printProduct(fulfilmentOptions: FulfilmentOptions, productOptions: ProductOptions): PrintProduct =
(fulfilmentOptions, productOptions) match {
case (HomeDelivery, Everyday) => HomeDeliveryEveryday
case (HomeDelivery, EverydayPlus) => HomeDeliveryEverydayPlus
case (HomeDelivery, Sixday) => HomeDeliverySixday
case (HomeDelivery, SixdayPlus) => HomeDeliverySixdayPlus
case (HomeDelivery, Weekend) => HomeDeliveryWeekend
case (HomeDelivery, WeekendPlus) => HomeDeliveryWeekendPlus
case (HomeDelivery, Saturday) => HomeDeliverySaturday
case (HomeDelivery, SaturdayPlus) => HomeDeliverySaturdayPlus
case (HomeDelivery, Sunday) => HomeDeliverySunday
case (HomeDelivery, SundayPlus) => HomeDeliverySundayPlus
case (NationalDelivery, Everyday) => NationalDeliveryEveryday
case (NationalDelivery, Sixday) => NationalDeliverySixday
case (NationalDelivery, Weekend) => NationalDeliveryWeekend
case (Collection, Everyday) => VoucherEveryday
case (Collection, EverydayPlus) => VoucherEverydayPlus
case (Collection, Sixday) => VoucherSixday
case (Collection, SixdayPlus) => VoucherSixdayPlus
case (Collection, Weekend) => VoucherWeekend
case (Collection, WeekendPlus) => VoucherWeekendPlus
case (Collection, Saturday) => VoucherSaturday
case (Collection, SaturdayPlus) => VoucherSaturdayPlus
case (Collection, Sunday) => VoucherSunday
case (Collection, SundayPlus) => VoucherSundayPlus
case (NoFulfilmentOptions, _) | (_, NoProductOptions) | (Domestic, _) | (RestOfWorld, _) |
(_, NewspaperArchive) | (NationalDelivery, Saturday) | (NationalDelivery, Sunday) |
(NationalDelivery, EverydayPlus) | (NationalDelivery, SixdayPlus) | (NationalDelivery, WeekendPlus) |
(NationalDelivery, SaturdayPlus) | (NationalDelivery, SundayPlus) =>
throw new RuntimeException(
s"Invalid combination of fulfilmentOptions ($fulfilmentOptions) and productOptions ($productOptions)",
)
}
product match {
case p: Paper =>
Some(
PrintOptions(
printProduct(p.fulfilmentOptions, p.productOptions),
Country.UK,
),
)
case _: GuardianWeekly =>
Some(
PrintOptions(
PrintProduct.GuardianWeekly,
deliveryCountry.getOrElse(Country.UK),
),
)
case _ => None
}
}