//native
type Zoho = {
token: string;
};
/**
* Create zia people enrichment
*
*/
export async function main(
auth: Zoho,
_module: string | undefined,
record_id: string | undefined,
body: {
__zia_people_enrichment: {
created_time: string;
id: string;
created_by: { name: string; id: string };
status: string;
enriched_data: {
website?: string;
email_infos?: { type: string; email: string }[];
gender?: string;
company_info?: {
name: string;
industries: { name?: string; description?: string }[];
experiences: {
end_date: string;
company_name: string;
title: string;
start_date: string;
primary: false | true;
}[];
};
last_name?: string;
educations?: {}[];
middle_name?: string;
skills?: {}[];
other_contacts?: string[];
address_list_info?: {
continent: string;
country: string;
name: string;
region: string;
primary: false | true;
}[];
primary_address_info?: {
continent: string;
country: string;
name: string;
region: string;
primary: false | true;
};
name?: string;
secondary_contact?: string;
primary_email?: string;
designation?: string;
id?: string;
interests?: {}[];
first_name?: string;
primary_contact?: string;
social_media?: { media_type: string; media_url: string[] }[];
};
enrich_based_on: {
social?: { twitter?: string; facebook?: string; linkedin?: string };
name?: string;
company?: { website?: string; name?: string };
email: string;
};
}[];
},
) {
const url = new URL(`https://zohoapis.com/crm/v8/__zia_people_enrichment`);
for (const [k, v] of [
["module", _module],
["record_id", record_id],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Zoho-oauthtoken " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago