Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added conversations.list endpoint functionality and cursor request parameter functionality in base response class. #250

Merged
merged 3 commits into from
Oct 9, 2020
Merged
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
18 changes: 9 additions & 9 deletions SlackAPI.sln
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.4
# Visual Studio Version 16
VisualStudioVersion = 16.0.30320.27
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlackAPI", "SlackAPI\SlackAPI.csproj", "{7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlackAPI.Tests", "SlackAPI.Tests\SlackAPI.Tests.csproj", "{DEFA9559-0F8F-4C38-9644-67A080EDC46D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution items", "Solution items", "{532C9828-A2CC-4281-950A-248B06D42E9C}"
ProjectSection(SolutionItems) = preProject
appveyor.yml = appveyor.yml
build.cake = build.cake
Directory.Build.props = Directory.Build.props
GlobalAssemblyInfo.cs = GlobalAssemblyInfo.cs
README.md = README.md
EndProjectSection
ProjectSection(SolutionItems) = preProject
appveyor.yml = appveyor.yml
build.cake = build.cake
Directory.Build.props = Directory.Build.props
GlobalAssemblyInfo.cs = GlobalAssemblyInfo.cs
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
14 changes: 14 additions & 0 deletions SlackAPI/RPCMessages/ConversationsListResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SlackAPI.RPCMessages
{
[RequestPath("conversations.list")]
public class ConversationsListResponse : Response
{
public Channel[] channels;
}
}
7 changes: 7 additions & 0 deletions SlackAPI/Response.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,12 @@ public void AssertOk()
if (!(ok))
throw new InvalidOperationException(string.Format("An error occurred: {0}", this.error));
}

public ResponseMetaData response_metadata;
}

public class ResponseMetaData
{
public string next_cursor;
}
}
16 changes: 16 additions & 0 deletions SlackAPI/SlackClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,22 @@ public void ChannelsInvite(Action<ChannelInviteResponse> callback, string userId
APIRequestWithToken(callback, parameters.ToArray());
}

public void GetConversationsList(Action<ConversationsListResponse> callback, string cursor = "", bool ExcludeArchived = true, int limit = 100, string[] types = null)
{
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>()
{
Tuple.Create("exclude_archived", ExcludeArchived ? "1" : "0")
};
if (limit > 0)
parameters.Add(Tuple.Create("limit", limit.ToString()));
if (types.Any())
parameters.Add(Tuple.Create("types", string.Join(",", types)));
if (!string.IsNullOrEmpty(cursor))
parameters.Add(Tuple.Create("cursor", cursor));

APIRequestWithToken(callback, parameters.ToArray());
}

public void GetChannelList(Action<ChannelListResponse> callback, bool ExcludeArchived = true)
{
APIRequestWithToken(callback, new Tuple<string, string>("exclude_archived", ExcludeArchived ? "1" : "0"));
Expand Down
16 changes: 16 additions & 0 deletions SlackAPI/SlackTaskClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,22 @@ public Task<ChannelInviteResponse> ChannelsInviteAsync(string userId, string cha
return APIRequestWithTokenAsync<ChannelInviteResponse>(parameters.ToArray());
}

public Task<ConversationsListResponse> GetConversationsListAsync(string cursor = "", bool ExcludeArchived = true, int limit = 100, string[] types = null)
{
List<Tuple<string, string>> parameters = new List<Tuple<string, string>>()
{
Tuple.Create("exclude_archived", ExcludeArchived ? "1" : "0")
};
if (limit > 0)
parameters.Add(Tuple.Create("limit", limit.ToString()));
if (types != null && types.Any())
parameters.Add(Tuple.Create("types", string.Join(",", types)));
if (!string.IsNullOrEmpty(cursor))
parameters.Add(new Tuple<string, string>("cursor", cursor));

return APIRequestWithTokenAsync<ConversationsListResponse>(parameters.ToArray());
}

public Task<ChannelListResponse> GetChannelListAsync(bool ExcludeArchived = true)
{
return APIRequestWithTokenAsync<ChannelListResponse>(new Tuple<string, string>("exclude_archived", ExcludeArchived ? "1" : "0"));
Expand Down