type Apollo = {
apiKey: string;
};
export async function main(
resource: Apollo,
params: {
search: string;
accountStageId?: string[];
sortByField?: "account_last_activity_date" | "account_created_at";
sortAscending?: boolean;
}
) {
const endpoint = "https://api.apollo.io/v1/accounts/search";
const body = {
q_organization_name: params.search,
account_stage_ids: params.accountStageId,
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.accounts;
}
Submitted by hugo697 118 days ago
type Apollo_io = {
apiKey: string
}
export async function main(
resource: Apollo_io,
params: {
search: string
accountStageId?: string[]
sortByField?: 'account_last_activity_date' | 'account_created_at'
sortAscending?: boolean
}
) {
const endpoint = 'https://api.apollo.io/v1/accounts/search'
const body = {
q_organization_name: params.search,
account_stage_ids: params.accountStageId,
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.accounts
}
Submitted by hugo697 118 days ago