public IActionResult Register(WebhookRegistrationViewModel registration)
        {
            if (registration == null)
            {
                return(BadRequest("webhook data must be provided"));
            }

            if (string.IsNullOrWhiteSpace(registration.EndpointUrl))
            {
                return(BadRequest("endpoint url must be provided"));
            }

            if (!AvailableEvents.GetAll.Contains(registration.Event))
            {
                return(BadRequest($"{registration.Event} is not a supported webhook event"));
            }

            _webhookService.AddWebhook(registration);

            return(NoContent());
        }
Exemple #2
0
 public void AddWebhook(WebhookRegistrationViewModel registration)
 {
     _webhooks.Add(new Webhook(registration.EndpointUrl, registration.Event));
 }