type Apollo = {
apiKey: string;
};
export async function main(
resource: Apollo,
params: {
search: string;
contactStageId?: string[];
sortByField?:
| "contact_last_activity_date"
| "contact_email_last_opened_at"
| "contact_email_last_clicked_at"
| "contact_created_at"
| "contact_updated_at";
sortAscending?: boolean;
}
) {
const endpoint = "https://api.apollo.io/v1/contacts/search";
const body = {
q_keywords: params.search,
contact_stage_ids: params.contactStageId,
sort_by_field: params.sortByField,
sort_ascending: params.sortAscending,
};
const response = await fetch(endpoint, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Cache-Control": "no-cache",
"X-Api-Key": resource.apiKey,
},
body: JSON.stringify(body),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
return data.contacts;
}
Submitted by hugo697 118 days ago
type Apollo_io = {
apiKey: string
}
export async function main(
resource: Apollo_io,
params: {
search: string
contactStageId?: string[]
sortByField?:
| 'contact_last_activity_date'
| 'contact_email_last_opened_at'
| 'contact_email_last_clicked_at'
| 'contact_created_at'
| 'contact_updated_at'
sortAscending?: boolean
}
) {
const endpoint = 'https://api.apollo.io/v1/contacts/search'
const body = {
q_keywords: params.search,
contact_stage_ids: params.contactStageId,
sort_by_field: params.sortByField,
sort_ascending: params.sortAscending
}
const response = await fetch(endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
'X-Api-Key': resource.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
}
const data = await response.json()
return data.contacts
}
Submitted by hugo697 118 days ago