|
14 | 14 | household_service = HouseholdService() |
15 | 15 |
|
16 | 16 |
|
17 | | -@household_bp.route("/<country_id>/household/<household_id>", methods=["GET"]) |
| 17 | +@household_bp.route("/<country_id>/household/<int:household_id>", methods=["GET"]) |
18 | 18 | @validate_country |
19 | | -def get_household(country_id: str, household_id: str) -> Response: |
| 19 | +def get_household(country_id: str, household_id: int) -> Response: |
20 | 20 | """ |
21 | 21 | Get a household's input data with a given ID. |
22 | 22 |
|
23 | 23 | Args: |
24 | 24 | country_id (str): The country ID. |
25 | | - household_id (str): The household ID. |
| 25 | + household_id (int): The household ID. |
26 | 26 | """ |
27 | 27 | print(f"Got request for household {household_id} in country {country_id}") |
28 | 28 |
|
29 | | - # Ensure that household ID is a number |
30 | | - try: |
31 | | - household_id = int(household_id) |
32 | | - except ValueError: |
33 | | - return Response( |
34 | | - status=400, |
35 | | - response=f"Invalid household ID; household ID must be a number", |
36 | | - ) |
37 | | - |
38 | 29 | try: |
39 | 30 | household: dict | None = household_service.get_household( |
40 | 31 | country_id, household_id |
@@ -128,15 +119,15 @@ def post_household(country_id: str) -> Response: |
128 | 119 | ) |
129 | 120 |
|
130 | 121 |
|
131 | | -@household_bp.route("/<country_id>/household/<household_id>", methods=["PUT"]) |
| 122 | +@household_bp.route("/<country_id>/household/<int:household_id>", methods=["PUT"]) |
132 | 123 | @validate_country |
133 | | -def update_household(country_id: str, household_id: str) -> Response: |
| 124 | +def update_household(country_id: str, household_id: int) -> Response: |
134 | 125 | """ |
135 | 126 | Update a household's input data. |
136 | 127 |
|
137 | 128 | Args: |
138 | 129 | country_id (str): The country ID. |
139 | | - household_id (str): The household ID. |
| 130 | + household_id (int): The household ID. |
140 | 131 | """ |
141 | 132 |
|
142 | 133 | # Validate payload |
|
0 commit comments