add GetParameter Model;

This commit is contained in:
2013-08-15 10:34:52 +02:00
parent 76542c2e54
commit 317605debf
2 changed files with 90 additions and 0 deletions
@@ -0,0 +1,78 @@
using RestSharp;
using System;
using System.Collections.Generic;
namespace UptimeSharp.Models
{
/// <summary>
/// All parameters which can be passed for monitor retrieval
/// </summary>
public class GetParameters
{
/// <summary>
/// List of monitor ids
/// </summary>
/// <value>
/// The monitors.
/// </value>
public int[] Monitors { get; set; }
/// <summary>
/// Defines the number of days to calculate the uptime ratio
/// </summary>
/// <value>
/// The custom uptime ratio.
/// </value>
public float[] CustomUptimeRatio { get; set; }
/// <summary>
/// Defines if the logs of each monitor will be returned
/// </summary>
/// <value>
/// The log bool.
/// </value>
public bool? ShowLogs { get; set; }
/// <summary>
/// Defines if the notified alert contacts of each notification will be returned
/// </summary>
/// <value>
/// The alert contacts bool.
/// </value>
public bool? ShowAlertContacts { get; set; }
/// <summary>
/// Defines if the alert contacts set for the monitor to be returned
/// </summary>
/// <value>
/// The alert contacts bool.
/// </value>
public bool? ShowMonitorAlertContacts { get; set; }
/// <summary>
/// Defines if the user's timezone should be returned
/// </summary>
/// <value>
/// The alert contacts bool.
/// </value>
public bool? ShowTimezone { get; set; }
/// <summary>
/// Converts this instance to a parameter list.
/// </summary>
/// <returns>Parameter list</returns>
public List<Parameter> Convert()
{
return new List<Parameter>()
{
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))
};
}
}
}
+12
View File
@@ -9,6 +9,18 @@ namespace UptimeSharp
/// </summary>
internal class Utilities
{
/// <summary>
/// converts a bool to a string for GET param
/// </summary>
/// <param name="value">The value.</param>
/// <returns>A string representation of the boolean</returns>
public static string? Bool(bool? value)
{
return value != null ? ((bool)value ? "1" : "0") : null;
}
/// <summary>
/// converts DateTime to an UNIX timestamp
/// </summary>