Exemple #1
0
        /// <summary>
        /// if subscribed to given webhook
        /// </summary>
        /// <returns></returns>
        public static bool IsSubscribed(this WebhookSubscriptionInfo webhookSubscription, string webhookName)
        {
            if (webhookSubscription.Webhooks.IsNullOrWhiteSpace())
            {
                return(false);
            }

            return(webhookSubscription.GetSubscribedWebhooks().Contains(webhookName));
        }
Exemple #2
0
        /// <summary>
        ///  Removes webhook subscription from <see cref="WebhookSubscriptionInfo.Webhooks"/> if exists
        /// </summary>
        /// <param name="webhookSubscription"></param>
        /// <param name="name">webhook unique name</param>
        public static void UnsubscribeWebhook(this WebhookSubscriptionInfo webhookSubscription, string name)
        {
            name = name.Trim();
            if (name.IsNullOrWhiteSpace())
            {
                throw new ArgumentNullException(nameof(name), $"{nameof(name)} can not be null, empty or whitespace!");
            }

            var webhookDefinitions = webhookSubscription.GetSubscribedWebhooks();

            if (!webhookDefinitions.Contains(name))
            {
                return;
            }

            webhookDefinitions.Remove(name);
            webhookSubscription.Webhooks = webhookDefinitions.ToJsonString();
        }