//native
type Zoho = {
token: string;
};
/**
* Update profile
*
*/
export async function main(
auth: Zoho,
id: string,
body: {
profiles: {
_default_view?: { name?: string; id?: string; type?: string };
name: string;
description: string;
id: string;
default?: false | true;
_delete?: false | true;
permission_type?: string;
custom?: false | true;
display_label: string;
type?: "normal_profile" | "lite_profile";
permissions_details: {
id: string;
enabled: false | true;
name: string;
display_label: string;
customizable?: false | true;
parent_permissions?: string[];
module: string;
}[];
sections: {
name: string;
categories:
| {
display_label: string;
permissions_details: string[];
name: string;
}
| {
display_label: string;
permissions_details: string[];
name: string;
module: string;
}[];
}[];
created_time: string;
modified_time: string;
modified_by: { name: string; id: string; email?: string };
category: false | true;
created_by: { name: string; id: string; email?: string };
}[];
},
) {
const url = new URL(`https://zohoapis.com/crm/v8/settings/profiles/${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