Esempio n. 1
0
        /// <summary>
        /// Adds webhook subscription to <see cref="WebhookSubscriptionInfo.Webhooks"/> if not exists
        /// </summary>
        /// <param name="webhookSubscription"></param>
        /// <param name="header">Key of header</param>
        public static void RemoveWebhookHeader(this WebhookSubscriptionInfo webhookSubscription, string header)
        {
            if (header.IsNullOrWhiteSpace())
            {
                throw new ArgumentNullException(nameof(header), $"{nameof(header)} can not be null, empty or whitespace!");
            }

            var headers = webhookSubscription.GetWebhookHeaders();

            if (!headers.ContainsKey(header))
            {
                return;
            }

            headers.Remove(header);

            webhookSubscription.Headers = headers.ToJsonString();
        }
Esempio n. 2
0
        /// <summary>
        /// Adds webhook subscription to <see cref="WebhookSubscriptionInfo.Webhooks"/> if not exists
        /// </summary>
        public static void AddWebhookHeader(this WebhookSubscriptionInfo webhookSubscription, string key, string value)
        {
            if (key.IsNullOrWhiteSpace())
            {
                throw new ArgumentNullException(nameof(key), $"{nameof(key)} can not be null, empty or whitespace!");
            }

            if (value.IsNullOrWhiteSpace())
            {
                throw new ArgumentNullException(nameof(value), $"{nameof(value)} can not be null, empty or whitespace!");
            }

            var headers = webhookSubscription.GetWebhookHeaders();

            headers[key] = value;

            webhookSubscription.Headers = headers.ToJsonString();
        }