diff --git a/UptimeSharp.Tests/AlertsTest.cs b/UptimeSharp.Tests/AlertsTest.cs index 4c9f1a1..ca9bb6e 100644 --- a/UptimeSharp.Tests/AlertsTest.cs +++ b/UptimeSharp.Tests/AlertsTest.cs @@ -1,8 +1,7 @@ -using Xunit; -using System.Collections.Generic; -using UptimeSharp.Models; -using System; +using System.Collections.Generic; using System.Threading.Tasks; +using UptimeSharp.Models; +using Xunit; namespace UptimeSharp.Tests { @@ -59,11 +58,14 @@ namespace UptimeSharp.Tests List alerts = await client.GetAlerts(); - Assert.InRange(alerts.ToArray().Length, 2, 100); + Assert.InRange(alerts.Count, 2, 100); List specificAlerts = await client.GetAlerts(new string[] { alerts[0].ID, alerts[1].ID }); - Assert.Equal(2, specificAlerts.ToArray().Length); + Assert.Equal(2, specificAlerts.Count); + + await client.DeleteAlert(alerts[0]); + await client.DeleteAlert(alerts[1]); } diff --git a/UptimeSharp/Models/Alert.cs b/UptimeSharp/Models/Alert.cs index b7817c0..dce1ba0 100644 --- a/UptimeSharp/Models/Alert.cs +++ b/UptimeSharp/Models/Alert.cs @@ -71,6 +71,10 @@ namespace UptimeSharp.Models /// public enum AlertType { + /// + /// Unknown + /// + Unknown, /// /// SMS /// diff --git a/UptimeSharp/Models/Response/AddAlertResonse.cs b/UptimeSharp/Models/Response/AddAlertResonse.cs new file mode 100644 index 0000000..28424f5 --- /dev/null +++ b/UptimeSharp/Models/Response/AddAlertResonse.cs @@ -0,0 +1,21 @@ +using Newtonsoft.Json; + +namespace UptimeSharp.Models +{ + /// + /// Alert Response + /// + [JsonObject] + internal class AddAlertResponse : Response + { + /// + /// Gets or sets the item dictionary. + /// The list is 2 layers deep, so this one is necessary :-/ + /// + /// + /// The item dictionary. + /// + [JsonProperty("alertcontact")] + public Alert Alert { get; set; } + } +} diff --git a/UptimeSharp/UptimeClient.cs b/UptimeSharp/UptimeClient.cs index c558ff8..bad6a06 100644 --- a/UptimeSharp/UptimeClient.cs +++ b/UptimeSharp/UptimeClient.cs @@ -119,7 +119,7 @@ namespace UptimeSharp // with this param it can return raw JSON parameters.Add("noJsonCallback", "1"); - IEnumerable paramEnumerable = parameters.Select(item => Uri.EscapeDataString(item.Key) + "=" + Uri.EscapeDataString(item.Value)); + IEnumerable paramEnumerable = parameters.Where(item => !String.IsNullOrEmpty(item.Value)).Select(item => Uri.EscapeDataString(item.Key) + "=" + Uri.EscapeDataString(item.Value)); // content of the request request = new HttpRequestMessage(HttpMethod.Get, method + "?" + String.Join("&", paramEnumerable));