Skip to content

Commit

Permalink
Updated the client for cursors to work with email filtering.
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Yeager <[email protected]>
  • Loading branch information
adamyeager committed Aug 31, 2015
1 parent 298ecec commit 707a0c2
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions PushbulletSharp/PushbulletClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -788,15 +788,15 @@ public PushResponseContainer GetPushes(PushResponseFilter filter)
}

string queryString = string.Empty;
List<string> queryStringList = new List<string>();

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<string> queryStringList = new List<string>();

if (filter.ModifiedDate != null)
{
string modifiedDateQueryString = string.Format("modified_after={0}", filter.ModifiedDate.DateTimeToUnixTime());
Expand All @@ -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
Expand Down

0 comments on commit 707a0c2

Please sign in to comment.