//native
type Zoho = {
token: string;
};
/**
* Create territories
*
*/
export async function main(
auth: Zoho,
body: {
territories?: {
created_time: string;
modified_time: string;
manager: { name: string; id: string };
reporting_to: { name: string; id: string };
permission_type: "read_write_delete" | "read_only";
modified_by: { name: string; id: string; email?: string };
description: string;
id: string;
created_by: { name: string; id: string; email?: string };
account_rule_criteria: {
comparator: string;
field: { api_name: string; id: string };
value: {};
group_operator: string;
group: {}[];
};
deal_rule_criteria: {
comparator: string;
field: { api_name: string; id: string };
value: {};
group_operator: string;
group: {}[];
};
lead_rule_criteria?: {
comparator: string;
field: { api_name: string; id: string };
value: {};
group_operator: string;
group: {}[];
};
name: string;
api_name: string;
}[];
},
) {
const url = new URL(`https://zohoapis.com/crm/v8/settings/territories`);
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