diff --git a/build.sbt b/build.sbt index c1d28b5f..8b3024f7 100644 --- a/build.sbt +++ b/build.sbt @@ -61,7 +61,8 @@ def faciaJson(playJsonVersion: PlayJsonVersion) = playJsonSpecificProject("facia commonsIo, playJsonVersion.lib, "org.scala-lang.modules" %% "scala-collection-compat" % "2.11.0", - scalaLogging + scalaLogging, + playJsonExtensions ), artifactProducingSettings(supportScala3 = playJsonVersion.supportsScala3) ) @@ -73,7 +74,7 @@ def fapiClient(playJsonVersion: PlayJsonVersion) = playJsonSpecificProject("fap contentApiDefault, commercialShared, scalaTestMockito, - mockito + mockito, ), artifactProducingSettings(supportScala3 = false) // currently blocked by contentApi & commercialShared clients ) diff --git a/facia-json/src/main/scala/com/gu/facia/client/models/Config.scala b/facia-json/src/main/scala/com/gu/facia/client/models/Config.scala index 5dceb91b..83e626b7 100644 --- a/facia-json/src/main/scala/com/gu/facia/client/models/Config.scala +++ b/facia-json/src/main/scala/com/gu/facia/client/models/Config.scala @@ -1,7 +1,9 @@ package com.gu.facia.client.models +import ai.x.play.json.Encoders.encoder import com.typesafe.scalalogging.StrictLogging import play.api.libs.json._ +import ai.x.play.json.Jsonx object Backfill { implicit val jsonFormat: OFormat[Backfill] = Json.format[Backfill] @@ -201,7 +203,7 @@ object DisplayHintsJson { case class DisplayHintsJson(maxItemsToDisplay: Option[Int]) object CollectionConfigJson { - implicit val jsonFormat: OFormat[CollectionConfigJson] = Json.format[CollectionConfigJson] + implicit val jsonFormat: OFormat[CollectionConfigJson] = Jsonx.formatCaseClass[CollectionConfigJson] val emptyConfig: CollectionConfigJson = withDefaults(None, None, None, None, None, None, None, None, None, None, None, None) @@ -227,7 +229,9 @@ object CollectionConfigJson { targetedTerritory: Option[TargetedTerritory] = None, platform: Option[CollectionPlatform] = None, frontsToolSettings: Option[FrontsToolSettings] = None, - suppressImages: Option[Boolean] = None + suppressImages: Option[Boolean] = None, + containerStyle: Option[String] = None, + imageAspectRatio: Option[String] = None ): CollectionConfigJson = CollectionConfigJson( displayName, @@ -251,8 +255,9 @@ object CollectionConfigJson { targetedTerritory, platform, frontsToolSettings, - suppressImages - ) + suppressImages, + containerStyle, + imageAspectRatio) } case class CollectionConfigJson( @@ -277,7 +282,9 @@ case class CollectionConfigJson( targetedTerritory: Option[TargetedTerritory], platform: Option[CollectionPlatform], frontsToolSettings: Option[FrontsToolSettings], - suppressImages: Option[Boolean] + suppressImages: Option[Boolean], + containerStyle: Option[String], + imageAspectRatio: Option[String] ) { val collectionType = `type` } diff --git a/fapi-client/src/main/scala/com/gu/facia/api/models/collectionconfig.scala b/fapi-client/src/main/scala/com/gu/facia/api/models/collectionconfig.scala index 35ee87b5..c92b029b 100644 --- a/fapi-client/src/main/scala/com/gu/facia/api/models/collectionconfig.scala +++ b/fapi-client/src/main/scala/com/gu/facia/api/models/collectionconfig.scala @@ -35,7 +35,9 @@ case class CollectionConfig( targetedTerritory: Option[TargetedTerritory], platform: CollectionPlatform = AnyPlatform, frontsToolSettings: Option[FrontsToolSettings], - suppressImages: Boolean) + suppressImages: Boolean, + containerStyle: Option[String], + imageAspectRatio: Option[String]) object CollectionConfig { val DefaultCollectionType = "fixed/small/slow-IV" @@ -62,7 +64,9 @@ object CollectionConfig { targetedTerritory = None, platform = AnyPlatform, frontsToolSettings = None, - suppressImages = false) + suppressImages = false, + containerStyle = None, + imageAspectRatio = None) def fromCollectionJson(collectionJson: CollectionConfigJson): CollectionConfig = CollectionConfig( @@ -87,5 +91,7 @@ object CollectionConfig { collectionJson.targetedTerritory, collectionJson.platform.getOrElse(AnyPlatform), collectionJson.frontsToolSettings, - collectionJson.suppressImages.exists(identity)) + collectionJson.suppressImages.exists(identity), + collectionJson.containerStyle, + collectionJson.imageAspectRatio) } diff --git a/project/dependencies.scala b/project/dependencies.scala index 71171aa1..f4627651 100644 --- a/project/dependencies.scala +++ b/project/dependencies.scala @@ -12,6 +12,7 @@ object Dependencies { val scalaTest = "org.scalatest" %% "scalatest" % "3.2.18" % Test val scalaLogging = "com.typesafe.scala-logging" %% "scala-logging" % "3.9.5" val commercialShared = "com.gu" %% "commercial-shared" % "6.1.8" + val playJsonExtensions = "ai.x" %% "play-json-extensions" % "0.42.0" case class PlayJsonVersion( majorMinorVersion: String,