import { TypedResponse } from '../../http';
import { DeepImmutable } from '../babylonjs-import';

/**
 * Format of a mail message.
 */
export interface MailMessage {
    /**
     * Recipient address for email.
     */
    recipientAddress: string;

    /**
     * Template id for email.
     */
    templateId: string;

    /**
     * Data to substitute into the email. This will vary depending on how the template
     * is defined.
     */
    data: Record<string, unknown>;
}

/**
 * Id of the sent message.
 */
export type MailMessageId = string;

/**
 * Provides methods to call the message API endpoints of the backend.
 */
export interface MessageApiClient {
    /**
     * Sends an email message. For security reasons it is not possible to specify a completely custom email. A valid
     * email template (specified by {@link MailMessage.templateId}) must be used and the data is substituted
     * into the template {@link MailMessage.data}. This will vary depending on the template. Templates must be configured
     * in the backend.
     * @param mailMessage Email message to send.
     * @returns MessageId of email.
     */
    sendMailMessage(mailMessage: DeepImmutable<MailMessage>): Promise<TypedResponse<MailMessageId>>;
}
