OnlyBiggg commited on
Commit
5543c4b
·
1 Parent(s): e22b5ab
app/dialogflow/services/dialog_service.py CHANGED
@@ -78,11 +78,13 @@ class DialogService:
78
  @staticmethod
79
  async def seats_trip(route_id: int, trip_id:int, departure_date: str, departure_time: str, kind: str):
80
  try:
81
- params = {
82
- "departureDate": departure_date,
83
- "departureTime": departure_time,
84
- "kind": kind,
85
- }
 
 
86
  response = await api.get(api_base=settings.API_BASE_URL_VATO, endpoint=f"/seats/{route_id}/{trip_id}" , params=params)
87
  seats = response["data"]
88
  return seats
@@ -199,9 +201,11 @@ class DialogService:
199
  @staticmethod
200
  async def stops(route_id: int, way_id: int):
201
  try:
202
- params = {
203
- "wayId": way_id,
204
- }
 
 
205
  response = await api.get(api_base=settings.API_BASE_URL_VATO, endpoint=f"/stops/{route_id}", params=params)
206
  data = response["data"]
207
  return data
 
78
  @staticmethod
79
  async def seats_trip(route_id: int, trip_id:int, departure_date: str, departure_time: str, kind: str):
80
  try:
81
+ params ={k: v for k, v in {
82
+ "departureDate": departure_date,
83
+ "departureTime": departure_time,
84
+ "kind": kind
85
+ }.items() if v is not None}
86
+ if params is None:
87
+ return []
88
  response = await api.get(api_base=settings.API_BASE_URL_VATO, endpoint=f"/seats/{route_id}/{trip_id}" , params=params)
89
  seats = response["data"]
90
  return seats
 
201
  @staticmethod
202
  async def stops(route_id: int, way_id: int):
203
  try:
204
+ if route_id is None or way_id is None:
205
+ return []
206
+ params ={ k: v for k,v in {
207
+ "wayId": way_id,
208
+ }.items() if v is not None}
209
  response = await api.get(api_base=settings.API_BASE_URL_VATO, endpoint=f"/stops/{route_id}", params=params)
210
  data = response["data"]
211
  return data