diff --git a/jvm/src/main/scala/uk/gov/homeoffice/drt/jsonformats/PaxFiguresJsonFormat.scala b/jvm/src/main/scala/uk/gov/homeoffice/drt/jsonformats/PaxFiguresJsonFormat.scala new file mode 100644 index 00000000..1d4e06e7 --- /dev/null +++ b/jvm/src/main/scala/uk/gov/homeoffice/drt/jsonformats/PaxFiguresJsonFormat.scala @@ -0,0 +1,22 @@ +package uk.gov.homeoffice.drt.jsonformats + +import spray.json.{DefaultJsonProtocol, JsString, JsValue, RootJsonFormat} +import uk.gov.homeoffice.drt.models.{DayPaxFigures, PaxFigures} +import uk.gov.homeoffice.drt.ports.Terminals.Terminal + +object DayPaxFiguresJsonFormat extends DefaultJsonProtocol { + + import uk.gov.homeoffice.drt.jsonformats.LocalDateJsonFormat._ + + implicit val dayPaxFiguresJsonFormat: RootJsonFormat[DayPaxFigures] = jsonFormat9(DayPaxFigures.apply) + + implicit object TerminalJsonFormat extends RootJsonFormat[Terminal] { + override def read(json: JsValue): Terminal = json match { + case JsString(dateStr) => Terminal(dateStr) + } + + override def write(obj: Terminal): JsValue = JsString(obj.toString) + } + + implicit val paxFiguresJsonFormat: RootJsonFormat[PaxFigures] = jsonFormat3(PaxFigures.apply) +} diff --git a/jvm/src/main/scala/uk/gov/homeoffice/drt/models/PaxFigures.scala b/jvm/src/main/scala/uk/gov/homeoffice/drt/models/PaxFigures.scala new file mode 100644 index 00000000..26154bd3 --- /dev/null +++ b/jvm/src/main/scala/uk/gov/homeoffice/drt/models/PaxFigures.scala @@ -0,0 +1,9 @@ +package uk.gov.homeoffice.drt.models + +import uk.gov.homeoffice.drt.ports.Terminals.Terminal +import uk.gov.homeoffice.drt.time.LocalDate + + +case class PaxFigures(terminal: Terminal, models: Seq[String], paxFigures: Seq[DayPaxFigures]) + +case class DayPaxFigures(date: LocalDate, actPax: Int, actCapPct: Double, forecastPax: Int, forecastCapPct: Double, drtFcstPax: Int, drtFcstCapPct: Double, modelPax: Map[String, Int], modelCapPct: Map[String, Double])