@levo-so/client
Version:
<img alt="Levo" src="https://static.levocdn.com/png/Levo-Logo.png" width="50" height="50">
61 lines (60 loc) • 7.77 kB
TypeScript
import type { Client } from './client';
import type { NotificationType } from './types';
import type { LevoResponse } from './types/types';
export declare class Notification {
private client;
constructor(client: Client);
/**
* Send a custom email, or a template email, to the specified recipients.
*
* @example
*
* const isSuccess = await levo.notification.sendEmail({
* to: ['example@example.com'],
* subject: 'Hello World',
* content: 'Hello World',
* });
*
* console.log(isSuccess); // Outputs true if the email was sent successfully
*
* @example
*
* const isSuccess = await levo.notification.sendEmail({
* to: ['example@example.com'],
* from_name: 'Demo Foundation',
* subject: 'Hello World',
* content: '<html lang=\"en\"><head><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><title>Demo Email Template</title><style media=\"all\" type=\"text/css\">@media all{.btn-primary table td:hover{background-color:#ec0867}.btn-primary a:hover{background-color:#ec0867;border-color:#ec0867}}@media only screen and (max-width:640px){.main p,.main span,.main td{font-size:16px}.wrapper{padding:8px}.content{padding:0}.container{padding:0;padding-top:8px;width:100%}.main{border-left-width:0;border-radius:0;border-right-width:0}.btn table{max-width:100%;width:100%}.btn a{font-size:16px;max-width:100%;width:100%}}@media all{.ExternalClass{width:100%}.ExternalClass,.ExternalClass div,.ExternalClass font,.ExternalClass p,.ExternalClass span,.ExternalClass td{line-height:100%}.apple-link a{color:inherit;font-family:inherit;font-size:inherit;font-weight:inherit;line-height:inherit;text-decoration:none}#MessageViewBody a{color:inherit;text-decoration:none;font-size:inherit;font-family:inherit;font-weight:inherit;line-height:inherit}}</style></head><body style=\"font-family:Helvetica,sans-serif;-webkit-font-smoothing:antialiased;font-size:16px;line-height:1.3;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;background-color:#f4f5f6;margin:0;padding:0\"><table role=\"presentation\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"body\" style=\"border-collapse:separate;mso-table-lspace:0;mso-table-rspace:0;background-color:#f4f5f6;width:100%\" width=\"100%\" bgcolor=\"#f4f5f6\"><tr><td style=\"font-family:Helvetica,sans-serif;font-size:16px;vertical-align:top\" valign=\"top\"> </td><td class=\"container\" style=\"font-family:Helvetica,sans-serif;font-size:16px;vertical-align:top;max-width:600px;padding:0;padding-top:24px;width:600px;margin:0 auto\" width=\"600\" valign=\"top\"><div class=\"content\" style=\"box-sizing:border-box;display:block;margin:0 auto;max-width:600px;padding:0\"><span class=\"preheader\" style=\"color:transparent;display:none;height:0;max-height:0;max-width:0;opacity:0;overflow:hidden;mso-hide:all;visibility:hidden;width:0\">Welcome to our demo email template!</span><table role=\"presentation\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"main\" style=\"border-collapse:separate;mso-table-lspace:0;mso-table-rspace:0;background:#fff;border:1px solid #eaebed;border-radius:16px;width:100%\" width=\"100%\"><tr><td class=\"wrapper\" style=\"font-family:Helvetica,sans-serif;font-size:16px;vertical-align:top;box-sizing:border-box;padding:24px\" valign=\"top\"><p style=\"font-family:Helvetica,sans-serif;font-size:16px;font-weight:400;margin:0;margin-bottom:16px\">Hello!</p><p style=\"font-family:Helvetica,sans-serif;font-size:16px;font-weight:400;margin:0;margin-bottom:16px\">We’re pleased to connect with you. We hope you find the information valuable.</p><table role=\"presentation\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"btn btn-primary\" style=\"border-collapse:separate;mso-table-lspace:0;mso-table-rspace:0;box-sizing:border-box;width:100%;min-width:100%\" width=\"100%\"><tbody><tr><td align=\"left\" style=\"font-family:Helvetica,sans-serif;font-size:16px;vertical-align:top;padding-bottom:16px\" valign=\"top\"><table role=\"presentation\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse:separate;mso-table-lspace:0;mso-table-rspace:0;width:auto\"><tbody><tr><td style=\"font-family:Helvetica,sans-serif;font-size:16px;vertical-align:top;border-radius:4px;text-align:center;background-color:#0867ec\" valign=\"top\" align=\"center\" bgcolor=\"#0867ec\"><a href=\"http://htmlemail.io\" target=\"_blank\" style=\"border:solid 2px #0867ec;border-radius:4px;box-sizing:border-box;cursor:pointer;display:inline-block;font-size:16px;font-weight:700;margin:0;padding:12px 24px;text-decoration:none;text-transform:capitalize;background-color:#0867ec;border-color:#0867ec;color:#fff\">Learn More</a></td></tr></tbody></table></td></tr></tbody></table><p style=\"font-family:Helvetica,sans-serif;font-size:16px;font-weight:400;margin:0;margin-bottom:16px\">Our goal is to provide clarity and engagement, ensuring your experience is meaningful.</p><p style=\"font-family:Helvetica,sans-serif;font-size:16px;font-weight:400;margin:0;margin-bottom:16px\">Thank you for your interest! We appreciate your support.</p></td></tr></table><div class=\"footer\" style=\"clear:both;padding-top:24px;text-align:center;width:100%\"><table role=\"presentation\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse:separate;mso-table-lspace:0;mso-table-rspace:0;width:100%\" width=\"100%\"><tr><td class=\"content-block\" style=\"font-family:Helvetica,sans-serif;vertical-align:top;color:#9a9ea6;font-size:16px;text-align:center\" valign=\"top\" align=\"center\"><span class=\"apple-link\" style=\"color:#9a9ea6;font-size:16px;text-align:center\">Doe and Company, 123 Business Rd, Suite 100, Anytown, USA</span><br>Prefer not to receive these emails?<a href=\"http://htmlemail.io/blog\" style=\"text-decoration:underline;color:#9a9ea6;font-size:16px;text-align:center\">Unsubscribe</a>.</td></tr></table></div></div></td><td style=\"font-family:Helvetica,sans-serif;font-size:16px;vertical-align:top\" valign=\"top\"> </td></tr></table></body></html>',
* cc: ['john.doe@example.com'],
* bcc: ['jane.doe@example.com'],
* reply_to: 'support@example.com'
* });
*
* console.log(isSuccess); // Outputs true if the email was sent successfully
*
* @example
*
* const isSuccess = await levo.notification.sendEmail({
* key: 'richtext',
* to: ['example@example.com'],
* from_name: 'Demo Foundation',
* subject: 'Hello World',
* content: '<p>This will go in a special richtext email template</p>',
* cc: ['john.doe@example.com'],
* bcc: ['jane.doe@example.com'],
* reply_to: 'support@example.com'
* });
*
* console.log(isSuccess); // Outputs true if the email was sent successfully
*
* @param {SendEmailInput} data - The data to send the email.
* @returns {Promise<boolean>} A promise that resolves to a boolean indicating whether the email was sent successfully.
* @throws {LevoError.Platform} If the email is invalid.
* @throws {LevoError.Platform} If the subject or content is not given.
* @throws {LevoError.Platform} If the workspace is not found.
*/
sendEmail(data: NotificationType.SendEmailInput): Promise<LevoResponse.Data<boolean, {
items?: number;
total: number;
pages: number;
}>>;
}