//native
type Zoho = {
token: string;
};
/**
* Email a quote
* Email a quote to the customer. Input json string is not mandatory. If input json string is empty, mail will be send with default mail content.
*/
export async function main(
auth: Zoho,
estimate_id: string,
attachments: string | undefined,
X_com_zoho_subscriptions_organizationid: string,
body: {
send_from_org_email_id?: false | true;
to_mail_ids: string[];
cc_mail_ids?: string[];
subject?: string;
body?: string;
},
) {
const url = new URL(
`https://www.zohoapis.com/billing/v1/estimates/${estimate_id}/email`,
);
for (const [k, v] of [["attachments", attachments]]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
headers: {
"X-com-zoho-subscriptions-organizationid":
X_com_zoho_subscriptions_organizationid,
"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