diff --git a/MigrationBackup/0f58b976/PushoverClient/PushoverClient.csproj b/MigrationBackup/0f58b976/PushoverClient/PushoverClient.csproj new file mode 100644 index 0000000..0dd5200 --- /dev/null +++ b/MigrationBackup/0f58b976/PushoverClient/PushoverClient.csproj @@ -0,0 +1,67 @@ + + + + + Debug + AnyCPU + {16E7D1FF-237A-4E89-94C6-FDDA36FBDDB0} + Library + Properties + PushoverClient + PushoverClient + v4.7.2 + 512 + ..\ + true + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PushoverClient/packages.config b/MigrationBackup/0f58b976/PushoverClient/packages.config similarity index 100% rename from PushoverClient/packages.config rename to MigrationBackup/0f58b976/PushoverClient/packages.config diff --git a/MigrationBackup/a18c6d13/SendPush/SendPush.csproj b/MigrationBackup/a18c6d13/SendPush/SendPush.csproj new file mode 100644 index 0000000..15183fa --- /dev/null +++ b/MigrationBackup/a18c6d13/SendPush/SendPush.csproj @@ -0,0 +1,76 @@ + + + + + Debug + AnyCPU + {6DB8F6AB-5003-4E57-80D8-D8A626D525DD} + Exe + Properties + SendPush + SendPush + v4.7.2 + 512 + ..\ + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\..\..\Packages\Microsoft.Extensions.CommandLineUtils.1.1.1\lib\net451\Microsoft.Extensions.CommandLineUtils.dll + + + + + + + + + + + + + + + + + + Designer + + + + + + {16e7d1ff-237a-4e89-94c6-fdda36fbddb0} + PushoverClient + + + + + + \ No newline at end of file diff --git a/SendPush/packages.config b/MigrationBackup/a18c6d13/SendPush/packages.config similarity index 59% rename from SendPush/packages.config rename to MigrationBackup/a18c6d13/SendPush/packages.config index 0d9f591..c89bae1 100644 --- a/SendPush/packages.config +++ b/MigrationBackup/a18c6d13/SendPush/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/PushoverClient.Tests/ClientTests.cs b/PushoverClient.Tests/ClientTests.cs index 315fda2..779e769 100644 --- a/PushoverClient.Tests/ClientTests.cs +++ b/PushoverClient.Tests/ClientTests.cs @@ -106,5 +106,69 @@ public async Task PushWithSound_ReturnsSuccessful() Assert.IsNotNull(response); Assert.AreEqual(1, response.Status); } + + [TestMethod] + public void PushHtmlWithValidParms_ReturnsSuccessful() + { + // Arrange + var title = "Test title"; + var message = "This is a bold test with italic push notification message"; + + // Act + var pclient = new Pushover(TEST_APP_KEY); + var response = pclient.Push(title, message, TEST_USER_KEY, "", Priority.Normal, NotificationSound.Bike, MessageStyle.html); + + // Assert + Assert.IsNotNull(response); + Assert.AreEqual(1, response.Status); + } + + [TestMethod] + public async Task PushHtmlAsyncWithValidParms_ReturnsSuccessful() + { + // Arrange + var title = "Test title"; + var message = "This is an async bold test with italic push notification message"; + + // Act + var pclient = new Pushover(TEST_APP_KEY); + var response = await pclient.PushAsync(title, message, TEST_USER_KEY, "", Priority.Normal, NotificationSound.Bike, MessageStyle.html); + + // Assert + Assert.IsNotNull(response); + Assert.AreEqual(1, response.Status); + } + + [TestMethod] + public void PushMonospaceWithValidParms_ReturnsSuccessful() + { + // Arrange + var title = "Test title"; + var message = "This is a monospace test push notification message"; + + // Act + var pclient = new Pushover(TEST_APP_KEY); + var response = pclient.Push(title, message, TEST_USER_KEY, "", Priority.Normal, NotificationSound.Bike, MessageStyle.monospace); + + // Assert + Assert.IsNotNull(response); + Assert.AreEqual(1, response.Status); + } + + [TestMethod] + public async Task PushMonospaceAsyncWithValidParms_ReturnsSuccessful() + { + // Arrange + var title = "Test title"; + var message = "This is an async monospace test push notification message"; + + // Act + var pclient = new Pushover(TEST_APP_KEY); + var response = await pclient.PushAsync(title, message, TEST_USER_KEY, "", Priority.Normal, NotificationSound.Bike, MessageStyle.monospace); + + // Assert + Assert.IsNotNull(response); + Assert.AreEqual(1, response.Status); + } } } diff --git a/PushoverClient/MessageStyle.cs b/PushoverClient/MessageStyle.cs new file mode 100644 index 0000000..7611db5 --- /dev/null +++ b/PushoverClient/MessageStyle.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +namespace PushoverClient +{ + //Detail at https://pushover.net/api#html + public enum MessageStyle + { + NotSet, //Default = will leave empty on sending + html, + monospace + } +} \ No newline at end of file diff --git a/PushoverClient/PushOverRequestArguments.cs b/PushoverClient/PushOverRequestArguments.cs index 25b6479..4a3b978 100644 --- a/PushoverClient/PushOverRequestArguments.cs +++ b/PushoverClient/PushOverRequestArguments.cs @@ -10,5 +10,7 @@ public class PushoverRequestArguments public string message { get; set; } public int priority { get; set; } public string sound { get; set; } + public string html { get; set; } + public string monospace { get; set; } } } \ No newline at end of file diff --git a/PushoverClient/Pushover.cs b/PushoverClient/Pushover.cs index 29b6003..413ed69 100644 --- a/PushoverClient/Pushover.cs +++ b/PushoverClient/Pushover.cs @@ -1,5 +1,6 @@ using ServiceStack; using System; +using System.Globalization; using System.Net; using System.Threading.Tasks; @@ -63,10 +64,11 @@ public Pushover(string appKey, string defaultSendKey) : this(appKey) /// Send to a specific device /// Priority of the message (optional) default value set to Normal /// If set sends the notification sound + /// Sets the message text style /// - public PushResponse Push(string title, string message, string userKey = "", string device = "", Priority priority = Priority.Normal, NotificationSound notificationSound = NotificationSound.NotSet) + public PushResponse Push(string title, string message, string userKey = "", string device = "", Priority priority = Priority.Normal, NotificationSound notificationSound = NotificationSound.NotSet, MessageStyle messageStyle = MessageStyle.NotSet) { - var args = CreateArgs(title, message, userKey, device, priority, notificationSound); + var args = CreateArgs(title, message, userKey, device, priority, notificationSound, messageStyle); try { return BASE_API_URL.PostToUrl(args).FromJson(); @@ -86,10 +88,11 @@ public PushResponse Push(string title, string message, string userKey = "", stri /// Send to a specific device /// Priority of the message (optional) default value set to Normal /// If set sends the notification sound + /// Sets the message text style /// - public async Task PushAsync(string title, string message, string userKey = "", string device = "", Priority priority = Priority.Normal, NotificationSound notificationSound = NotificationSound.NotSet) + public async Task PushAsync(string title, string message, string userKey = "", string device = "", Priority priority = Priority.Normal, NotificationSound notificationSound = NotificationSound.NotSet, MessageStyle messageStyle = MessageStyle.NotSet) { - var args = CreateArgs(title, message, userKey, device, priority, notificationSound); + var args = CreateArgs(title, message, userKey, device, priority, notificationSound, messageStyle); try { return (await BASE_API_URL.PostToUrlAsync(args)).FromJson(); @@ -101,8 +104,7 @@ public async Task PushAsync(string title, string message, string u } - - private object CreateArgs(string title, string message, string userKey, string device, Priority priority, NotificationSound notificationSound) + private object CreateArgs(string title, string message, string userKey, string device, Priority priority, NotificationSound notificationSound, MessageStyle messageStyle) { // Try the passed user key or fall back to default var userGroupKey = string.IsNullOrEmpty(userKey) ? DefaultUserGroupSendKey : userKey; @@ -127,6 +129,15 @@ private object CreateArgs(string title, string message, string userKey, string d args.sound = notificationSound.ToString().ToLower(); } + if (messageStyle == MessageStyle.html) + { + args.html = "1"; + } + if (messageStyle == MessageStyle.monospace) + { + args.monospace = "1"; + } + return args; } diff --git a/PushoverClient/PushoverClient.csproj b/PushoverClient/PushoverClient.csproj index 9574c56..5869a3e 100644 --- a/PushoverClient/PushoverClient.csproj +++ b/PushoverClient/PushoverClient.csproj @@ -35,9 +35,6 @@ false - - ..\packages\ServiceStack.Text.5.0.2\lib\net45\ServiceStack.Text.dll - @@ -48,6 +45,7 @@ + @@ -56,7 +54,9 @@ - + + 5.0.2 + diff --git a/SendPush/SendPush.csproj b/SendPush/SendPush.csproj index 15a0e54..c24c9a6 100644 --- a/SendPush/SendPush.csproj +++ b/SendPush/SendPush.csproj @@ -35,9 +35,6 @@ 4 - - ..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll - @@ -56,7 +53,6 @@ Designer - @@ -64,6 +60,14 @@ PushoverClient + + + 1.9.71 + + + 1.1.1 + +