//native
type Zoho = {
token: string;
};
/**
* Update email draft
*
*/
export async function main(
auth: Zoho,
_module: string,
record: string,
draft: string,
body: {
__email_drafts: {
id: string;
modified_time: string;
created_time: string;
from: string;
to: { user_name: string; email: string }[];
reply_to: string;
cc: { user_name: string; email: string }[];
bcc: { user_name: string; email: string }[];
template: { id: string; name: string };
inventory_details: {
inventory_template: { name: string; id: string };
record: {
id?: string;
Created_By?: { name: string; id: string; email?: string };
Created_Time?: string;
Modified_By?: { name: string; id: string; email?: string };
Modified_Time?: string;
Tag?: {
name: string;
color_code:
| "#57B1FD"
| "#879BFC"
| "#658BA8"
| "#FD87BD"
| "#969696"
| "#F48435"
| "#1DB9B4"
| "#E7A826"
| "#63C57E"
| "#F17574"
| "#D297EE"
| "#A8C026"
| "#B88562";
created_time: string;
modified_time: string;
modified_by: { name: string; id: string; email?: string };
created_by: { name: string; id: string; email?: string };
id: string;
}[];
name?: string;
};
paper_type: string;
view_type: string;
};
attachments: { service_name: string; file_size: string }[];
schedule_details: { time: string };
rich_text: false | true;
email_opt_out: false | true;
subject: string;
content: string;
summary: string;
}[];
},
) {
const url = new URL(
`https://zohoapis.com/crm/v8/${_module}/${record}/__email_drafts/${draft}`,
);
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