dolibarr-bff/DoliMiddlewareApi/Controllers/SettingsController.cs

33 lines
952 B
C#
Raw Normal View History

2026-05-16 22:01:26 +00:00
using DoliMiddlewareApi.Services.Notifications;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace DoliMiddlewareApi.Controllers;
[ApiController]
[Route("api/[controller]")]
[Authorize]
public class SettingsController(WebhookSettings webhookSettings) : ControllerBase
{
[HttpGet("webhook")]
[ProducesResponseType(typeof(object), StatusCodes.Status200OK)]
public IActionResult GetWebhook()
{
return Ok(new { url = webhookSettings.WebhookUrl });
}
[HttpPut("webhook")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
public IActionResult SetWebhook([FromBody] SetWebhookDto dto)
{
webhookSettings.WebhookUrl = string.IsNullOrWhiteSpace(dto.Url) ? null : dto.Url.Trim();
return NoContent();
}
}
public class SetWebhookDto
{
public string? Url { get; set; }
}