fix(tools): remove invalid searchText field from Lusha prospecting filters
Lusha API rejects filters.companies.include.searchText (HTTP 400). Replaced with valid 'names' field in search_companies and removed redundant company searchText from search_people. Updated unit tests.
This commit is contained in:
@@ -131,8 +131,6 @@ class _LushaClient:
|
||||
company_include: dict[str, Any] = {}
|
||||
if company_name:
|
||||
company_include["names"] = [company_name]
|
||||
if industry:
|
||||
company_include["searchText"] = industry
|
||||
|
||||
filters: dict[str, Any] = {"contacts": {"include": contact_include}}
|
||||
if company_include:
|
||||
@@ -156,15 +154,19 @@ class _LushaClient:
|
||||
if len(parts) == 2 and parts[0].isdigit() and parts[1].isdigit():
|
||||
size_range = [{"min": int(parts[0]), "max": int(parts[1])}]
|
||||
|
||||
company_include: dict[str, Any] = {
|
||||
"locations": [{"country": location}],
|
||||
}
|
||||
if size_range:
|
||||
company_include["sizes"] = size_range
|
||||
if industry:
|
||||
company_include["names"] = [industry]
|
||||
|
||||
body: dict[str, Any] = {
|
||||
"pages": {"size": 25, "page": 0},
|
||||
"filters": {
|
||||
"companies": {
|
||||
"include": {
|
||||
"searchText": industry,
|
||||
"sizes": size_range,
|
||||
"locations": [{"country": location}],
|
||||
}
|
||||
"include": company_include,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ class TestLushaClient:
|
||||
assert body["filters"]["contacts"]["include"]["searchText"] == "VP Sales vp software"
|
||||
assert body["filters"]["contacts"]["include"]["locations"] == [{"country": "New York"}]
|
||||
assert body["filters"]["contacts"]["include"]["departments"] == ["sales"]
|
||||
assert body["filters"]["companies"]["include"]["searchText"] == "software"
|
||||
assert "searchText" not in body["filters"]["companies"]["include"]
|
||||
assert body["filters"]["companies"]["include"]["names"] == ["Acme"]
|
||||
assert mock_request.call_args.args[1] == f"{LUSHA_API_BASE}/prospecting/contact/search"
|
||||
|
||||
@@ -134,7 +134,8 @@ class TestLushaClient:
|
||||
assert result["companies"][0]["id"] == "co1"
|
||||
body = mock_request.call_args.kwargs["json"]
|
||||
assert body["pages"] == {"size": 25, "page": 0}
|
||||
assert body["filters"]["companies"]["include"]["searchText"] == "software"
|
||||
assert "searchText" not in body["filters"]["companies"]["include"]
|
||||
assert body["filters"]["companies"]["include"]["names"] == ["software"]
|
||||
assert body["filters"]["companies"]["include"]["sizes"] == [{"min": 51, "max": 200}]
|
||||
assert body["filters"]["companies"]["include"]["locations"] == [
|
||||
{"country": "United States"}
|
||||
|
||||
Reference in New Issue
Block a user