Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,23 @@ String scroll_param_value = users.scroll_param;
Users users = usersClient.Scroll(scroll_param_value);
```

**List users with Pagination using Pages**
```cs
Pages page = new Pages()
{
page = 1,
per_page = 10,
}
Users users = usersClient.Next(page);
```

**List users with Pagination**
```cs
Users users = usersClient.Next();

Users users = usersClient.Next(1, 50, OrderBy.Desc, UserSortBy.created_at);
```

**Delete a user**
```cs
usersClient.Archive("100300231"); // with intercom generated user's id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<ReleaseVersion>2.0.0</ReleaseVersion>
<ReleaseVersion>2.1.1</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Intercom.Tests/Clients/UserClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class UserClientTest : TestBase

public UserClientTest()
{
this.usersClient = new UsersClient(new Authentication(AppId, AppKey));
usersClient = new UsersClient(new Authentication(AppId, AppKey));
}

[Test()]
Expand Down
2 changes: 1 addition & 1 deletion src/Intercom.Tests/Intercom.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<ReleaseVersion>2.0.0</ReleaseVersion>
<ReleaseVersion>2.1.1</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
36 changes: 26 additions & 10 deletions src/Intercom/Clients/UsersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace Intercom.Clients
{
public class UsersClient : Client
{
// TODO: Implement paging
private static class UserSortBy
{
public const String created_at = "created_at";
Expand Down Expand Up @@ -166,21 +165,38 @@ public Users List()

public Users List(Dictionary<String, String> parameters)
{
ClientResponse<Users> result = null;
result = Get<Users>(parameters: parameters);
return result.Result;
return ListUsersFromParams(parameters);
}

// TODO: Implement paging (by Pages argument)
private Users Next(Pages pages)
public Users Next(Pages pages)
{
return null;
Dictionary<String, String> parameters = new Dictionary<String, String>();

parameters.Add("page", pages.page.ToString());
parameters.Add("per_page", pages.per_page.ToString());
parameters.Add("order", OrderBy.Desc.ToString());
parameters.Add("sort", UserSortBy.created_at.ToString());

return ListUsersFromParams(parameters);
}

// TODO: Implement paging
private Users Next(int page = 1, int perPage = 50, OrderBy orderBy = OrderBy.Dsc, String sortBy = UserSortBy.created_at)
public Users Next(int page = 1, int perPage = 50, OrderBy orderBy = OrderBy.Desc, String sortBy = UserSortBy.created_at)
{
return null;
Dictionary<String, String> parameters = new Dictionary<String, String>();

parameters.Add("page", page.ToString());
parameters.Add("per_page", perPage.ToString());
parameters.Add("order", orderBy.ToString().ToLower());
parameters.Add("sort", sortBy.ToString());

return ListUsersFromParams(parameters);
}

private Users ListUsersFromParams(Dictionary<String, String> parameters)
{
ClientResponse<Users> result = null;
result = Get<Users>(parameters: parameters);
return result.Result;
}

public Users Scroll(String scrollParam = null)
Expand Down
2 changes: 1 addition & 1 deletion src/Intercom/Enums/OrderBy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ namespace Intercom.Core
public enum OrderBy
{
Asc,
Dsc
Desc
}
}
2 changes: 1 addition & 1 deletion src/Intercom/Intercom.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ReleaseVersion>2.0.0</ReleaseVersion>
<ReleaseVersion>2.1.1</ReleaseVersion>
<PackageId>Intercom.Dotnet.Client</PackageId>
<PackageIconUrl>https://raw.githubusercontent.com/intercom/intercom-dotnet/master/src/assets/Intercom.png</PackageIconUrl>
<Owners>Intercom</Owners>
Expand Down
2 changes: 1 addition & 1 deletion src/Intercom/intercom.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>Intercom.Dotnet.Client</id>
<title>Intercom Dotnet Client</title>
<version>2.0.0</version>
<version>2.1.1</version>
<authors>Intercom</authors>
<owners>Intercom</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
Expand Down