rajsinghparihar commited on
Commit
617e1d9
·
1 Parent(s): cfae47b

final commit

Browse files
Files changed (2) hide show
  1. app.py +7 -7
  2. utils.py +1 -1
app.py CHANGED
@@ -56,10 +56,10 @@ def search_hotels(
56
  check_out_date: str,
57
  num_adults: str,
58
  currency: str,
59
- sort_by_id: Optional[str] = None,
60
  min_price: Optional[str] = None,
61
  max_price: Optional[str] = None,
62
- rating_id: Optional[str] = None,
63
  ):
64
  """
65
  Uses Google Hotels API via SerpAPI to search for hotels and returns property information.
@@ -70,10 +70,10 @@ def search_hotels(
70
  check_out_date (str): The check-out date in YYYY-MM-DD format.
71
  num_adults (str): Number of adult guests.
72
  currency (str): The currency code for prices.
73
- sort_by_id (Optional[str]): Parameter is used to sort results (Available options: "3" - Lowest price, "8" - Highest rating, "13" - Most reviewed)
74
  min_price (Optional[str]): Filter for price lower limit.
75
  max_price (Optional[str]): Filter for price upper limit.
76
- rating_id (Optional[str]): Parameter is used for filtering the results to certain rating. (Available options: "7" - 3.5+, "8" - 4.0+, "9" - 4.5+)
77
 
78
  Returns:
79
  dict: A dictionary containing hotel properties with their details including
@@ -86,10 +86,10 @@ def search_hotels(
86
  "check_out_date": check_out_date,
87
  "adults": num_adults,
88
  "currency": currency,
89
- "sort_by": sort_by_id,
90
  "min_price": min_price,
91
  "max_price": max_price,
92
- "rating": rating_id,
93
  "hl": "en",
94
  "api_key": os.getenv("SERP_API_KEY"),
95
  }
@@ -98,7 +98,7 @@ def search_hotels(
98
  result_dict = result.as_dict()
99
  hotel_results = {"properties": []}
100
  if "properties" in result_dict:
101
- hotel_results["properties"] = result_dict["properties"]
102
 
103
  return hotel_results
104
 
 
56
  check_out_date: str,
57
  num_adults: str,
58
  currency: str,
59
+ sort_by: Optional[str] = None,
60
  min_price: Optional[str] = None,
61
  max_price: Optional[str] = None,
62
+ rating: Optional[str] = None,
63
  ):
64
  """
65
  Uses Google Hotels API via SerpAPI to search for hotels and returns property information.
 
70
  check_out_date (str): The check-out date in YYYY-MM-DD format.
71
  num_adults (str): Number of adult guests.
72
  currency (str): The currency code for prices.
73
+ sort_by (Optional[str]): Parameter is used to sort results (Available options: "3" - Lowest price, "8" - Highest rating, "13" - Most reviewed)
74
  min_price (Optional[str]): Filter for price lower limit.
75
  max_price (Optional[str]): Filter for price upper limit.
76
+ rating (Optional[str]): Parameter is used for filtering the results to certain rating. (Available options: "7" - 3.5+, "8" - 4.0+, "9" - 4.5+)
77
 
78
  Returns:
79
  dict: A dictionary containing hotel properties with their details including
 
86
  "check_out_date": check_out_date,
87
  "adults": num_adults,
88
  "currency": currency,
89
+ "sort_by": sort_by,
90
  "min_price": min_price,
91
  "max_price": max_price,
92
+ "rating": rating,
93
  "hl": "en",
94
  "api_key": os.getenv("SERP_API_KEY"),
95
  }
 
98
  result_dict = result.as_dict()
99
  hotel_results = {"properties": []}
100
  if "properties" in result_dict:
101
+ hotel_results["properties"] = result_dict["properties"][:5]
102
 
103
  return hotel_results
104
 
utils.py CHANGED
@@ -1,5 +1,5 @@
1
  def _remove_null_params(params: dict):
2
- for p in params:
3
  if not params[p]:
4
  del params[p]
5
 
 
1
  def _remove_null_params(params: dict):
2
+ for p in list(params.keys()):
3
  if not params[p]:
4
  del params[p]
5