| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- namespace Diligent.WebAPI.Host.Controllers.V1
- {
- [ExcludeFromCodeCoverage]
- [ApiVersion("1.0")]
- [ApiController]
- [Route("v{version:apiVersion}/webhooks")]
- public class WebhooksController : ControllerBase
- {
- private readonly IWebhookSubscriptionService _webhookSubscriptionService;
- private readonly IWebhookDefinitionService _webhookDefinitionService;
-
- public WebhooksController(
- IWebhookSubscriptionService subscriptionService,
- IWebhookDefinitionService definitionsService)
- {
- _webhookSubscriptionService = subscriptionService;
- _webhookDefinitionService = definitionsService;
- }
-
- /// <summary>
- /// Create webhook subscription
- /// </summary>
- [HttpPost]
- [ProducesResponseType(StatusCodes.Status201Created)]
- [ProducesResponseType(typeof(ErrorResponseDto), StatusCodes.Status400BadRequest)]
- public async Task<IActionResult> Post([FromBody] WebhookSubscriptionCreateDto dto)
- {
- await _webhookSubscriptionService.CreateWebhookSubscription(dto);
- return StatusCode(StatusCodes.Status201Created);
- }
-
- /// <summary>
- /// Get all webhook definitions
- /// </summary>
- [HttpGet("definitions")]
- [ProducesResponseType(typeof(List<WebhookDefinitionViewDto>), StatusCodes.Status200OK)]
- [ProducesResponseType(typeof(ErrorResponseDto), StatusCodes.Status400BadRequest)]
- public async Task<IActionResult> GetDefinitions()
- {
- return Ok(await _webhookDefinitionService.GetAll());
- }
- }
- }
|