//native
type Zoho = {
token: string;
};
/**
* Update notifications
*
*/
export async function main(
auth: Zoho,
body: {
watch?: {
channel_id: string;
notify_url: string;
events: string[];
token?: string;
fields?: {};
notify_on_related_action?: false | true;
return_affected_field_values?: false | true;
_delete_events?: true;
resource_name?: string;
channel_expiry?: string;
resource_id?: string;
resource_uri?: string;
notification_condition?: {
type?: string;
module: { api_name?: string; id?: string };
field_selection: {
comparator: string;
field: { api_name: string; id: string };
value: {};
group_operator: string;
group: {}[];
};
}[];
}[];
},
) {
const url = new URL(`https://zohoapis.com/crm/v8/actions/watch`);
const response = await fetch(url, {
method: "PUT",
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