public void AddOrUpdateSubscription(WebhookSubscription webhookSubscription)
        {
            CheckIfPermissionsGranted(webhookSubscription);

            if (webhookSubscription.Id == default)
            {
                webhookSubscription.Id     = _guidGenerator.Create();
                webhookSubscription.Secret = WebhookSubscriptionSecretPrefix + Guid.NewGuid().ToString().Replace("-", "");
                WebhookSubscriptionsStore.Insert(webhookSubscription.ToWebhookSubscriptionInfo());
            }
            else
            {
                var subscription = WebhookSubscriptionsStore.Get(webhookSubscription.Id);
                subscription.WebhookUri = webhookSubscription.WebhookUri;
                subscription.Webhooks   = webhookSubscription.Webhooks.ToJsonString();
                subscription.Headers    = webhookSubscription.Headers.ToJsonString();
                WebhookSubscriptionsStore.Update(subscription);
            }
        }
        public virtual async Task AddOrUpdateSubscriptionAsync(WebhookSubscription webhookSubscription)
        {
            await CheckIfPermissionsGrantedAsync(webhookSubscription);

            if (webhookSubscription.Id == default)
            {
                webhookSubscription.Id     = _guidGenerator.Create();
                webhookSubscription.Secret = WebhookSubscriptionSecretPrefix + Guid.NewGuid().ToString("N");
                await WebhookSubscriptionsStore.InsertAsync(webhookSubscription.ToWebhookSubscriptionInfo());
            }
            else
            {
                var subscription = await WebhookSubscriptionsStore.GetAsync(webhookSubscription.Id);

                subscription.WebhookUri = webhookSubscription.WebhookUri;
                subscription.Webhooks   = webhookSubscription.Webhooks.ToJsonString();
                subscription.Headers    = webhookSubscription.Headers.ToJsonString();
                await WebhookSubscriptionsStore.UpdateAsync(subscription);
            }
        }
        public virtual void AddOrUpdateSubscription(WebhookSubscription webhookSubscription)
        {
            UnitOfWorkManager.WithUnitOfWork(() =>
            {
                CheckIfPermissionsGranted(webhookSubscription);

                if (webhookSubscription.Id == default)
                {
                    webhookSubscription.Id     = _guidGenerator.Create();
                    webhookSubscription.Secret = WebhookSubscriptionSecretPrefix + Guid.NewGuid().ToString("N");
                    WebhookSubscriptionsStore.Insert(webhookSubscription.ToWebhookSubscriptionInfo());
                }
                else
                {
                    var subscription        = WebhookSubscriptionsStore.Get(webhookSubscription.Id);
                    subscription.WebhookUri = webhookSubscription.WebhookUri;
                    subscription.Webhooks   = webhookSubscription.Webhooks.ToJsonString();
                    subscription.Headers    = webhookSubscription.Headers.ToJsonString();
                    WebhookSubscriptionsStore.Update(subscription);
                }
            });
        }