From 707a0c238fda5e0f4ae5de1c580784ea4a5a5bf5 Mon Sep 17 00:00:00 2001 From: Adam Yeager Date: Mon, 31 Aug 2015 08:51:02 -0400 Subject: [PATCH] Updated the client for cursors to work with email filtering. Signed-off-by: Adam Yeager --- PushbulletSharp/PushbulletClient.cs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/PushbulletSharp/PushbulletClient.cs b/PushbulletSharp/PushbulletClient.cs index a0d6c13..2529901 100644 --- a/PushbulletSharp/PushbulletClient.cs +++ b/PushbulletSharp/PushbulletClient.cs @@ -788,15 +788,15 @@ public PushResponseContainer GetPushes(PushResponseFilter filter) } string queryString = string.Empty; + List queryStringList = new List(); - if(!string.IsNullOrWhiteSpace(filter.Cursor)) + if (!string.IsNullOrWhiteSpace(filter.Cursor)) { - queryString = string.Concat("?cursor=", filter.Cursor); + string cursorQueryString = string.Format("cursor={0}", filter.Cursor); + queryStringList.Add(cursorQueryString); } else { - List queryStringList = new List(); - if (filter.ModifiedDate != null) { string modifiedDateQueryString = string.Format("modified_after={0}", filter.ModifiedDate.DateTimeToUnixTime()); @@ -808,17 +808,19 @@ public PushResponseContainer GetPushes(PushResponseFilter filter) string activeQueryString = string.Format("active={0}", (bool)filter.Active); queryStringList.Add(activeQueryString); } + } - if(!string.IsNullOrWhiteSpace(filter.Email)) - { - string emailQueryString = string.Format("email={0}", filter.Email); - queryStringList.Add(emailQueryString); - } + //Email filtering can be done on either cursor or regular queries + if (!string.IsNullOrWhiteSpace(filter.Email)) + { + string emailQueryString = string.Format("email={0}", filter.Email); + queryStringList.Add(emailQueryString); + } - if (queryStringList.Count() > 0) - { - queryString = string.Concat("?", string.Join("&", queryStringList)); - } + //Join all of the query strings + if (queryStringList.Count() > 0) + { + queryString = string.Concat("?", string.Join("&", queryStringList)); } #endregion