internal static WebNotificationHook DeserializeWebNotificationHook(JsonElement element)
        {
            WebhookHookParameter hookParameter        = default;
            HookType             hookType             = default;
            Optional <string>    hookId               = default;
            string            hookName                = default;
            Optional <string> description             = default;
            Optional <string> externalLink            = default;
            Optional <IReadOnlyList <string> > admins = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("hookParameter"))
                {
                    hookParameter = WebhookHookParameter.DeserializeWebhookHookParameter(property.Value);
                    continue;
                }
                if (property.NameEquals("hookType"))
                {
                    hookType = new HookType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("hookId"))
                {
                    hookId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("hookName"))
                {
                    hookName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("externalLink"))
                {
                    externalLink = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("admins"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    admins = array;
                    continue;
                }
            }
            return(new WebNotificationHook(hookType, hookId.Value, hookName, description.Value, externalLink.Value, Optional.ToList(admins), hookParameter));
        }
        /// <summary>
        /// Initializes a new instance of <see cref="Administration.WebNotificationHook"/> for mocking purposes.
        /// </summary>
        /// <param name="id">Sets the <see cref="NotificationHook.Id"/> property.</param>
        /// <param name="name">Sets the <see cref="NotificationHook.Name"/> property.</param>
        /// <param name="description">Sets the <see cref="NotificationHook.Description"/> property.</param>
        /// <param name="externalUri">Sets the <see cref="NotificationHook.ExternalUri"/> property.</param>
        /// <param name="administrators">Sets the <see cref="NotificationHook.Administrators"/> property.</param>
        /// <param name="endpoint">Sets the <see cref="WebNotificationHook.Endpoint"/> property.</param>
        /// <param name="username">Sets the <see cref="WebNotificationHook.Username"/> property.</param>
        /// <param name="password">Sets the <see cref="WebNotificationHook.Password"/> property.</param>
        /// <param name="headers">Sets the <see cref="WebNotificationHook.Headers"/> property.</param>
        /// <param name="certificateKey">Sets the <see cref="WebNotificationHook.CertificateKey"/> property.</param>
        /// <param name="certificatePassword">Sets the <see cref="WebNotificationHook.CertificatePassword"/> property.</param>
        /// <returns>A new instance of <see cref="Administration.WebNotificationHook"/> for mocking purposes.</returns>
        public static WebNotificationHook WebNotificationHook(string id = null, string name = null, string description = null, Uri externalUri = null, IEnumerable <string> administrators = null, Uri endpoint = null, string username = null, string password = null, IDictionary <string, string> headers = null, string certificateKey = null, string certificatePassword = null)
        {
            administrators ??= new List <string>();
            headers ??= new Dictionary <string, string>();

            WebhookHookParameter parameter = new WebhookHookParameter(endpoint?.AbsoluteUri, username, password, headers, certificateKey, certificatePassword);

            return(new WebNotificationHook(NotificationHookKind.Webhook, id, name, description, externalUri?.AbsoluteUri, administrators.ToList(), parameter));
        }
 internal WebNotificationHook(HookType hookType, string id, string name, string description, string externalLink, IReadOnlyList <string> administrators, WebhookHookParameter hookParameter)
     : base(hookType, id, name, description, externalLink, administrators)
 {
     HookType            = hookType;
     Endpoint            = new Uri(hookParameter.Endpoint);
     Username            = hookParameter.Username;
     Password            = hookParameter.Password;
     CertificateKey      = hookParameter.CertificateKey;
     CertificatePassword = hookParameter.CertificatePassword;
     Headers             = hookParameter.Headers;
 }