Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRTII-1412 Add PaxFigures & json formats #192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -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])