//native
type Zoho = {
token: string;
};
/**
* Update role
*
*/
export async function main(
auth: Zoho,
role_id: string,
body: {
roles: {
display_label: string;
forecast_manager: { id: string; name: string };
reporting_to: { id: string; name: string };
share_with_peers: false | true;
description: string;
id: string;
name: string;
created_by__s: { name: string; id: string; email?: string };
modified_by__s: { name: string; id: string; email?: string };
modified_time__s: string;
created_time__s: string;
admin_user?: false | true;
}[];
},
) {
const url = new URL(`https://zohoapis.com/crm/v8/settings/roles/${role_id}`);
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