Пример #1
0
        public static Boolean TryParse(JObject JSON, out HTTPSNotification Notification)
        {
            var url = JSON["URL"]?.Value <String>();

            if (JSON["@context"]?.Value <String>() == JSONLDContext &&
                url.IsNotNullOrEmpty())
            {
                Notification = new HTTPSNotification(JSON["URL"]?.Value <String>(),
                                                     JSON["method"] != null ? HTTPMethod.ParseString(JSON["method"].Value <String>()) : HTTPMethod.POST,
                                                     JSON["TCPPort"] != null ? IPPort.Parse(JSON["TCPPort"].Value <String>()) : IPPort.HTTPS,
                                                     JSON["basicAuth"]?["login"]?.Value <String>(),
                                                     JSON["basicAuth"]?["password"]?.Value <String>(),
                                                     JSON["APIKey"]?.Value <String>(),
                                                     JSON["RequestTimeout"] != null ? TimeSpan.FromSeconds((Double)JSON["RequestTimeout"]?.Value <Int32>()) : new TimeSpan?(),
                                                     (JSON["messageTypes"] as JArray)?.SafeSelect(element => NotificationMessageType.Parse(element.Value <String>())),
                                                     JSON["description"]?.Value <String>());

                return(true);
            }

            Notification = null;
            return(false);
        }
Пример #2
0
        public static Boolean TryParse(JObject JSON, out TelegramGroupNotification Notification)
        {
            var GroupName = JSON["groupName"]?.Value <String>();

            if (JSON["@context"]?.Value <String>() == JSONLDContext && GroupName.IsNeitherNullNorEmpty())
            {
                Notification = new TelegramGroupNotification(GroupName,
                                                             JSON["chatId"]?.Value <Int32>(),
                                                             JSON["sharedSecret"]?.Value <String>(),
                                                             JSON["textTemplate"]?.Value <String>(),
                                                             (JSON["messageTypes"] as JArray)?.SafeSelect(element => NotificationMessageType.Parse(element.Value <String>())),
                                                             JSON["description"]?.Value <String>());

                return(true);
            }

            Notification = null;
            return(false);
        }
Пример #3
0
        public static Boolean TryParse(JObject JSON, out EMailNotification Notification)
        {
            if (JSON["@context"]?.Value <String>() == JSONLDContext &&
                JSON["email"] is JObject EMailJSON &&
                EMailAddress.TryParseJSON(EMailJSON,
                                          out EMailAddress EMail,
                                          out String ErrorResponse,
                                          true))
            {
                Notification = new EMailNotification(EMail,
                                                     JSON["subject"]?.Value <String>(),
                                                     JSON["subjectPrefix"]?.Value <String>(),
                                                     JSON["listId"]?.Value <String>(),
                                                     (JSON["messageTypes"] as JArray)?.SafeSelect(element => NotificationMessageType.Parse(element.Value <String>())),
                                                     JSON["description"]?.Value <String>());

                return(true);
            }

            Notification = null;
            return(false);
        }
Пример #4
0
        public static Boolean TryParse(JObject JSON, out SMSNotification Notification)
        {
            if (JSON["@context"]?.Value <String>() == JSONLDContext &&
                PhoneNumber.TryParse(JSON["phoneNumber"]?.Value <String>(), out PhoneNumber phoneNumber))
            {
                Notification = new SMSNotification(PhoneNumber.Parse(JSON["phoneNumber"]?.Value <String>()),
                                                   JSON["textTemplate"]?.Value <String>(),
                                                   (JSON["messageTypes"] as JArray)?.SafeSelect(element => NotificationMessageType.Parse(element.Value <String>())),
                                                   JSON["description"]?.Value <String>());

                return(true);
            }

            Notification = null;
            return(false);
        }