using RestSharp;
using System;
using System.Collections.Generic;
namespace UptimeSharp.Models
{
///
/// All parameters which can be passed for monitor retrieval
///
internal class RetrieveParameters
{
///
/// 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? ShowLog { get; set; }
///
/// Defines if the alert contacts set for the monitor to be returned
///
///
/// The alert contacts bool.
///
public bool? ShowAlerts { get; set; }
///
/// Converts this instance to a parameter list.
///
/// Parameter list
public List Convert()
{
List parameters = new List();
if (Monitors != null && Monitors.Length > 0)
{
parameters.Add(UptimeClient.Parameter("monitors", String.Join("-", Monitors)));
}
if (CustomUptimeRatio != null && CustomUptimeRatio.Length > 0)
{
parameters.Add(UptimeClient.Parameter("customUptimeRatio", String.Join("-", CustomUptimeRatio)));
}
parameters.Add(UptimeClient.Parameter("showMonitorAlertContacts", (bool)ShowAlerts ? "1" : "0"));
if (ShowLog.HasValue)
{
string showLog = (bool)ShowLog ? "1" : "0";
parameters.Add(UptimeClient.Parameter("logs", showLog));
parameters.Add(UptimeClient.Parameter("alertContacts", showLog));
parameters.Add(UptimeClient.Parameter("showTimezone", showLog));
}
return parameters;
}
}
}