diff --git a/lib/open_trip_planner_client/plan_params.ex b/lib/open_trip_planner_client/plan_params.ex index 709f6dd..9110068 100644 --- a/lib/open_trip_planner_client/plan_params.ex +++ b/lib/open_trip_planner_client/plan_params.ex @@ -13,6 +13,7 @@ defmodule OpenTripPlannerClient.PlanParams do :date, :time, arriveBy: false, + numItineraries: 5, transportModes: [%{mode: :WALK}, %{mode: :TRANSIT}], wheelchair: false ] @@ -101,6 +102,7 @@ defmodule OpenTripPlannerClient.PlanParams do arriveBy: arrive_by(), fromPlace: place(), date: date(), + numItineraries: integer(), time: time(), toPlace: place(), transportModes: transport_modes(), diff --git a/priv/plan.graphql b/priv/plan.graphql index f8c4ba7..a69d3eb 100644 --- a/priv/plan.graphql +++ b/priv/plan.graphql @@ -6,6 +6,7 @@ query TripPlan( $arriveBy: Boolean $wheelchair: Boolean $transportModes: [TransportMode] + $numItineraries: Int ) { plan( fromPlace: $fromPlace @@ -20,7 +21,7 @@ query TripPlan( searchWindow: 7200 # Increased from 3 to offer more itineraries for potential post-processing - numItineraries: 5 + numItineraries: $numItineraries # Increased from 2.0 to reduce number of itineraries with significant walking walkReluctance: 5.0 diff --git a/test/open_trip_planner_client/plan_params_test.exs b/test/open_trip_planner_client/plan_params_test.exs index 57185da..45356ee 100644 --- a/test/open_trip_planner_client/plan_params_test.exs +++ b/test/open_trip_planner_client/plan_params_test.exs @@ -18,6 +18,18 @@ defmodule OpenTripPlannerClient.PlanParamsTest do assert to_time_param(now) == time end + test "new/1 defaults to having 5 itineraries" do + assert %OpenTripPlannerClient.PlanParams{ + numItineraries: 5 + } = new() + end + + test "new/1 allows a customizable number of itineraries" do + assert %OpenTripPlannerClient.PlanParams{ + numItineraries: 42 + } = new(%{numItineraries: 42}) + end + test "to_place_param/1 with stop" do name = Faker.App.name() stop_id = Faker.Internet.slug()