diff --git a/UptimeSharp/Components/Get.cs b/UptimeSharp/Components/Get.cs index 2f220b8..adac38f 100644 --- a/UptimeSharp/Components/Get.cs +++ b/UptimeSharp/Components/Get.cs @@ -15,7 +15,12 @@ namespace UptimeSharp /// public List Get() { - return Get("getMonitors").Items; + GetParameters parameters = new GetParameters() + { + ShowAlerts = true + }; + + return Get("getMonitors", parameters.Convert()).Items; } @@ -28,7 +33,8 @@ namespace UptimeSharp { GetParameters parameters = new GetParameters() { - Monitors = new int[] { monitorId } + Monitors = new int[] { monitorId }, + ShowAlerts = true }; return Get("getMonitors", parameters.Convert()).Items[0]; @@ -44,7 +50,8 @@ namespace UptimeSharp { GetParameters parameters = new GetParameters() { - Monitors = monitors + Monitors = monitors, + ShowAlerts = true }; return Get("getMonitors", parameters.Convert()).Items; diff --git a/UptimeSharp/Models/Alert.cs b/UptimeSharp/Models/Alert.cs index 7f9eb17..2688595 100644 --- a/UptimeSharp/Models/Alert.cs +++ b/UptimeSharp/Models/Alert.cs @@ -24,7 +24,7 @@ namespace UptimeSharp.Models /// The name. /// [DataMember(Name = "type")] - public Type Type { get; set; } + public AlertType Type { get; set; } /// /// Gets or sets the alert value. @@ -41,7 +41,7 @@ namespace UptimeSharp.Models /// /// The type of the alert contact notified. /// - public enum Type + public enum AlertType { /// /// SMS @@ -50,7 +50,7 @@ namespace UptimeSharp.Models /// /// E-Mail /// - EMail = 2, + Email = 2, /// /// Twitter DM /// diff --git a/UptimeSharp/Models/Log.cs b/UptimeSharp/Models/Log.cs new file mode 100644 index 0000000..ffa9348 --- /dev/null +++ b/UptimeSharp/Models/Log.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; + +namespace UptimeSharp.Models +{ + /// + /// The Log Model + /// + [DataContract] + public class Log + { + /// + /// Gets or sets the log type. + /// + /// + /// The type. + /// + [DataMember(Name = "type")] + public LogType Type { get; set; } + + /// + /// Gets or sets the date time, when the log action appeared. + /// + /// + /// The date. + /// + [DataMember(Name = "datetime")] + public DateTime Date { get; set; } + + /// + /// Gets or sets the alerts, which were notified when the log action appeared. + /// + /// + /// The alert contacts. + /// + [DataMember(Name = "alertcontact")] + public List Alerts { get; set; } + } + + + + /// + /// The type of the log entry. + /// + public enum LogType + { + /// + /// Down + /// + Down = 1, + /// + /// Up + /// + Up = 2, + /// + /// Started + /// + Started = 98, + /// + /// Paused + /// + Paused = 99 + } +} diff --git a/UptimeSharp/Models/Monitor.cs b/UptimeSharp/Models/Monitor.cs index 54b44b1..f81085f 100644 --- a/UptimeSharp/Models/Monitor.cs +++ b/UptimeSharp/Models/Monitor.cs @@ -155,6 +155,24 @@ namespace UptimeSharp.Models /// [DataMember(Name = "subtype")] public Subtype Subtype { get; set; } + + /// + /// Gets or sets the alerts. + /// + /// + /// The alert contacts. + /// + [DataMember(Name = "alertcontact")] + public List Alerts { get; set; } + + /// + /// Gets or sets the log. + /// + /// + /// The log with dates and associated alert contacts. + /// + [DataMember(Name = "log")] + public List Log { get; set; } } diff --git a/UptimeSharp/Models/Parameters/GetParameters.cs b/UptimeSharp/Models/Parameters/GetParameters.cs index 0be98ba..875eb4a 100644 --- a/UptimeSharp/Models/Parameters/GetParameters.cs +++ b/UptimeSharp/Models/Parameters/GetParameters.cs @@ -31,15 +31,7 @@ namespace UptimeSharp.Models /// /// The log bool. /// - public bool? ShowLogs { get; set; } - - /// - /// Defines if the notified alert contacts of each notification will be returned - /// - /// - /// The alert contacts bool. - /// - public bool? ShowAlertContacts { get; set; } + public bool? ShowLog { get; set; } /// /// Defines if the alert contacts set for the monitor to be returned @@ -47,15 +39,7 @@ namespace UptimeSharp.Models /// /// The alert contacts bool. /// - public bool? ShowMonitorAlertContacts { get; set; } - - /// - /// Defines if the user's timezone should be returned - /// - /// - /// The alert contacts bool. - /// - public bool? ShowTimezone { get; set; } + public bool? ShowAlerts { get; set; } /// @@ -74,21 +58,16 @@ namespace UptimeSharp.Models { parameters.Add(Utilities.CreateParam("customUptimeRatio", String.Join("-", CustomUptimeRatio))); } - if (ShowLogs.HasValue) + if (ShowLog.HasValue) { - parameters.Add(Utilities.CreateParam("logs", ShowLogs)); + string showLog = (bool)ShowLog ? "1" : "0"; + parameters.Add(Utilities.CreateParam("logs", showLog)); + parameters.Add(Utilities.CreateParam("alertContacts", showLog)); + parameters.Add(Utilities.CreateParam("showTimezone", showLog)); } - if (ShowAlertContacts.HasValue) + if (ShowAlerts.HasValue) { - parameters.Add(Utilities.CreateParam("alertContacts", ShowAlertContacts)); - } - if (ShowMonitorAlertContacts.HasValue) - { - parameters.Add(Utilities.CreateParam("showMonitorAlertContacts", ShowMonitorAlertContacts)); - } - if (ShowTimezone.HasValue) - { - parameters.Add(Utilities.CreateParam("showTimezone", ShowTimezone)); + parameters.Add(Utilities.CreateParam("showMonitorAlertContacts", (bool)ShowAlerts ? "1" : "0")); } return parameters; diff --git a/UptimeSharp/UptimeSharp.csproj b/UptimeSharp/UptimeSharp.csproj index 42bed90..4f0b4cc 100644 --- a/UptimeSharp/UptimeSharp.csproj +++ b/UptimeSharp/UptimeSharp.csproj @@ -54,6 +54,8 @@ + +