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

Pr/250 Expand #250 to Enum #251

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
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
52 changes: 42 additions & 10 deletions SlackAPI/Conversation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,46 @@

namespace SlackAPI
{
public class Conversation
{
public string id;
public DateTime created;
public DateTime last_read;
public bool is_open;
public bool is_starred;
public int unread_count;
public Message latest;
}
public class Conversation
{
public string id;
public DateTime created;
public DateTime last_read;
public bool is_open;
public bool is_starred;
public int unread_count;
public Message latest;

public static string ConversationTypesToQueryParam(ConversationTypes[] types)
{
//Translate the enum user-friendly names to API used names
List<string> typesAsString = new List<string>();
if (types.Contains(ConversationTypes.PublicChannel))
{
typesAsString.Add("public_channel");
}
if (types.Contains(ConversationTypes.PrivateChannel))
{
typesAsString.Add("private_channel");
}
if (types.Contains(ConversationTypes.GroupMessage))
{
typesAsString.Add("mpim");
}
if (types.Contains(ConversationTypes.DirectMessage))
{
typesAsString.Add("im");
}

return string.Join(",", types);
}
}

public enum ConversationTypes
{
PublicChannel, //public_channel
PrivateChannel, //private_channel
GroupMessage, //mpim
DirectMessage //im
}
}
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;
}
}
Loading