diff --git a/UptimeSharp/Components/Get.cs b/UptimeSharp/Components/Monitor.cs similarity index 71% rename from UptimeSharp/Components/Get.cs rename to UptimeSharp/Components/Monitor.cs index adac38f..7ae7259 100644 --- a/UptimeSharp/Components/Get.cs +++ b/UptimeSharp/Components/Monitor.cs @@ -67,5 +67,32 @@ namespace UptimeSharp { return Get("getMonitors", parameters.Convert()).Items; } + + + /// + /// Deletes a monitor + /// + /// The unique identifier for the monitor. + /// success state + public bool Delete(int ID) + { + List parameters = new List() + { + new Parameter() { Name = "monitorID", Value = ID, Type = ParameterType.GetOrPost } + }; + + return Get("deleteMonitor", parameters).Status; + } + + + /// + /// Deletes a monitor + /// + /// The monitor. + /// success state + public bool Delete(Monitor monitor) + { + return Delete(monitor.ID); + } } } \ No newline at end of file diff --git a/UptimeSharp/Models/Response/Default.cs b/UptimeSharp/Models/Response/Default.cs new file mode 100644 index 0000000..a57bd6b --- /dev/null +++ b/UptimeSharp/Models/Response/Default.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System.Runtime.Serialization; + +namespace UptimeSharp.Models +{ + /// + /// Default Response + /// + [DataContract] + internal class Default : ResponseBase + { + + } +} diff --git a/UptimeSharp/Models/Response/ResponseBase.cs b/UptimeSharp/Models/Response/ResponseBase.cs index c3f9834..da02117 100644 --- a/UptimeSharp/Models/Response/ResponseBase.cs +++ b/UptimeSharp/Models/Response/ResponseBase.cs @@ -12,9 +12,24 @@ namespace UptimeSharp.Models /// Gets or sets a value indicating whether this is status. /// /// - /// true if status is OK; otherwise, false. + /// "ok" or "fail" /// [DataMember(Name = "stat")] - public bool Status { get; set; } + public string RawStatus { get; set; } + + /// + /// Gets or sets a value indicating whether this is status. + /// + /// + /// true if status is OK; otherwise, false. + /// + [IgnoreDataMember] + public bool Status + { + get + { + return RawStatus == "ok"; + } + } } } diff --git a/UptimeSharp/UptimeClient.cs b/UptimeSharp/UptimeClient.cs index c94d6aa..7a15a9c 100644 --- a/UptimeSharp/UptimeClient.cs +++ b/UptimeSharp/UptimeClient.cs @@ -123,6 +123,23 @@ namespace UptimeSharp } + protected string Get(string resource, List parameters = null) + { + var request = new RestRequest(resource, Method.GET); + + // enumeration for params + if (parameters != null) + { + parameters.ForEach( + param => request.AddParameter(param) + ); + } + + // do the request + return Request(request); + } + + ///// ///// Puts an action ///// diff --git a/UptimeSharp/UptimeSharp.csproj b/UptimeSharp/UptimeSharp.csproj index 4f0b4cc..3d507c9 100644 --- a/UptimeSharp/UptimeSharp.csproj +++ b/UptimeSharp/UptimeSharp.csproj @@ -52,12 +52,13 @@ - + +