Skip to content

Commit

Permalink
fix: filter by activity done
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidRouyer committed Jan 8, 2019
1 parent ec9fdef commit f4f1803
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 16 deletions.
16 changes: 11 additions & 5 deletions src/Pipedrive.net.Tests/Clients/ActivitiesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public async Task RequestsCorrectUrl()
PageSize = 1,
PageCount = 1,
StartPage = 0,
Done = ActivityDone.Done,
};

await client.GetAll(filters);
Expand All @@ -46,8 +47,9 @@ public async Task RequestsCorrectUrl()
{
await connection.GetAll<Activity>(
Arg.Is<Uri>(u => u.ToString() == "activities"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 1
&& d["user_id"] == "0"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["user_id"] == "0"
&& d["done"] == "1"),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
Expand Down Expand Up @@ -77,6 +79,7 @@ public async Task RequestsCorrectUrl()
PageSize = 1,
PageCount = 1,
StartPage = 0,
Done = ActivityDone.Done,
};

await client.GetAllForCurrent(filters);
Expand All @@ -85,7 +88,8 @@ public async Task RequestsCorrectUrl()
{
await connection.GetAll<Activity>(
Arg.Is<Uri>(u => u.ToString() == "activities"),
Arg.Is<Dictionary<string,string>>(d => d.Count == 0),
Arg.Is<Dictionary<string,string>>(d => d.Count == 1
&& d["done"] == "1"),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
Expand Down Expand Up @@ -115,6 +119,7 @@ public async Task RequestsCorrectUrl()
PageSize = 1,
PageCount = 1,
StartPage = 0,
Done = ActivityDone.Done,
};

await client.GetAllForUserId(123, filters);
Expand All @@ -123,8 +128,9 @@ public async Task RequestsCorrectUrl()
{
await connection.GetAll<Activity>(
Arg.Is<Uri>(u => u.ToString() == "activities"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 1
&& d["user_id"] == "123"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["user_id"] == "123"
&& d["done"] == "1"),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
Expand Down
24 changes: 16 additions & 8 deletions src/Pipedrive.net.Tests/Clients/DealsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public async Task RequestsCorrectUrl()
PageSize = 1,
PageCount = 1,
StartPage = 0,
Status = DealStatus.lost,
};

await client.GetAll(filters);
Expand All @@ -47,8 +48,9 @@ public async Task RequestsCorrectUrl()
{
await connection.GetAll<Deal>(
Arg.Is<Uri>(u => u.ToString() == "deals"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 1
&& d["owned_by_you"] == "0"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["owned_by_you"] == "0"
&& d["status"] == "lost"),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
Expand Down Expand Up @@ -78,6 +80,7 @@ public async Task RequestsCorrectUrl()
PageSize = 1,
PageCount = 1,
StartPage = 0,
Status = DealStatus.lost,
};

await client.GetAllForCurrent(filters);
Expand All @@ -86,8 +89,9 @@ public async Task RequestsCorrectUrl()
{
await connection.GetAll<Deal>(
Arg.Is<Uri>(u => u.ToString() == "deals"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 1
&& d["owned_by_you"] == "1"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["owned_by_you"] == "1"
&& d["status"] == "lost"),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
Expand Down Expand Up @@ -117,6 +121,7 @@ public async Task RequestsCorrectUrl()
PageSize = 1,
PageCount = 1,
StartPage = 0,
Status = DealStatus.lost,
};

await client.GetAllForUserId(123, filters);
Expand All @@ -125,8 +130,9 @@ public async Task RequestsCorrectUrl()
{
await connection.GetAll<Deal>(
Arg.Is<Uri>(u => u.ToString() == "deals"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 1
&& d["user_id"] == "123"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["user_id"] == "123"
&& d["status"] == "lost"),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
Expand Down Expand Up @@ -317,6 +323,7 @@ public async Task RequestsCorrectUrl()
PageSize = 1,
PageCount = 1,
StartPage = 0,
Done = ActivityDone.Done,
};

await client.GetActivities(123, filters);
Expand All @@ -325,8 +332,9 @@ public async Task RequestsCorrectUrl()
{
await connection.GetAll<Activity>(
Arg.Is<Uri>(u => u.ToString() == "deals/123/activities"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 1
&& d["id"] == "123"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["id"] == "123"
&& d["done"] == "1"),
Arg.Is<ApiOptions>(o => o.PageSize == 1
&& o.PageCount == 1
&& o.StartPage == 0)
Expand Down
1 change: 0 additions & 1 deletion src/Pipedrive.net.Tests/Clients/FilesClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using NSubstitute;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Xunit;

Expand Down
2 changes: 1 addition & 1 deletion src/Pipedrive.net/Models/Request/ActivityFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public IDictionary<string, string> Parameters
}
if (Done.HasValue)
{
d.Add("done", Done.Value.ToString());
d.Add("done", ((int)Done.Value).ToString());
}
return d;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Pipedrive.net/Models/Request/DealActivityFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public IDictionary<string, string> Parameters
var d = new Dictionary<string, string>();
if (Done.HasValue)
{
d.Add("done", Done.Value.ToString());
d.Add("done", ((int)Done.Value).ToString());
}
if (!string.IsNullOrWhiteSpace(Exclude))
{
Expand Down

0 comments on commit f4f1803

Please sign in to comment.