using System; using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using MisIngredientesVue.Core.Extensions; using MisIngredientesVue.Core.Models; using MisIngredientesVue.Core.Services; namespace MisIngredientesVue.Controllers { [Route("api/[controller]")] [ApiController] public class WebHooksController : Controller { private readonly IWebHookService _webHookService; public WebHooksController(IWebHookService webHookService) { _webHookService = webHookService; } [HttpGet] public async Task GetWebhooks() { return Ok(await _webHookService.GetWebhooks(User.Identity.GetTenantId())); } [HttpPost] public async Task AddWebhook([FromBody] AddWebhookRequest request) { if (request == null) return BadRequest(); await _webHookService.AddWebHooks(User.Identity.GetTenantId(), request.Url, request.Events); return Ok(); } } public class AddWebhookRequest { public string Url { get; set; } public string[] Events { get; set; } } }