Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions ba.code-workspace

This file was deleted.

5 changes: 4 additions & 1 deletion blocket_api/blocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def search_car(
milage_to: int | None = None,
colors: list[CarColor] = [],
transmissions: list[CarTransmission] = [],
horsepower_from: int | None = None,
horsepower_to: int | None = None,
org_id: int | None = None,
) -> dict[str, Any]:
url = f"{SITE_URL}/mobility/search/api/search/SEARCH_ID_CAR_USED"
Expand All @@ -102,12 +104,13 @@ def search_car(
"year_to": year_to,
"milage_from": milage_from,
"milage_to": milage_to,
"engine_effect_from": horsepower_from,
"engine_effect_to": horsepower_to,
"orgId": org_id,
}

params = [QueryParam(k, v) for k, v in param_dict.items() if v is not None]

# Multi-value params
params.extend(QueryParam("location", loc.value) for loc in locations)
params.extend(QueryParam("make", model.value) for model in models)
params.extend(QueryParam("exterior_colour", color.value) for color in colors)
Expand Down
6 changes: 5 additions & 1 deletion tests/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def test_search_car(self) -> None:
"&price_from=1000"
"&price_to=50000"
"&transmission=2"
"&engine_effect_from=200"
"&engine_effect_to=300"
"&orgId=1337"
)
respx.get(expected_url).mock(
Expand All @@ -134,6 +136,8 @@ def test_search_car(self) -> None:
price_from=1000,
price_to=50000,
transmissions=[CarTransmission.AUTOMATIC],
horsepower_from=200,
horsepower_to=300,
org_id=1337,
)
assert result == {"status": "ok"}
Expand Down Expand Up @@ -303,7 +307,7 @@ def test_get_mc_ad(self) -> None:
<div class="flex gap-16 hyphens-auto">
<span class="s-text-subtle">Motorvolym</span>
<p class="m-0 font-bold">150 cc</p>
</div>
</div>
</div>

<div class="border-t pt-40 mt-40">
Expand Down
Loading