diff --git a/.gitignore b/.gitignore index 8e281d6..5b625ec 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ local.properties .classpath .settings/ .loadpath +.vs # External tool builders .externalToolBuilders/ diff --git a/Attachment.cs b/Attachment.cs deleted file mode 100644 index 2274dfd..0000000 --- a/Attachment.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace SlackAPI -{ - //See: https://api.slack.com/docs/attachments - public class Attachment - { - public string fallback; - public string color; - public string pretext; - public string author_name; - public string author_link; - public string author_icon; - public string title; - public string title_link; - public string text; - public Field[] fields; - - public string image_url; - public string thumb_url; - public string[] mrkdwn_in; - } - - public class Field{ - public string title; - public string value; - public bool @short; - } -} diff --git a/Channel.cs b/Channel.cs deleted file mode 100644 index 7335e8b..0000000 --- a/Channel.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI -{ - public class Channel : Conversation - { - public string name; - public string creator; - - public bool is_archived; - public bool is_member; - public bool is_general; - public bool is_channel; - public bool is_group; - //Is this deprecated by is_open? - public bool IsPrivateGroup { get { return id != null && id[0] == 'G'; } } - - public int num_members; - public OwnedStampedMessage topic; - public OwnedStampedMessage purpose; - - public string[] members; - } -} diff --git a/Conversation.cs b/Conversation.cs deleted file mode 100644 index def8d1a..0000000 --- a/Conversation.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -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; - } -} diff --git a/DirectMessageConversation.cs b/DirectMessageConversation.cs deleted file mode 100644 index 2241fe6..0000000 --- a/DirectMessageConversation.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI -{ - public class DirectMessageConversation : Conversation - { - public string user; - public bool is_user_deleted; - } -} diff --git a/IntegrationTest/Connect.cs b/IntegrationTest/Connect.cs index e4aa7c2..7b31ac6 100644 --- a/IntegrationTest/Connect.cs +++ b/IntegrationTest/Connect.cs @@ -6,6 +6,7 @@ using IntegrationTest.Helpers; using Polly; using SlackAPI.WebSocketMessages; +using SlackAPI.Models; namespace IntegrationTest { @@ -36,7 +37,7 @@ public void TestGetAccessToken() var authCode = _config.Slack.AuthCode; // act - var accessTokenResponse = GetAccessToken(clientId, clientSecret, "", authCode); + var accessTokenResponse = GetAccessToken(clientId, clientSecret, string.Empty, authCode); // assert Assert.IsNotNull(accessTokenResponse, "accessTokenResponse != null"); @@ -85,7 +86,7 @@ public void TestConnectPostAndDelete() // then Assert.IsNotNull(deletedResponse, "No response was found"); - Assert.IsTrue(deletedResponse.ok, "Message not deleted!"); + Assert.IsTrue(deletedResponse.Ok, "Message not deleted!"); Assert.AreEqual(channel, deletedResponse.channel, "Got invalid channel? Something's not right here..."); Assert.AreEqual(messageTimestamp, deletedResponse.ts, "Got invalid time stamp? Something's not right here..."); } diff --git a/IntegrationTest/Helpers/ClientHelper.cs b/IntegrationTest/Helpers/ClientHelper.cs index 662c270..fb74e5e 100644 --- a/IntegrationTest/Helpers/ClientHelper.cs +++ b/IntegrationTest/Helpers/ClientHelper.cs @@ -13,7 +13,7 @@ public static SlackSocketClient GetClient(string authToken) var wait = new EventWaitHandle(false, EventResetMode.ManualReset); var client = new SlackSocketClient(authToken); - client.Connect(x => + client.Connect((x,sc) => { Console.WriteLine("RTM Start"); }, () => diff --git a/IntegrationTest/Helpers/SlackMother.cs b/IntegrationTest/Helpers/SlackMother.cs index bd10870..5204e48 100644 --- a/IntegrationTest/Helpers/SlackMother.cs +++ b/IntegrationTest/Helpers/SlackMother.cs @@ -1,27 +1,28 @@ -namespace IntegrationTest.Helpers -{ - using SlackAPI; +using SlackAPI; +using SlackAPI.Models; +namespace IntegrationTest.Helpers +{ public class SlackMother { public static Attachment[] SomeAttachments => new[] { new Attachment() { - fallback = "Required plain-text summary of the attachment.", - color = "#36a64f", - pretext = "Optional text that appears above the attachment block", - author_name = "Bobby Tables", - author_link = "http://flickr.com/bobby/", - author_icon = "http://flickr.com/icons/bobby.jpg", - title = "Slack API Documentation", - title_link = "https://api.slack.com/", - text = "Optional text that appears within the attachment", - fields = new[] + Fallback = "Required plain-text summary of the attachment.", + Color = "#36a64f", + Pretext = "Optional text that appears above the attachment block", + AuthorName = "Bobby Tables", + AuthorLink = "http://flickr.com/bobby/", + AuthorIcon = "http://flickr.com/icons/bobby.jpg", + Title = "Slack API Documentation", + TitleLink = "https://api.slack.com/", + Text = "Optional text that appears within the attachment", + Fields = new[] { - new Field() { title = "Priority", value = "High", @short = false }, - new Field() { title = "Priority", value = "High", @short = true }, - new Field() { title = "Priority", value = "High", @short = true } + new Field() { Title = "Priority", Value = "High", IsShort = false }, + new Field() { Title = "Priority", Value = "High", IsShort = true }, + new Field() { Title = "Priority", Value = "High", IsShort = true } } } }; diff --git a/IntegrationTest/JoinDirectMessageChannel.cs b/IntegrationTest/JoinDirectMessageChannel.cs index 4b14d24..7cb659f 100644 --- a/IntegrationTest/JoinDirectMessageChannel.cs +++ b/IntegrationTest/JoinDirectMessageChannel.cs @@ -25,14 +25,14 @@ public void ShouldJoinDirectMessageChannel() var client = ClientHelper.GetClient(_config.Slack.UserAuthToken); string userName = _config.Slack.DirectMessageUser; - string user = client.Users.First(x => x.name.Equals(userName, StringComparison.InvariantCultureIgnoreCase)).id; + string user = client.Users.First(x => x.Name.Equals(userName, StringComparison.InvariantCultureIgnoreCase)).Id; // when EventWaitHandle wait = new EventWaitHandle(false, EventResetMode.ManualReset); client.JoinDirectMessageChannel(response => { - Assert.IsTrue(response.ok, "Error while joining user channel"); - Assert.IsTrue(!string.IsNullOrEmpty(response.channel.id), "We expected a channel id to be returned"); + Assert.IsTrue(response.Ok, "Error while joining user channel"); + Assert.IsTrue(!string.IsNullOrEmpty(response.channel.Id), "We expected a channel id to be returned"); wait.Set(); }, user); diff --git a/IntegrationTest/PostMessage.cs b/IntegrationTest/PostMessage.cs index 4d76c63..f135340 100644 --- a/IntegrationTest/PostMessage.cs +++ b/IntegrationTest/PostMessage.cs @@ -9,7 +9,7 @@ namespace IntegrationTest { using SlackAPI; - + using SlackAPI.Models; [TestClass] public class PostMessage { @@ -41,7 +41,7 @@ public void SimpleMessageDelivery() } // then - Assert.IsTrue(actual.ok, "Error while posting message to channel. "); + Assert.IsTrue(actual.Ok, "Error while posting message to channel. "); Assert.AreEqual(actual.message.text, "Hi there!"); Assert.AreEqual(actual.message.type, "message"); } @@ -68,7 +68,7 @@ public void Attachments() } // then - Assert.IsTrue(actual.ok, "Error while posting message to channel. "); + Assert.IsTrue(actual.Ok, "Error while posting message to channel. "); } } } \ No newline at end of file diff --git a/IntegrationTest/Update.cs b/IntegrationTest/Update.cs index 742ad92..2856b87 100644 --- a/IntegrationTest/Update.cs +++ b/IntegrationTest/Update.cs @@ -6,7 +6,7 @@ namespace IntegrationTest { using SlackAPI; - + using SlackAPI.Models; [TestClass] public class Update { @@ -42,7 +42,7 @@ public void SimpleUpdate() } // then - Assert.IsTrue(actual.ok, "Error while posting message to channel. "); + Assert.IsTrue(actual.Ok, "Error while posting message to channel. "); Assert.AreEqual(actual.message.text, "[changed]"); Assert.AreEqual(actual.message.type, "message"); } @@ -56,7 +56,7 @@ private string PostedMessage(SlackSocketClient client) response => { messageId = response.ts; - Assert.IsTrue(response.ok, "Error while posting message to channel. "); + Assert.IsTrue(response.Ok, "Error while posting message to channel. "); sync.Proceed(); }, _config.Slack.TestChannel, diff --git a/JavascriptBotsToArray.cs b/JavascriptBotsToArray.cs index c8d0a38..f4da312 100644 --- a/JavascriptBotsToArray.cs +++ b/JavascriptBotsToArray.cs @@ -1,4 +1,5 @@ -using System; +using SlackAPI.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/Models/Attachment.cs b/Models/Attachment.cs new file mode 100644 index 0000000..58f8899 --- /dev/null +++ b/Models/Attachment.cs @@ -0,0 +1,173 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace SlackAPI.Models +{ + /// + /// See: https://api.slack.com/docs/attachments + /// + public class Attachment + { + /// + /// Provide this attachment with a visual header by providing a short string here. + /// + [JsonProperty(PropertyName = "title")] + public string Title { get; set; } + + [JsonProperty("text", NullValueHandling = NullValueHandling.Ignore)] + public string Text { get; set; } + + /// + /// A plaintext message displayed to users using an interface that does not support attachments or interactive messages. + /// Consider leaving a URL pointing to your service if the potential message actions are representable outside of Slack. + /// Otherwise, let folks know what they are missing. + /// + [JsonProperty("fallback", NullValueHandling = NullValueHandling.Ignore)] + public string Fallback { get; set; } + + /// + /// The provided string will act as a unique identifier for the collection of buttons within the attachment. + /// It will be sent back to your message button action URL with each invoked action. This field is required + /// when the attachment contains message buttons. It is key to identifying the interaction you're working with. + /// + [JsonProperty("callback_id", NullValueHandling = NullValueHandling.Ignore)] + public string CallbackId { get; set; } + + /// + /// Used to visually distinguish an attachment from other messages. Accepts hex values and a few named colors as + /// documented in attaching content to messages. Use sparingly and according to best practices. + /// + [JsonProperty("color", NullValueHandling = NullValueHandling.Ignore)] + public string Color { get; set; } + + [JsonProperty("pretext", NullValueHandling = NullValueHandling.Ignore)] + public string Pretext { get; set; } + + [JsonProperty("author_name", NullValueHandling = NullValueHandling.Ignore)] + public string AuthorName { get; set; } + + [JsonProperty("author_link", NullValueHandling = NullValueHandling.Ignore)] + public string AuthorLink { get; set; } + + [JsonProperty("author_icon", NullValueHandling = NullValueHandling.Ignore)] + public string AuthorIcon { get; set; } + + [JsonProperty("title_link", NullValueHandling = NullValueHandling.Ignore)] + public string TitleLink { get; set; } + + [JsonProperty("fields", NullValueHandling = NullValueHandling.Ignore)] + public Field[] Fields { get; set; } + + [JsonProperty("image_url", NullValueHandling = NullValueHandling.Ignore)] + public string ImageUrl { get; set; } + + [JsonProperty("thumb_url", NullValueHandling = NullValueHandling.Ignore)] + public string ThumbUrl { get; set; } + + [JsonProperty("mrkdwn_in", NullValueHandling = NullValueHandling.Ignore)] + public string[] MrkdwnIn { get; set; } + + [JsonProperty("attachment_type", NullValueHandling = NullValueHandling.Ignore)] + public string AttachmentType { get; set; } + + /// + /// A collection of actions (buttons) to include in the attachment. Required when using message buttons and otherwise not useful. + /// A maximum of 5 actions may be provided. + /// + [JsonProperty("actions", NullValueHandling = NullValueHandling.Ignore)] + public ActionField[] Actions { get; set; } + } + + public class Field + { + [JsonProperty(PropertyName = "title")] + public string Title { get; set; } + + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + [JsonProperty(PropertyName = "short")] + public bool IsShort { get; set; } + } + + /// + /// https://api.slack.com/docs/message-buttons#actioin_fields + /// + public class ActionField + { + /// + /// Provide a string to give this specific action a name. The name will be returned to your Action URL along + /// with the message's callback_id when this action is invoked. Use it to identify this particular response path. + /// If multiple actions share the same name, only one of them can be in a triggered state. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// The user-facing label for the message button representing this action. + /// Cannot contain markup. Best to keep these short and decisive. + /// + [JsonProperty(PropertyName = "text")] + public string Text { get; set; } + + /// + /// Your buttons can have a little extra visual importance added to them, which is especially useful when providing logical default action or highlighting something destructive. + /// default — Yes, it's the default. Buttons will look simple. + /// primary — Use this sparingly, when the button represents a key action to accomplish. You should probably only ever have one primary button within a set. + /// danger — Use this when the consequence of the button click will result in the destruction of something, like a piece of data stored on your servers. Use even more sparingly than primary. + /// + [JsonProperty(PropertyName = "style")] + public string Style { get; set; } + + /// + /// Provide nothing but button here. There are no other types of actions today. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } = "button"; + + /// + /// Provide a string identifying this specific action. It will be sent to your Action URL along with the name and attachment's callback_id. + /// If providing multiple actions with the same name, value can be strategically used to differentiate intent. + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + /// + /// If you provide a JSON hash of confirmation fields, your button will pop up dialog with your indicated text and choices, + /// giving them one last chance to avoid a destructive action or other undesired outcome. + /// + [JsonProperty(PropertyName = "confirm")] + public ConfirmationField Confirm { get; set; } + } + + /// + /// https://api.slack.com/docs/message-buttons#confirmation_fields + /// + public class ConfirmationField + { + /// + /// Title the pop up window. Please be brief. + /// + [JsonProperty(PropertyName = "title")] + public string Title { get; set; } + + /// + /// Describe in detail the consequences of the action and contextualize your button text choices. + /// Required + /// + [JsonProperty(PropertyName = "text")] + public string Text { get; set; } + + /// + /// The text label for the button to continue with an action. Keep it short. Defaults to Okay. + /// + [JsonProperty(PropertyName = "ok_text")] + public string OkText { get; set; } + + /// + /// The text label for the button to cancel the action. Keep it short. Defaults to Cancel. + /// + [JsonProperty(PropertyName = "dismiss_text")] + public string DismissText { get; set; } + } +} diff --git a/Bot.cs b/Models/Bot.cs similarity index 94% rename from Bot.cs rename to Models/Bot.cs index 4c6f900..50d46f9 100644 --- a/Bot.cs +++ b/Models/Bot.cs @@ -1,6 +1,6 @@ using System; -namespace SlackAPI +namespace SlackAPI.Models { public class Bot { diff --git a/Models/Channel.cs b/Models/Channel.cs new file mode 100644 index 0000000..231dccf --- /dev/null +++ b/Models/Channel.cs @@ -0,0 +1,70 @@ +using Newtonsoft.Json; +using System; + +namespace SlackAPI.Models +{ + /// + /// https://api.slack.com/types/channel + /// + public class Channel : Conversation + { + [JsonProperty(PropertyName = "is_channel")] + public bool IsChannel { get; set; } + + /// + /// Is the user ID of the member that created this private channel. + /// + [JsonProperty(PropertyName = "creator")] + public string CreatorUserId { get; set; } + + /// + /// Will be true if the channel is archived. + /// + [JsonProperty(PropertyName = "is_archived")] + public bool IsArchived { get; set; } + + [JsonProperty(PropertyName = "is_mpim")] + public bool IsMpim { get; set; } + + /// + /// Is a list of user ids for all users in this channel. + /// This includes any disabled accounts that were in this channel when they were disabled. + /// + [JsonProperty(PropertyName = "members")] + public string[] Members { get; set; } + + /// + /// Will be true if the calling member is part of the channel. + /// + [JsonProperty(PropertyName = "is_member")] + public bool IsMember { get; set; } + + /// + /// Will be true if this channel is the "general" channel that includes all regular team members. + /// In most teams this is called #general but some teams have renamed it. + /// + [JsonProperty(PropertyName = "is_general")] + public bool IsGeneral { get; set; } + + [JsonProperty(PropertyName = "is_group")] + public bool IsGroup { get; set; } + + [Obsolete] + [JsonProperty(PropertyName = "num_members")] + public int NumMembers { get; set; } + + /// + /// Provide information about the channel topic + /// + [JsonProperty(PropertyName = "topic")] + public OwnedStampedMessage Topic { get; set; } + + /// + /// Provide information about the channel purpose + /// + [JsonProperty(PropertyName = "purpose")] + public OwnedStampedMessage Purpose { get; set; } + + public override SlackChannelType Type { get { return IsChannel ? SlackChannelType.Channel : SlackChannelType.Group; } } + } +} diff --git a/ContextMessage.cs b/Models/ContextMessage.cs similarity index 78% rename from ContextMessage.cs rename to Models/ContextMessage.cs index 764c17a..ae43ab4 100644 --- a/ContextMessage.cs +++ b/Models/ContextMessage.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { public class ContextMessage : Message { diff --git a/Models/Conversation.cs b/Models/Conversation.cs new file mode 100644 index 0000000..852ee3c --- /dev/null +++ b/Models/Conversation.cs @@ -0,0 +1,47 @@ +using Newtonsoft.Json; +using System; + +namespace SlackAPI.Models +{ + /// + /// Base class from all slack conversations + /// + public class Conversation + { + /// + /// Is the ID of the channel, private group or DM channel. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + [JsonProperty(PropertyName = "created")] + public DateTime Created { get; set; } + + [JsonProperty(PropertyName = "has_pins")] + public bool HasPins { get; set; } + + [Obsolete] + [JsonProperty(PropertyName = "is_starred")] + public bool IsStarred { get; set; } + + [JsonProperty(PropertyName = "is_open")] + public bool IsOpen { get; set; } + + [JsonProperty(PropertyName = "last_read")] + public DateTime LastRead { get; set; } + + [JsonProperty(PropertyName = "latest")] + public Message Latest { get; set; } + + [JsonProperty(PropertyName = "unread_count")] + public int UnreadCount { get; set; } + + [JsonProperty(PropertyName = "unread_count_display")] + public string UnreadCountDisplay { get; set; } + + public string Name { get; set; } + + public virtual SlackChannelType Type { get; } + + } +} diff --git a/Models/DirectMessage.cs b/Models/DirectMessage.cs new file mode 100644 index 0000000..d59de48 --- /dev/null +++ b/Models/DirectMessage.cs @@ -0,0 +1,28 @@ +using Newtonsoft.Json; +using System; + +namespace SlackAPI.Models +{ + /// + /// https://api.slack.com/types/im + /// + public class DirectMessage : Conversation + { + /// + /// The user property is the ID of the user speaking + /// + [JsonProperty(PropertyName = "user")] + public string UserId { get; set; } + + [JsonProperty(PropertyName = "is_im")] + public bool IsIm { get; set; } + + [JsonProperty(PropertyName = "is_org_shared")] + public bool IsOrgShared { get; set; } + + [JsonProperty(PropertyName = "is_user_deleted")] + public bool IsUserDeleted { get; set; } + + public override SlackChannelType Type { get; } = SlackChannelType.DirectMessage; + } +} diff --git a/File.cs b/Models/File.cs similarity index 98% rename from File.cs rename to Models/File.cs index 3f1dd33..1575b4e 100644 --- a/File.cs +++ b/Models/File.cs @@ -1,6 +1,6 @@ using System; -namespace SlackAPI +namespace SlackAPI.Models { //TODO: See below: /// diff --git a/Message.cs b/Models/Message.cs similarity index 83% rename from Message.cs rename to Models/Message.cs index d829245..24da721 100644 --- a/Message.cs +++ b/Models/Message.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using SlackAPI.Models; namespace SlackAPI { diff --git a/OwnedStampedMessage.cs b/Models/OwnedStampedMessage.cs similarity index 51% rename from OwnedStampedMessage.cs rename to Models/OwnedStampedMessage.cs index d756e4b..0eecc17 100644 --- a/OwnedStampedMessage.cs +++ b/Models/OwnedStampedMessage.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { public class OwnedStampedMessage { diff --git a/Preferences.cs b/Models/Preferences.cs similarity index 97% rename from Preferences.cs rename to Models/Preferences.cs index 92f48a5..ed71ef6 100644 --- a/Preferences.cs +++ b/Models/Preferences.cs @@ -1,6 +1,4 @@ -using System; - -namespace SlackAPI +namespace SlackAPI.Models { public class Preferences { @@ -53,7 +51,7 @@ public class Preferences public bool mark_msgs_read_immediately; public string tz; public string emoji_mode; - public string highlight_words; + public string hightlight_words; //public string newxp_slackbot_step; //I don't even... public SearchSort search_sort; public string push_loud_channels; diff --git a/Reaction.cs b/Models/Reaction.cs similarity index 86% rename from Reaction.cs rename to Models/Reaction.cs index 5cae709..714b937 100644 --- a/Reaction.cs +++ b/Models/Reaction.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace SlackAPI +namespace SlackAPI.Models { public class Reaction { diff --git a/Models/ReactionAddedResponse.cs b/Models/ReactionAddedResponse.cs new file mode 100644 index 0000000..9b0b364 --- /dev/null +++ b/Models/ReactionAddedResponse.cs @@ -0,0 +1,8 @@ +namespace SlackAPI.Models +{ + [RequestPath("reactions.add")] + public class ReactionAddedResponse : Response + { + + } +} diff --git a/Models/Response.cs b/Models/Response.cs new file mode 100644 index 0000000..c4eb44b --- /dev/null +++ b/Models/Response.cs @@ -0,0 +1,103 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System; +using System.Runtime.Serialization; + +namespace SlackAPI.Models +{ + public abstract class Response + { + /// + /// Should always be checked before trying to process a response. + /// + [JsonProperty(PropertyName = "ok")] + public bool Ok { get; set; } + + /// + /// if ok is false, then this is the reason-code + /// + [JsonProperty(PropertyName = "error")] + [JsonConverter(typeof(StringEnumConverter))] + public ReasonCode Error { get; set;} + + /// + /// This table lists the expected warnings that this method will return. + /// However, other warnings can be returned in the case where the service is experiencing unexpected trouble. + /// + [JsonProperty(PropertyName = "warning")] + public string Warning { get; set; } + + public void AssertOk() + { + if (!(Ok)) + throw new InvalidOperationException(string.Format("An error occurred: {0}", Error)); + } + } + + /// + /// From : https://api.slack.com/methods/rtm.start + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ReasonCode + { + /// + /// Team is being migrated between servers. See the team_migration_started event documentation for details. + /// + [EnumMember(Value = "migration_in_progress")] + MigrationInProgress, + /// + /// No authentication token provided. + /// + [EnumMember(Value = "not_authed")] + NotAuthed, + /// + /// Invalid authentication token. + /// + [EnumMember(Value = "invalid_auth")] + InvalidAuth, + /// + /// Authentication token is for a deleted user or team. + /// + [EnumMember(Value = "account_inactive")] + AccountInactive, + /// + /// The method was passed an argument whose name falls outside the bounds of common decency. + /// This includes very long names and names with non-alphanumeric characters other than _. + /// If you get this error, it is typically an indication that you have made a very malformed API call. + /// + [EnumMember(Value = "invalid_arg_name")] + InvalidArgName, + /// + /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. + /// + [EnumMember(Value = "invalid_array_arg")] + InvalidArrayArg, + /// + /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. + /// + [EnumMember(Value = "invalid_charset")] + InvalidCharset, + /// + /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, + /// but the form data was either missing or syntactically invalid. + /// + [EnumMember(Value = "invalid_form_data")] + InvalidFormData, + /// + /// The method was called via a POST request, but the specified Content-Type was invalid. + /// Valid types are: application/json application/x-www-form-urlencoded multipart/form-data text/plain. + /// + [EnumMember(Value = "invalid_post_type")] + InvalidPostType, + /// + /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. + /// + [EnumMember(Value = "missing_post_type")] + MissingPostType, + /// + /// The method was called via a POST request, but the POST data was either missing or truncated. + /// + [EnumMember(Value = "request_timeout")] + RequestTimeout, + } +} diff --git a/Models/SlackChannelType.cs b/Models/SlackChannelType.cs new file mode 100644 index 0000000..46f211a --- /dev/null +++ b/Models/SlackChannelType.cs @@ -0,0 +1,10 @@ +namespace SlackAPI.Models +{ + public enum SlackChannelType + { + Channel, + Group, + DirectMessage + } + +} diff --git a/SlackScope.cs b/Models/SlackScope.cs similarity index 58% rename from SlackScope.cs rename to Models/SlackScope.cs index 3819c05..f35b8e9 100644 --- a/SlackScope.cs +++ b/Models/SlackScope.cs @@ -1,10 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace SlackAPI +namespace SlackAPI.Models { [Flags] public enum SlackScope diff --git a/Team.cs b/Models/Team.cs similarity index 99% rename from Team.cs rename to Models/Team.cs index 8635d09..393f0ad 100644 --- a/Team.cs +++ b/Models/Team.cs @@ -1,6 +1,6 @@ using System; -namespace SlackAPI +namespace SlackAPI.Models { public class Team { diff --git a/TeamPreferences.cs b/Models/TeamPreferences.cs similarity index 79% rename from TeamPreferences.cs rename to Models/TeamPreferences.cs index 777ad9a..dcf85ee 100644 --- a/TeamPreferences.cs +++ b/Models/TeamPreferences.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { public class TeamPreferences { diff --git a/Models/User.cs b/Models/User.cs new file mode 100644 index 0000000..924119e --- /dev/null +++ b/Models/User.cs @@ -0,0 +1,59 @@ +using Newtonsoft.Json; +using System; + +namespace SlackAPI.Models +{ + public class User + { + /// + /// Is the ID of the user. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + public bool IsSlackBot + { + get + { + return Id.Equals("USLACKBOT", StringComparison.CurrentCultureIgnoreCase); + } + } + + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + [JsonProperty(PropertyName = "deleted")] + public bool Deleted { get; set; } + + [JsonProperty(PropertyName = "color")] + public string Color { get; set; } + + [JsonProperty(PropertyName = "profile")] + public UserProfile Profile { get; set; } + + [JsonProperty(PropertyName = "is_admin")] + public bool IsAdmin { get; set; } + + [JsonProperty(PropertyName = "is_owner")] + public bool IsOwner { get; set; } + + [JsonProperty(PropertyName = "has_files")] + public bool HasFiles { get; set; } + + [JsonProperty(PropertyName = "presence")] + public string Presence { get; set; } + + [JsonProperty(PropertyName = "is_bot")] + public bool IsBot { get; set; } + + [JsonProperty(PropertyName = "tz")] + public string Tz { get; set; } + + [JsonProperty(PropertyName = "tz_label")] + public string TzLabel { get; set; } + + [JsonProperty(PropertyName = "tz_offset")] + public int TzOffset { get; set; } + + } +} diff --git a/UserProfile.cs b/Models/UserProfile.cs similarity index 77% rename from UserProfile.cs rename to Models/UserProfile.cs index 32b0fb8..2d9c65a 100644 --- a/UserProfile.cs +++ b/Models/UserProfile.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { public class UserProfile { @@ -19,7 +13,7 @@ public class UserProfile public string image_48; public string image_72; public string image_192; - + public string image_512; public override string ToString() { return real_name; diff --git a/UserTeamCombo.cs b/Models/UserTeamCombo.cs similarity index 58% rename from UserTeamCombo.cs rename to Models/UserTeamCombo.cs index 95a19c7..f604bfd 100644 --- a/UserTeamCombo.cs +++ b/Models/UserTeamCombo.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { public class UserTeamCombo { diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 8b2c719..0f1c7fd 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -13,6 +13,7 @@ [assembly: AssemblyCopyright("Copyright © 2014")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] +[assembly: log4net.Config.XmlConfigurator(Watch = true)] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from diff --git a/RPCMessages/AccessTokenResponse.cs b/RPCMessages/AccessTokenResponse.cs index ebf9fb9..5f5338d 100644 --- a/RPCMessages/AccessTokenResponse.cs +++ b/RPCMessages/AccessTokenResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("oauth.access")] public class AccessTokenResponse : Response @@ -12,6 +6,7 @@ public class AccessTokenResponse : Response public string access_token; public string scope; public string team_name; + public string team_id; public Bot bot; } } diff --git a/RPCMessages/AuthSigninResponse.cs b/RPCMessages/AuthSigninResponse.cs index c086581..0184b9a 100644 --- a/RPCMessages/AuthSigninResponse.cs +++ b/RPCMessages/AuthSigninResponse.cs @@ -1,6 +1,4 @@ -using System; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("auth.signin")] public class AuthSigninResponse : Response diff --git a/RPCMessages/AuthStartResponse.cs b/RPCMessages/AuthStartResponse.cs index 93dde36..7d46771 100644 --- a/RPCMessages/AuthStartResponse.cs +++ b/RPCMessages/AuthStartResponse.cs @@ -1,6 +1,4 @@ -using System; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("auth.start")] public class AuthStartResponse : Response diff --git a/RPCMessages/AuthTestResponse.cs b/RPCMessages/AuthTestResponse.cs index 2e9657e..a8f3be8 100644 --- a/RPCMessages/AuthTestResponse.cs +++ b/RPCMessages/AuthTestResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("auth.test", true)] public class AuthTestResponse : Response diff --git a/RPCMessages/ChannelCreateResponse.cs b/RPCMessages/ChannelCreateResponse.cs index b527365..3586c84 100644 --- a/RPCMessages/ChannelCreateResponse.cs +++ b/RPCMessages/ChannelCreateResponse.cs @@ -1,6 +1,4 @@ -using System; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("channels.create")] public class ChannelCreateResponse : Response diff --git a/RPCMessages/ChannelListResponse.cs b/RPCMessages/ChannelListResponse.cs index 22280c1..7de73bd 100644 --- a/RPCMessages/ChannelListResponse.cs +++ b/RPCMessages/ChannelListResponse.cs @@ -1,6 +1,4 @@ -using System; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("channels.list")] public class ChannelListResponse : Response diff --git a/RPCMessages/ChannelMessageHistory.cs b/RPCMessages/ChannelMessageHistory.cs index 27fb059..e110519 100644 --- a/RPCMessages/ChannelMessageHistory.cs +++ b/RPCMessages/ChannelMessageHistory.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("channels.history")] public class ChannelMessageHistory : MessageHistory diff --git a/RPCMessages/ChannelSetTopicResponse.cs b/RPCMessages/ChannelSetTopicResponse.cs index 540f1d0..30ceca1 100644 --- a/RPCMessages/ChannelSetTopicResponse.cs +++ b/RPCMessages/ChannelSetTopicResponse.cs @@ -1,4 +1,4 @@ -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("channels.setTopic")] public class ChannelSetTopicResponse : Response diff --git a/RPCMessages/DeletedResponse.cs b/RPCMessages/DeletedResponse.cs index 89b5af8..f25ec73 100644 --- a/RPCMessages/DeletedResponse.cs +++ b/RPCMessages/DeletedResponse.cs @@ -1,10 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("chat.delete")] public class DeletedResponse : Response diff --git a/RPCMessages/DirectMessageConversationListResponse.cs b/RPCMessages/DirectMessageConversationListResponse.cs index 59746ad..fe30d60 100644 --- a/RPCMessages/DirectMessageConversationListResponse.cs +++ b/RPCMessages/DirectMessageConversationListResponse.cs @@ -1,14 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("im.list")] public class DirectMessageConversationListResponse : Response { - public DirectMessageConversation[] ims; + public DirectMessage[] ims; } } diff --git a/RPCMessages/FileInfoResponse.cs b/RPCMessages/FileInfoResponse.cs index 38270a8..9f9aa83 100644 --- a/RPCMessages/FileInfoResponse.cs +++ b/RPCMessages/FileInfoResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("files.info")] public class FileInfoResponse : Response diff --git a/RPCMessages/FileListResponse.cs b/RPCMessages/FileListResponse.cs index 2771aba..bae2da8 100644 --- a/RPCMessages/FileListResponse.cs +++ b/RPCMessages/FileListResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("files.list")] public class FileListResponse : Response diff --git a/RPCMessages/FileUploadResponse.cs b/RPCMessages/FileUploadResponse.cs index dcf80f4..7ec933b 100644 --- a/RPCMessages/FileUploadResponse.cs +++ b/RPCMessages/FileUploadResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("files.upload")] public class FileUploadResponse : Response diff --git a/RPCMessages/FindTeamResponse.cs b/RPCMessages/FindTeamResponse.cs index d0b2d09..028cea6 100644 --- a/RPCMessages/FindTeamResponse.cs +++ b/RPCMessages/FindTeamResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { /// /// This is an undocumented response from an undocumented API. If anyone finds more info on this, please create a pull request. diff --git a/RPCMessages/GroupArchiveResponse.cs b/RPCMessages/GroupArchiveResponse.cs index d043012..48e3dec 100644 --- a/RPCMessages/GroupArchiveResponse.cs +++ b/RPCMessages/GroupArchiveResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("groups.archive")] public class GroupArchiveResponse : Response diff --git a/RPCMessages/GroupCloseResponse.cs b/RPCMessages/GroupCloseResponse.cs index d0fdcd2..3130618 100644 --- a/RPCMessages/GroupCloseResponse.cs +++ b/RPCMessages/GroupCloseResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("groups.close")] public class GroupCloseResponse : Response diff --git a/RPCMessages/GroupCreateChildResponse.cs b/RPCMessages/GroupCreateChildResponse.cs index 51d495e..5a07c49 100644 --- a/RPCMessages/GroupCreateChildResponse.cs +++ b/RPCMessages/GroupCreateChildResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("groups.createChild")] public class GroupCreateChildResponse : GroupResponse diff --git a/RPCMessages/GroupCreateResponse.cs b/RPCMessages/GroupCreateResponse.cs index b5082e0..9ed1efc 100644 --- a/RPCMessages/GroupCreateResponse.cs +++ b/RPCMessages/GroupCreateResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("groups.create")] public class GroupCreateResponse : GroupResponse diff --git a/RPCMessages/GroupInviteResponse.cs b/RPCMessages/GroupInviteResponse.cs index 2155178..d240053 100644 --- a/RPCMessages/GroupInviteResponse.cs +++ b/RPCMessages/GroupInviteResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("groups.invite")] public class GroupInviteResponse : GroupResponse diff --git a/RPCMessages/GroupKickResponse.cs b/RPCMessages/GroupKickResponse.cs index 3213fb2..fa86acf 100644 --- a/RPCMessages/GroupKickResponse.cs +++ b/RPCMessages/GroupKickResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("groups.kick")] public class GroupKickResponse : Response diff --git a/RPCMessages/GroupLeaveResponse.cs b/RPCMessages/GroupLeaveResponse.cs index 9c96122..0b17784 100644 --- a/RPCMessages/GroupLeaveResponse.cs +++ b/RPCMessages/GroupLeaveResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("groups.leave")] public class GroupLeaveResponse : Response diff --git a/RPCMessages/GroupListResponse.cs b/RPCMessages/GroupListResponse.cs index d8ad777..b33ebf2 100644 --- a/RPCMessages/GroupListResponse.cs +++ b/RPCMessages/GroupListResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("groups.list")] public class GroupListResponse : Response diff --git a/RPCMessages/GroupMarkResponse.cs b/RPCMessages/GroupMarkResponse.cs index b4cb742..617eff1 100644 --- a/RPCMessages/GroupMarkResponse.cs +++ b/RPCMessages/GroupMarkResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("groups.mark")] public class GroupMarkResponse : Response diff --git a/RPCMessages/GroupMessageHistory.cs b/RPCMessages/GroupMessageHistory.cs index 5708ca8..ec97655 100644 --- a/RPCMessages/GroupMessageHistory.cs +++ b/RPCMessages/GroupMessageHistory.cs @@ -1,6 +1,4 @@ -using System; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("groups.history")] public class GroupMessageHistory : MessageHistory diff --git a/RPCMessages/GroupOpenResponse.cs b/RPCMessages/GroupOpenResponse.cs index 70c2ffc..6cfb76a 100644 --- a/RPCMessages/GroupOpenResponse.cs +++ b/RPCMessages/GroupOpenResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("groups.open")] public class GroupOpenResponse : Response diff --git a/RPCMessages/GroupRenameResponse.cs b/RPCMessages/GroupRenameResponse.cs index 6590576..145b63b 100644 --- a/RPCMessages/GroupRenameResponse.cs +++ b/RPCMessages/GroupRenameResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("groups.rename")] public class GroupRenameResponse : Response diff --git a/RPCMessages/GroupResponse.cs b/RPCMessages/GroupResponse.cs index f8834bc..5ec90d0 100644 --- a/RPCMessages/GroupResponse.cs +++ b/RPCMessages/GroupResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { public class GroupResponse : Response { diff --git a/RPCMessages/GroupSetPurposeResponse.cs b/RPCMessages/GroupSetPurposeResponse.cs index 93a061c..967fd67 100644 --- a/RPCMessages/GroupSetPurposeResponse.cs +++ b/RPCMessages/GroupSetPurposeResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("groups.setPurpose")] public class GroupSetPurposeResponse : Response diff --git a/RPCMessages/GroupSetTopicResponse.cs b/RPCMessages/GroupSetTopicResponse.cs index f8adab9..0724092 100644 --- a/RPCMessages/GroupSetTopicResponse.cs +++ b/RPCMessages/GroupSetTopicResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("groups.setTopic")] public class GroupSetTopicResponse : Response diff --git a/RPCMessages/GroupUnarchiveResponse.cs b/RPCMessages/GroupUnarchiveResponse.cs index d68061c..a5c30a8 100644 --- a/RPCMessages/GroupUnarchiveResponse.cs +++ b/RPCMessages/GroupUnarchiveResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("groups.unarchive")] public class GroupUnarchiveResponse : Response diff --git a/RPCMessages/JoinDirectMessageChannelResponse.cs b/RPCMessages/JoinDirectMessageChannelResponse.cs index 2e9d54b..f1dfba6 100644 --- a/RPCMessages/JoinDirectMessageChannelResponse.cs +++ b/RPCMessages/JoinDirectMessageChannelResponse.cs @@ -1,4 +1,4 @@ -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("im.open")] public class JoinDirectMessageChannelResponse : Response diff --git a/RPCMessages/LoginResponse.cs b/RPCMessages/LoginResponse.cs index d048f31..aff9ce4 100644 --- a/RPCMessages/LoginResponse.cs +++ b/RPCMessages/LoginResponse.cs @@ -1,22 +1,22 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace SlackAPI +namespace SlackAPI.Models { - [RequestPath("rtm.start")] + [RequestPath("rtm.start")] public class LoginResponse : Response { public Bot[] bots; public Channel[] channels; public Channel[] groups; - public DirectMessageConversation[] ims; + public DirectMessage[] ims; public Self self; public int svn_rev; public int min_svn_rev; public Team team; + + /// + /// The Websocket URLs provided by rtm.start are single-use and are only valid for 30 seconds, so make sure to connect quickly. + /// public string url; public User[] users; } diff --git a/RPCMessages/MarkResponse.cs b/RPCMessages/MarkResponse.cs index 976b0c9..e8a510a 100644 --- a/RPCMessages/MarkResponse.cs +++ b/RPCMessages/MarkResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { /// /// This is used for moving the read cursor in the channel. diff --git a/RPCMessages/MessageHistory.cs b/RPCMessages/MessageHistory.cs index ba2541c..80e47e3 100644 --- a/RPCMessages/MessageHistory.cs +++ b/RPCMessages/MessageHistory.cs @@ -1,7 +1,6 @@ using System; -using Newtonsoft.Json.Serialization; -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("im.history")] public class MessageHistory : Response diff --git a/RPCMessages/PostMessageResponse.cs b/RPCMessages/PostMessageResponse.cs index c7f4b90..4bb3863 100644 --- a/RPCMessages/PostMessageResponse.cs +++ b/RPCMessages/PostMessageResponse.cs @@ -1,4 +1,4 @@ -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("chat.postMessage")] public class PostMessageResponse : Response diff --git a/RPCMessages/PresenseResponse.cs b/RPCMessages/PresenseResponse.cs index 5c3c333..70fe042 100644 --- a/RPCMessages/PresenseResponse.cs +++ b/RPCMessages/PresenseResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("users.setPresence")] public class PresenceResponse : Response diff --git a/RPCMessages/SearchResponseAll.cs b/RPCMessages/SearchResponseAll.cs index 80d224b..da03a75 100644 --- a/RPCMessages/SearchResponseAll.cs +++ b/RPCMessages/SearchResponseAll.cs @@ -1,6 +1,4 @@ -using System; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("search.all")] public class SearchResponseAll : Response diff --git a/RPCMessages/SearchResponseFiles.cs b/RPCMessages/SearchResponseFiles.cs index 9b8b284..3f476f4 100644 --- a/RPCMessages/SearchResponseFiles.cs +++ b/RPCMessages/SearchResponseFiles.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("search.files")] public class SearchResponseFiles : Response diff --git a/RPCMessages/SearchResponseMessages.cs b/RPCMessages/SearchResponseMessages.cs index 6131f94..9821c9c 100644 --- a/RPCMessages/SearchResponseMessages.cs +++ b/RPCMessages/SearchResponseMessages.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("search.messages")] public class SearchResponseMessages : Response diff --git a/RPCMessages/StarListResponse.cs b/RPCMessages/StarListResponse.cs index 2fe3e7d..480dc2f 100644 --- a/RPCMessages/StarListResponse.cs +++ b/RPCMessages/StarListResponse.cs @@ -1,6 +1,4 @@ -using System; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("stars.list")] public class StarListResponse : Response diff --git a/RPCMessages/UpdateResponse.cs b/RPCMessages/UpdateResponse.cs index 4514edf..6f3f98b 100644 --- a/RPCMessages/UpdateResponse.cs +++ b/RPCMessages/UpdateResponse.cs @@ -1,4 +1,4 @@ -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("chat.update")] public class UpdateResponse : Response diff --git a/RPCMessages/UserCountsResponse.cs b/RPCMessages/UserCountsResponse.cs index 2e82026..e69e080 100644 --- a/RPCMessages/UserCountsResponse.cs +++ b/RPCMessages/UserCountsResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("users.counts")] public class UserCountsResponse : Response diff --git a/RPCMessages/UserGetPresenceResponse.cs b/RPCMessages/UserGetPresenceResponse.cs index 62b4327..e9465b3 100644 --- a/RPCMessages/UserGetPresenceResponse.cs +++ b/RPCMessages/UserGetPresenceResponse.cs @@ -1,4 +1,4 @@ -namespace SlackAPI.RPCMessages +namespace SlackAPI.Models { [RequestPath("users.getPresence")] public class UserGetPresenceResponse : Response diff --git a/RPCMessages/UserInfoResponse.cs b/RPCMessages/UserInfoResponse.cs index 2948f50..69a9482 100644 --- a/RPCMessages/UserInfoResponse.cs +++ b/RPCMessages/UserInfoResponse.cs @@ -1,4 +1,4 @@ -namespace SlackAPI.RPCMessages +namespace SlackAPI.Models { [RequestPath("users.info")] public class UserInfoResponse : Response diff --git a/RPCMessages/UserListResponse.cs b/RPCMessages/UserListResponse.cs index 4e2a3ec..5393522 100644 --- a/RPCMessages/UserListResponse.cs +++ b/RPCMessages/UserListResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("users.list")] public class UserListResponse : Response diff --git a/RPCMessages/UserPreferencesResponse.cs b/RPCMessages/UserPreferencesResponse.cs index f8f69c0..60f74fc 100644 --- a/RPCMessages/UserPreferencesResponse.cs +++ b/RPCMessages/UserPreferencesResponse.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI +namespace SlackAPI.Models { [RequestPath("users.prefs.get")] public class UserPreferencesResponse: Response diff --git a/ReactionAddedResponse.cs b/ReactionAddedResponse.cs deleted file mode 100644 index b641ac3..0000000 --- a/ReactionAddedResponse.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI -{ - [RequestPath("reactions.add")] - public class ReactionAddedResponse : Response - { - - } -} diff --git a/Request.cs b/Request.cs index 34b8279..37782e8 100644 --- a/Request.cs +++ b/Request.cs @@ -1,11 +1,10 @@ using Newtonsoft.Json; +using SlackAPI.Models; using System; using System.Collections.Generic; using System.IO; using System.Net; using System.Reflection; -using System.Text; -using System.Threading; namespace SlackAPI { diff --git a/RequestStateForTask.cs b/RequestStateForTask.cs index 63075b7..2a437ae 100644 --- a/RequestStateForTask.cs +++ b/RequestStateForTask.cs @@ -1,10 +1,8 @@ using Newtonsoft.Json; +using SlackAPI.Models; using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net; -using System.Text; using System.Threading.Tasks; namespace SlackAPI diff --git a/Response.cs b/Response.cs deleted file mode 100644 index 6c60a0d..0000000 --- a/Response.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SlackAPI -{ - public abstract class Response - { - /// - /// Should always be checked before trying to process a response. - /// - public bool ok; - - /// - /// if ok is false, then this is the reason-code - /// - public string error; - - public void AssertOk() - { - if (!(ok)) - throw new InvalidOperationException(string.Format("An error occurred: {0}", this.error)); - } - } -} diff --git a/SlackAPI.csproj b/SlackAPI.csproj index aa3aaac..6c02cd1 100644 --- a/SlackAPI.csproj +++ b/SlackAPI.csproj @@ -20,6 +20,7 @@ DEBUG;TRACE prompt 4 + bin\Debug\SlackAPI.XML pdbonly @@ -28,8 +29,13 @@ TRACE prompt 4 + bin\Release\SlackAPI.XML + + packages\log4net.2.0.3\lib\net40-full\log4net.dll + False + packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True @@ -37,6 +43,7 @@ + @@ -44,22 +51,23 @@ - - - - + + + + + - - + + - - + + @@ -80,7 +88,7 @@ - + @@ -93,33 +101,34 @@ - + - + - + - + - + + - - - + + + - - + + @@ -129,6 +138,7 @@ + @@ -137,6 +147,8 @@ + + @@ -154,6 +166,7 @@ +