import axios from "axios";
import { INotificationsAdapter, NotificationDataEmail } from "./Notifications.Interface";

export class NotificationsDonWebAdapter implements INotificationsAdapter<NotificationDataEmail> {
    async send(data: NotificationDataEmail): Promise<void> {
        const dataEmail = {
            from: "norepply@turnosxpress.com.ar",
            to: data.email,
            subject: data.subject,
            html: data.message,
        };

        const apiConfig = {
            method: "post",
            maxBodyLength: Infinity,
            url: "https://api.envialosimple.email/api/v1/mail/send",
            headers: {
                Authorization: `Bearer ${process.env.DONWEB_MAIL_API_KEY}`,
                "Content-Type": "application/json",
            },
            data: dataEmail,
        };

        await axios(apiConfig);
    }
}
