Skip to content

Commit

Permalink
Merge pull request #11 from Elbandi/master
Browse files Browse the repository at this point in the history
Allow set timestamp for messages
  • Loading branch information
danesparza authored Mar 28, 2020
2 parents e324d62 + 352854c commit 02ce6fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions PushoverClient/PushOverRequestArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class PushoverRequestArguments
public string title { get; set; }
public string message { get; set; }
public int priority { get; set; }
public int timestamp { get; set; }
public string sound { get; set; }
}
}
11 changes: 6 additions & 5 deletions PushoverClient/Pushover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public Pushover(string appKey, string defaultSendKey) : this(appKey)
/// <param name="priority">Priority of the message (optional) default value set to Normal</param>
/// <param name="notificationSound">If set sends the notification sound</param>
/// <returns></returns>
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, DateTime? timestamp = null, NotificationSound notificationSound = NotificationSound.NotSet)
{
var args = CreateArgs(title, message, userKey, device, priority, notificationSound);
var args = CreateArgs(title, message, userKey, device, priority, timestamp ?? DateTime.UtcNow, notificationSound);
try
{
return BASE_API_URL.PostToUrl(args).FromJson<PushResponse>();
Expand All @@ -87,9 +87,9 @@ public PushResponse Push(string title, string message, string userKey = "", stri
/// <param name="priority">Priority of the message (optional) default value set to Normal</param>
/// <param name="notificationSound">If set sends the notification sound</param>
/// <returns></returns>
public async Task<PushResponse> PushAsync(string title, string message, string userKey = "", string device = "", Priority priority = Priority.Normal, NotificationSound notificationSound = NotificationSound.NotSet)
public async Task<PushResponse> PushAsync(string title, string message, string userKey = "", string device = "", Priority priority = Priority.Normal, DateTime? timestamp = null, NotificationSound notificationSound = NotificationSound.NotSet)
{
var args = CreateArgs(title, message, userKey, device, priority, notificationSound);
var args = CreateArgs(title, message, userKey, device, priority, timestamp?? DateTime.UtcNow, notificationSound);
try
{
return (await BASE_API_URL.PostToUrlAsync(args)).FromJson<PushResponse>();
Expand All @@ -102,7 +102,7 @@ public async Task<PushResponse> 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, DateTime timestamp, NotificationSound notificationSound)
{
// Try the passed user key or fall back to default
var userGroupKey = string.IsNullOrEmpty(userKey) ? DefaultUserGroupSendKey : userKey;
Expand All @@ -119,6 +119,7 @@ private object CreateArgs(string title, string message, string userKey, string d
device = device,
title = title,
message = message,
timestamp = (int)timestamp.Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
priority = (int)priority
};

Expand Down

0 comments on commit 02ce6fe

Please sign in to comment.