diff --git a/lib/dotcom_web/controllers/schedule/finder_api.ex b/lib/dotcom_web/controllers/schedule/finder_api.ex index 30244e91d9..27cc2d4635 100644 --- a/lib/dotcom_web/controllers/schedule/finder_api.ex +++ b/lib/dotcom_web/controllers/schedule/finder_api.ex @@ -40,7 +40,16 @@ defmodule DotcomWeb.ScheduleController.FinderApi do # Leverage the JourneyList module to return a simplified set of trips @spec journeys(Plug.Conn.t(), map) :: Plug.Conn.t() - def journeys(conn, %{"stop" => stop_id, "date" => date} = params) do + def journeys( + conn, + %{ + "stop" => stop_id, + "date" => date, + "is_current" => is_current, + "id" => _id, + "direction" => _direction + } = params + ) do {:ok, user_selected_date} = Date.from_iso8601(date) {schedules, predictions} = load_from_repos(conn, params) @@ -52,7 +61,7 @@ defmodule DotcomWeb.ScheduleController.FinderApi do # matching the design spec architecturally better than the existing # Schedules-only and Predictions-only configuration for # ScheduleFinder. - today? = params["is_current"] == "true" + today? = is_current == "true" current_time = if today?, do: user_selected_date, else: nil journey_list_opts = [ @@ -68,6 +77,10 @@ defmodule DotcomWeb.ScheduleController.FinderApi do json(conn, journeys) end + def journeys(conn, _) do + return_invalid_arguments_error(conn) + end + # Use alternative JourneyList constructor to only return trips with predictions @spec departures(Plug.Conn.t(), map) :: Plug.Conn.t() def departures(conn, %{"stop" => stop_id} = params) do @@ -87,7 +100,7 @@ defmodule DotcomWeb.ScheduleController.FinderApi do end def departures(conn, _) do - ControllerHelpers.return_invalid_arguments_error(conn) + return_invalid_arguments_error(conn) end @spec get_trip_info(Plug.Conn.t(), Trip.id_t(), Route.t(), String.t(), String.t(), String.t()) :: @@ -171,7 +184,7 @@ defmodule DotcomWeb.ScheduleController.FinderApi do end def trip(conn, _) do - ControllerHelpers.return_invalid_arguments_error(conn) + return_invalid_arguments_error(conn) end # Use internal API to generate list of relevant schedules and predictions