using IdokladSdk.Models.Email;
using Microsoft.AspNetCore.Mvc;
using Idoklad.Services;
namespace Idoklad.Controllers;
///
/// Sends document e-mails through iDoklad. The request body carries the settings: the document id
/// (DocumentId), recipients (OtherRecipients, SendToPartner, SendToSelf,
/// SendToAccountant), optional subject/body and report language. Requires iDoklad credentials
/// (headers or environment defaults).
///
[ApiController]
[Route("mail")]
[Produces("application/json")]
[Tags("Mail")]
public sealed class MailController : ControllerBase
{
private readonly MailService _service;
public MailController(MailService service) => _service = service;
/// Send an issued invoice by e-mail.
[HttpPost("issued-invoices/send")]
public async Task SendIssuedInvoice([FromBody] IssuedInvoiceEmailSettings settings, CancellationToken ct)
=> Ok(await _service.SendIssuedInvoiceAsync(settings, ct));
/// Send a proforma (advance) invoice by e-mail.
[HttpPost("proforma-invoices/send")]
public async Task SendProformaInvoice([FromBody] ProformaInvoiceEmailSettings settings, CancellationToken ct)
=> Ok(await _service.SendProformaInvoiceAsync(settings, ct));
/// Send a credit note by e-mail.
[HttpPost("credit-notes/send")]
public async Task SendCreditNote([FromBody] CreditNoteEmailSettings settings, CancellationToken ct)
=> Ok(await _service.SendCreditNoteAsync(settings, ct));
/// Send a received invoice by e-mail.
[HttpPost("received-invoices/send")]
public async Task SendReceivedInvoice([FromBody] ReceivedInvoiceEmailSettings settings, CancellationToken ct)
=> Ok(await _service.SendReceivedInvoiceAsync(settings, ct));
/// Send payment reminders by e-mail.
[HttpPost("reminders/send")]
public async Task SendReminders([FromBody] RemindersEmailSettings settings, CancellationToken ct)
=> Ok(await _service.SendRemindersAsync(settings, ct));
}