internal static WebNotificationHook DeserializeWebNotificationHook(JsonElement element)
        {
            WebhookHookParameter hookParameter      = default;
            NotificationHookKind hookType           = default;
            Optional <string>    hookId             = default;
            string                     hookName     = default;
            Optional <string>          description  = default;
            Optional <string>          externalLink = default;
            Optional <IList <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 NotificationHookKind(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));
        }
 internal NotificationHook(NotificationHookKind hookType, string id, string name, string description, string internalExternalLink, IList <string> administrators)
 {
     HookKind       = hookType;
     Id             = id;
     Name           = name;
     Description    = description;
     ExternalUri    = string.IsNullOrEmpty(internalExternalLink) ? null : new Uri(internalExternalLink);
     Administrators = administrators;
 }
Beispiel #3
0
 internal WebNotificationHook(NotificationHookKind hookType, string id, string name, string description, string externalLink, IList <string> administrators, WebhookHookParameter hookParameter)
     : base(hookType, id, name, description, externalLink, administrators)
 {
     HookKind            = hookType;
     Endpoint            = new Uri(hookParameter.Endpoint);
     Username            = hookParameter.Username;
     Password            = hookParameter.Password;
     CertificateKey      = hookParameter.CertificateKey;
     CertificatePassword = hookParameter.CertificatePassword;
     Headers             = hookParameter.Headers;
 }
 internal EmailNotificationHook(NotificationHookKind hookType, string id, string name, string description, string externalLink, IList <string> administrators, EmailHookParameter hookParameter)
     : base(hookType, id, name, description, externalLink, administrators)
 {
     HookKind      = hookType;
     EmailsToAlert = hookParameter.ToList;
 }