import * as Logger from "bunyan";
import { IRecipientResolver } from "../core/recipients";
import { INotification, NotificationRecipients, INotificationDispatchResult, INotificationHandler, INotificationTransport } from "../core/core";
import { NotificationDispatchHandler } from "../core/dispatchHandler";
import { MailService } from '@sendgrid/mail';
import { MailData } from "@sendgrid/helpers/classes/mail";
import { EmailData } from "@sendgrid/helpers/classes/email-address";
declare module "@sendgrid/helpers/classes/mail" {
    interface MailData {
        dynamicTemplateData?: any;
    }
}
declare module "../core/core" {
    interface INotificationRecipient {
        sendgrid?: string | string[];
        email?: string | string[];
    }
}
export declare class SendgridNotificationDispatchHandler extends NotificationDispatchHandler<ISendgridNotificationTransport> {
    constructor(logger: Logger, transport: ISendgridNotificationTransport);
}
export declare function sendgridInitializer(logger: Logger, config: ISendgridOptions, recipientResolver?: IRecipientResolver): Promise<SendgridNotificationDispatchHandler>;
export interface ISendgridNotification extends INotification {
    fromAddress?: string;
}
export interface ISendgridNotificationHandler<T extends ISendgridNotification> extends INotificationHandler<T> {
    sendgrid(notification: T, transport: ISendgridNotificationTransport): Promise<any>;
}
export interface ISendgridNotificationTransport extends INotificationTransport<typeof MailService> {
    send(recipients: NotificationRecipients, from: EmailData, builder: (message: MailData) => void): Promise<INotificationDispatchResult>;
    getFromAddress(notification: ISendgridNotification): string;
}
export declare class SendgridTransporter {
    private logger;
    private nodemailerConfig;
    constructor(logger: Logger, nodemailerConfig: ISendgridOptions);
    getTransporter(): Promise<typeof MailService>;
    private validate;
    private createSendgridTransport;
    private createTransport;
}
export interface ISendgridOptions {
    apiKey: string;
    defaultFromAddress: string;
    substitutionWrappers?: [string, string];
}
export declare class SendgridNotificationTransport implements ISendgridNotificationTransport {
    private logger;
    native: typeof MailService;
    private recipientResolver;
    private defaultFromAddress;
    static create(logger: Logger, transporter: SendgridTransporter, recipientResolver: IRecipientResolver, defaultFromAddress: string): Promise<ISendgridNotificationTransport>;
    constructor(logger: Logger, native: typeof MailService, recipientResolver: IRecipientResolver, defaultFromAddress: string);
    getFromAddress(notification: ISendgridNotification): string;
    shutdown(): void;
    resolveTokens(recipients: NotificationRecipients): Promise<string[]>;
    send(recipients: NotificationRecipients, from: EmailData, builder: (message: MailData) => void): Promise<INotificationDispatchResult>;
    sendMessage(mail: MailData): Promise<INotificationDispatchResult>;
}
