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
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
package integrations.telex.salesagent.lead.dto;

import integrations.telex.salesagent.lead.service.LocationMappingService;
import lombok.Data;
import lombok.RequiredArgsConstructor;

@Data
@RequiredArgsConstructor
public class PeopleSearchRequest {
private String keyword;
private String location;

private transient LocationMappingService locationMappingService;

public String buildLinkedInSearchUrl() {
StringBuilder urlBuilder = new StringBuilder("https://www.linkedin.com/search/results/people/?");

if (location != null && !location.isEmpty()) {
String geoUrn = locationMappingService.getGeoUrnForLocation(location);
if (geoUrn != null) {
urlBuilder.append("geoUrn=%5B%22").append(geoUrn).append("%22%5D&");
} else {
// Handle case where location is not found in the mapping
System.out.println("Location not found in mapping: " + location);
}
}

urlBuilder.append("origin=FACETED_SEARCH");
return urlBuilder.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ public class LeadPeopleResearchService {
private final RestTemplate restTemplate;
private final ObjectMapper objectMapper;
private final TelexClient telexClient;
private final LocationMappingService locationMappingService;

public List<PeopleLeadDto> queryLeads(String channelID, PeopleSearchRequest request) {
try {
// Build URL with location filter
String searchUrl = request.buildLinkedInSearchUrl();
String searchUrl = buildLinkedInSearchUrl(request);
log.info("Constructed LinkedIn search URL: {}", searchUrl);

// Make API call
Expand Down Expand Up @@ -133,4 +134,18 @@ private List<PeopleLeadDto> formatPeopleResponse(String responseBody) {
}
return leads;
}

private String buildLinkedInSearchUrl(PeopleSearchRequest request) {
StringBuilder urlBuilder = new StringBuilder("https://www.linkedin.com/search/results/people/?");

if (request.getLocation() != null && !request.getLocation().isEmpty()) {
String geoUrn = locationMappingService.getGeoUrnForLocation(request.getLocation());
if (geoUrn != null) {
urlBuilder.append("geoUrn=%5B%22").append(geoUrn).append("%22%5D&");
}
}

urlBuilder.append("origin=FACETED_SEARCH");
return urlBuilder.toString();
}
}
Loading