diff --git a/UptimeSharp/Models/Parameters/GetParameters.cs b/UptimeSharp/Models/Parameters/GetParameters.cs new file mode 100644 index 0000000..1def349 --- /dev/null +++ b/UptimeSharp/Models/Parameters/GetParameters.cs @@ -0,0 +1,78 @@ +using RestSharp; +using System; +using System.Collections.Generic; + +namespace UptimeSharp.Models +{ + /// + /// All parameters which can be passed for monitor retrieval + /// + public class GetParameters + { + /// + /// List of monitor ids + /// + /// + /// The monitors. + /// + public int[] Monitors { get; set; } + + /// + /// Defines the number of days to calculate the uptime ratio + /// + /// + /// The custom uptime ratio. + /// + public float[] CustomUptimeRatio { get; set; } + + /// + /// Defines if the logs of each monitor will be returned + /// + /// + /// 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; } + + /// + /// Defines if the alert contacts set for the monitor to be returned + /// + /// + /// 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; } + + + /// + /// Converts this instance to a parameter list. + /// + /// Parameter list + public List Convert() + { + return new List() + { + Utilities.CreateParam("monitors", String.Join("-", Monitors)), + Utilities.CreateParam("customUptimeRatio", String.Join("-", CustomUptimeRatio)), + Utilities.CreateParam("logs", Utilities.Bool(ShowLogs)), + Utilities.CreateParam("alertContacts", Utilities.Bool(ShowAlertContacts)), + Utilities.CreateParam("showMonitorAlertContacts", Utilities.Bool(ShowMonitorAlertContacts)), + Utilities.CreateParam("showTimezone", Utilities.Bool(ShowTimezone)) + }; + } + } +} diff --git a/UptimeSharp/Utilities.cs b/UptimeSharp/Utilities.cs index dd368b0..1616f61 100644 --- a/UptimeSharp/Utilities.cs +++ b/UptimeSharp/Utilities.cs @@ -9,6 +9,18 @@ namespace UptimeSharp /// internal class Utilities { + + /// + /// converts a bool to a string for GET param + /// + /// The value. + /// A string representation of the boolean + public static string? Bool(bool? value) + { + return value != null ? ((bool)value ? "1" : "0") : null; + } + + /// /// converts DateTime to an UNIX timestamp ///