33 lines
952 B
C#
33 lines
952 B
C#
|
|
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; }
|
||
|
|
}
|