//native
type Zoho = {
token: string;
};
/**
* Record count
*
*/
export async function main(
auth: Zoho,
module_api_name: string,
cvid: string | undefined,
criteria: string | undefined,
email: string | undefined,
phone: string | undefined,
word: string | undefined,
) {
const url = new URL(
`https://zohoapis.com/crm/v8/${module_api_name}/actions/count`,
);
for (const [k, v] of [
["cvid", cvid],
["criteria", criteria],
["email", email],
["phone", phone],
["word", word],
]) {
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