//native
type Zoho = {
token: string;
};
/**
* Get zia people enrichments
*
*/
export async function main(
auth: Zoho,
status: "COMPLETED" | "FAILED" | "DATA_NOT_FOUND" | "SCHEDULED" | undefined,
sort_order: string | undefined,
sort_by: string | undefined,
page: string | undefined,
per_page: string | undefined,
count: string | undefined,
) {
const url = new URL(`https://zohoapis.com/crm/v8/__zia_people_enrichment`);
for (const [k, v] of [
["status", status],
["sort_order", sort_order],
["sort_by", sort_by],
["page", page],
["per_page", per_page],
["count", count],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Zoho-oauthtoken " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago