示例#1
0
        public (bool LimitReached, WebHook WebHook) Add(
            Uri payloadTargetUri,
            bool enabled,
            string[] subscribedEvents,
            SubscriptionChoice subscriptionChoice,
            string secret)
        {
            if (_webHooks.Count >= _maxCount)
            {
                // Always limit the number of webhooks. Should probably throw a custom exception too.
                return(true, null);
            }
            subscribedEvents = subscribedEvents ?? Array.Empty <string>();
            var now  = _getUtcNow();
            var item = new WebHookMemento
            {
                Id = Guid.NewGuid(),
                PayloadTargetUri   = payloadTargetUri,
                CreatedUtc         = now,
                SubscribeToEvents  = new HashSet <string>(subscribedEvents),
                SubscriptionChoice = subscriptionChoice,
                Enabled            = enabled,
                UpdatedUtc         = now,
                Secret             = secret
            };
            var webHook = new WebHook(item);

            _webHooks.Add(webHook.Id, webHook);
            return(false, webHook);
        }
示例#2
0
 internal WebHook(WebHookMemento memento)
 {
     _memento = memento;
 }