Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

WebhooksController.cs 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. namespace Diligent.WebAPI.Host.Controllers.V1
  2. {
  3. [ExcludeFromCodeCoverage]
  4. [ApiVersion("1.0")]
  5. [ApiController]
  6. [Route("v{version:apiVersion}/webhooks")]
  7. public class WebhooksController : ControllerBase
  8. {
  9. private readonly IWebhookSubscriptionService _webhookSubscriptionService;
  10. private readonly IWebhookDefinitionService _webhookDefinitionService;
  11. public WebhooksController(
  12. IWebhookSubscriptionService subscriptionService,
  13. IWebhookDefinitionService definitionsService)
  14. {
  15. _webhookSubscriptionService = subscriptionService;
  16. _webhookDefinitionService = definitionsService;
  17. }
  18. /// <summary>
  19. /// Create webhook subscription
  20. /// </summary>
  21. [HttpPost]
  22. [ProducesResponseType(StatusCodes.Status201Created)]
  23. [ProducesResponseType(typeof(ErrorResponseDto), StatusCodes.Status400BadRequest)]
  24. public async Task<IActionResult> Post([FromBody] WebhookSubscriptionCreateDto dto)
  25. {
  26. await _webhookSubscriptionService.CreateWebhookSubscription(dto);
  27. return StatusCode(StatusCodes.Status201Created);
  28. }
  29. /// <summary>
  30. /// Get all webhook definitions
  31. /// </summary>
  32. [HttpGet("definitions")]
  33. [ProducesResponseType(typeof(List<WebhookDefinitionViewDto>), StatusCodes.Status200OK)]
  34. [ProducesResponseType(typeof(ErrorResponseDto), StatusCodes.Status400BadRequest)]
  35. public async Task<IActionResult> GetDefinitions()
  36. {
  37. return Ok(await _webhookDefinitionService.GetAll());
  38. }
  39. }
  40. }