18 using System.Collections.Generic;
19 using Newtonsoft.Json;
20 using Newtonsoft.Json.Linq;
38 public override void WriteJson(JsonWriter writer,
object value, JsonSerializer serializer)
50 public override object ReadJson(JsonReader reader, Type objectType,
object existingValue, JsonSerializer serializer)
52 var jObject = JObject.Load(reader);
55 if (jObject.TryGetValue(
"PhoneNumber", StringComparison.InvariantCultureIgnoreCase, out token))
57 var message = jObject.GetValue(
"Message", StringComparison.InvariantCultureIgnoreCase);
61 else if (jObject.TryGetValue(
"Subject", StringComparison.InvariantCultureIgnoreCase, out token))
63 var data = jObject.GetValue(
"Data", StringComparison.InvariantCultureIgnoreCase);
64 var message = jObject.GetValue(
"Message", StringComparison.InvariantCultureIgnoreCase);
65 var address = jObject.GetValue(
"Address", StringComparison.InvariantCultureIgnoreCase);
66 var headers= jObject.GetValue(
"Headers", StringComparison.InvariantCultureIgnoreCase);
68 return new NotificationEmail(address?.ToString(), token.ToString(), message?.ToString(), data?.ToString(), headers?.ToObject<Dictionary<string, string>>());
70 else if (jObject.TryGetValue(
"Address", StringComparison.InvariantCultureIgnoreCase, out token))
72 var headers = jObject.GetValue(
"Headers", StringComparison.InvariantCultureIgnoreCase);
73 var data = jObject.GetValue(
"Data", StringComparison.InvariantCultureIgnoreCase);
75 return new NotificationWeb(token.ToString(), data?.ToString(), headers?.ToObject<Dictionary<string, string>>());
77 else if (jObject.TryGetValue(
"Id", StringComparison.InvariantCultureIgnoreCase, out token))
79 var message = jObject.GetValue(
"Message", StringComparison.InvariantCultureIgnoreCase);
80 var botToken = jObject.GetValue(
"Token", StringComparison.InvariantCultureIgnoreCase);
83 else if (jObject.TryGetValue(
"host", StringComparison.InvariantCultureIgnoreCase, out token))
86 var hostname = token.ToString();
87 var port = jObject.GetValue(
"port", StringComparison.InvariantCultureIgnoreCase)?.ToObject<
int?>();
88 var username = jObject.GetValue(
"username", StringComparison.InvariantCultureIgnoreCase)?.ToString();
89 var filePath = jObject.GetValue(
"fileDestinationPath", StringComparison.InvariantCultureIgnoreCase)?.ToString();
90 var fileContent = jObject.GetValue(
"fileContent", StringComparison.InvariantCultureIgnoreCase)?.ToString();
92 if (jObject.TryGetValue(
"password", StringComparison.InvariantCultureIgnoreCase, out var password))
94 var secure = jObject.GetValue(
"secure", StringComparison.InvariantCultureIgnoreCase)?.ToObject<
bool>() ??
true;
95 return NotificationFtp.FromEncodedData(hostname, username, password.ToString(), filePath, fileContent, secure, port);
98 var privateKey = jObject.GetValue(
"privateKey", StringComparison.InvariantCultureIgnoreCase)?.ToString();
99 var passphrase = jObject.GetValue(
"passphrase", StringComparison.InvariantCultureIgnoreCase)?.ToString();
100 return NotificationFtp.FromEncodedData(hostname, username, privateKey, passphrase, filePath, fileContent, port);