internal static EmailNotificationHook DeserializeEmailNotificationHook(JsonElement element)
        {
            EmailHookParameter 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 = EmailHookParameter.DeserializeEmailHookParameter(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 EmailNotificationHook(hookType, hookId.Value, hookName, description.Value, externalLink.Value, Optional.ToList(admins), hookParameter));
        }
예제 #2
0
        /// <summary>
        /// </summary>
        public EmailHook(string name, IList <string> emailsToAlert)
            : base(name)
        {
            Argument.AssertNotNull(emailsToAlert, nameof(emailsToAlert));

            HookParameter = new EmailHookParameter(emailsToAlert);
            HookType      = HookType.Email;
        }
        /// <summary>
        /// Initializes a new instance of <see cref="Administration.EmailNotificationHook"/> 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="emailsToAlert">Sets the <see cref="EmailNotificationHook.EmailsToAlert"/> property.</param>
        /// <returns>A new instance of <see cref="Administration.EmailNotificationHook"/> for mocking purposes.</returns>
        public static EmailNotificationHook EmailNotificationHook(string id = null, string name = null, string description = null, Uri externalUri = null, IEnumerable <string> administrators = null, IEnumerable <string> emailsToAlert = null)
        {
            administrators ??= new List <string>();
            emailsToAlert ??= new List <string>();

            EmailHookParameter parameter = new EmailHookParameter(emailsToAlert.ToList());

            return(new EmailNotificationHook(NotificationHookKind.Email, id, name, description, externalUri?.AbsoluteUri, administrators.ToList(), parameter));
        }
 internal EmailNotificationHook(HookType hookType, string id, string name, string description, string externalLink, IReadOnlyList <string> administrators, EmailHookParameter hookParameter)
     : base(hookType, id, name, description, externalLink, administrators)
 {
     HookType      = hookType;
     EmailsToAlert = hookParameter.ToList;
 }
예제 #5
0
 internal EmailHook(HookType hookType, string id, string name, string description, string externalLink, IReadOnlyList <string> administrators, EmailHookParameter hookParameter)
     : base(hookType, id, name, description, externalLink, administrators)
 {
     HookParameter = hookParameter;
     HookType      = hookType;
 }