From 4f1e1bdef014f19d548ec301ad49c224a79e90e5 Mon Sep 17 00:00:00 2001 From: mrmurb Date: Mon, 19 Aug 2019 15:24:08 +0200 Subject: [PATCH 1/6] Removes Post/Get and replaces with Execute --- SlackNet/Http.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/SlackNet/Http.cs b/SlackNet/Http.cs index 08a9090..6b9f468 100644 --- a/SlackNet/Http.cs +++ b/SlackNet/Http.cs @@ -8,8 +8,7 @@ namespace SlackNet { public interface IHttp { - Task Get(string url, CancellationToken? cancellationToken = null); - Task Post(string url, HttpContent content, CancellationToken? cancellationToken = null); + Task Execute(HttpRequestMessage requestMessage, CancellationToken? cancellationToken = null); } class Http : IHttp @@ -23,16 +22,9 @@ public Http(HttpClient client, SlackJsonSettings jsonSettings) _jsonSettings = jsonSettings; } - public async Task Get(string url, CancellationToken? cancellationToken = null) + public async Task Execute(HttpRequestMessage requestMessage, CancellationToken? cancellationToken = null) { - var response = await _client.SendAsync(new HttpRequestMessage(HttpMethod.Get, url), cancellationToken ?? CancellationToken.None).ConfigureAwait(false); - response.EnsureSuccessStatusCode(); - return await Deserialize(response).ConfigureAwait(false); - } - - public async Task Post(string url, HttpContent content, CancellationToken? cancellationToken = null) - { - var response = await _client.PostAsync(url, content, cancellationToken ?? CancellationToken.None).ConfigureAwait(false); + var response = await _client.SendAsync(requestMessage, cancellationToken ?? CancellationToken.None).ConfigureAwait(false); response.EnsureSuccessStatusCode(); return await Deserialize(response).ConfigureAwait(false); } From 33d4061944a4b536ea51df7a8cece79feda07767 Mon Sep 17 00:00:00 2001 From: mrmurb Date: Mon, 19 Aug 2019 15:24:39 +0200 Subject: [PATCH 2/6] Refactoring to make use of Execute from Http.cs --- SlackNet/SlackApiClient.cs | 48 ++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/SlackNet/SlackApiClient.cs b/SlackNet/SlackApiClient.cs index 2ccab86..afd9379 100644 --- a/SlackNet/SlackApiClient.cs +++ b/SlackNet/SlackApiClient.cs @@ -1,4 +1,6 @@ using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json; @@ -65,6 +67,15 @@ public interface ISlackApiClient /// Task Post(string apiMethod, Args args, HttpContent content, CancellationToken? cancellationToken); + /// + /// Calls a Slack API that requires POST content. + /// + /// Type of response expected. + /// Name of Slack method. + /// Arguments to send to Slack. Authorization headers will be added automagically. + /// + Task Post(string apiMethod, Args args, CancellationToken? cancellationToken) where T : class; + /// /// Calls a Slack API that requires POST content. /// @@ -145,8 +156,12 @@ public Task Get(string apiMethod, Args args, CancellationToken? cancellationToke /// Name of Slack method. /// Arguments to send to Slack. The "token" parameter will be filled in automatically. /// - public async Task Get(string apiMethod, Args args, CancellationToken? cancellationToken) where T : class => - Deserialize(await _http.Get(Url(apiMethod, args), cancellationToken ?? CancellationToken.None).ConfigureAwait(false)); + public async Task Get(string apiMethod, Args args, CancellationToken? cancellationToken) where T : class + { + var requestMessage = new HttpRequestMessage(HttpMethod.Get, Url(apiMethod, args)); + return Deserialize(await _http.Execute(requestMessage, cancellationToken ?? CancellationToken.None).ConfigureAwait(false)); + } + /// /// Calls a Slack API that requires POST content. @@ -164,11 +179,34 @@ public Task Post(string apiMethod, Args args, HttpContent content, CancellationT /// Type of response expected. /// Name of Slack method. /// Arguments to send to Slack. The "token" parameter will be filled in automatically. - /// POST body content. Should be either or . /// - public async Task Post(string apiMethod, Args args, HttpContent content, CancellationToken? cancellationToken) where T : class => - Deserialize(await _http.Post(Url(apiMethod, args), content, cancellationToken ?? CancellationToken.None).ConfigureAwait(false)); + public async Task Post(string apiMethod, Args args, CancellationToken? cancellationToken) where T : class + { + var requestMessage = new HttpRequestMessage(HttpMethod.Post,Url(apiMethod)); + requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _token); + requestMessage.Content = new StringContent(JsonConvert.SerializeObject(args, _jsonSettings.SerializerSettings), Encoding.UTF8, "application/json"); + + var response = await _http.Execute(requestMessage, cancellationToken ?? CancellationToken.None).ConfigureAwait(false); + return Deserialize(response); + } + /// + /// Calls a Slack API that requires POST content. + /// + /// Type of response expected. + /// Name of Slack method. + /// Arguments to send to Slack. The "token" parameter will be filled in automatically. + /// POST body content. Should be either or . + /// + public async Task Post(string apiMethod, Args args, HttpContent content, CancellationToken? cancellationToken) where T : class + { + var requestMessage = new HttpRequestMessage(HttpMethod.Post, Url(apiMethod, args)) { Content = content }; + return Deserialize(await _http.Execute(requestMessage, cancellationToken ?? CancellationToken.None).ConfigureAwait(false)); + } + + private string Url(string apiMethod) => + _urlBuilder.Url(apiMethod, new Args()); + private string Url(string apiMethod, Args args) { if (!args.ContainsKey("token")) From 20a21e8c72f7c7545f9567d7f43c3ffe3389f9db Mon Sep 17 00:00:00 2001 From: mrmurb Date: Mon, 19 Aug 2019 15:25:06 +0200 Subject: [PATCH 3/6] Need to implement ISlackApiClient in tests --- SlackNet.Tests/ApiLintTest.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/SlackNet.Tests/ApiLintTest.cs b/SlackNet.Tests/ApiLintTest.cs index 782b33f..d559ee2 100644 --- a/SlackNet.Tests/ApiLintTest.cs +++ b/SlackNet.Tests/ApiLintTest.cs @@ -140,6 +140,15 @@ public Task Post(string apiMethod, Args args, HttpContent content, CancellationT return Task.FromResult(0); } + public Task Post(string apiMethod, Args args, CancellationToken? cancellationToken) where T : class + { + HttpMethod = "POST"; + SlackMethod = apiMethod; + Args = args; + CancellationToken = cancellationToken; + return Task.FromResult(Activator.CreateInstance()); + } + public Task Post(string apiMethod, Args args, HttpContent content, CancellationToken? cancellationToken) where T : class { HttpMethod = "POST"; From 390b4cf35506acab6e871eb38a15b8bf7e3972a9 Mon Sep 17 00:00:00 2001 From: mrmurb Date: Mon, 19 Aug 2019 15:25:29 +0200 Subject: [PATCH 4/6] Make use of ISlackApiClient's new Post --- SlackNet/WebApi/ChatApi.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SlackNet/WebApi/ChatApi.cs b/SlackNet/WebApi/ChatApi.cs index 8f51269..969d2ee 100644 --- a/SlackNet/WebApi/ChatApi.cs +++ b/SlackNet/WebApi/ChatApi.cs @@ -116,7 +116,7 @@ public Task MeMessage(string channel, string text, Cancellati /// The message to post. /// public Task PostMessage(Message message, CancellationToken? cancellationToken = null) => - _client.Get("chat.postMessage", PopulateMessageArgs(message, new Args()), + _client.Post("chat.postMessage", PopulateMessageArgs(message, new Args()), cancellationToken); /// @@ -158,7 +158,7 @@ private static Args PopulateMessageArgs(Message message, Args args) /// The message to post. Not all message properties are supported by PostEphemeral. /// public Task PostEphemeral(string userId, Message message, CancellationToken? cancellationToken = null) => - _client.Get("chat.postEphemeral", new Args + _client.Post("chat.postEphemeral", new Args { { "channel", message.Channel }, { "text", message.Text }, From 3e8e4ee5302d80aac6f02add864bbc907db93669 Mon Sep 17 00:00:00 2001 From: mrmurb Date: Tue, 20 Aug 2019 10:39:01 +0200 Subject: [PATCH 5/6] use preferred HTTP method according to Slack Docs --- SlackNet/WebApi/ApiApi.cs | 2 +- SlackNet/WebApi/AuthApi.cs | 2 +- SlackNet/WebApi/ChannelsApi.cs | 22 +++++++++++----------- SlackNet/WebApi/ChatApi.cs | 10 +++++----- SlackNet/WebApi/ConversationsApi.cs | 24 ++++++++++++------------ SlackNet/WebApi/DialogApi.cs | 2 +- SlackNet/WebApi/DndApi.cs | 4 ++-- SlackNet/WebApi/FileCommentsApi.cs | 2 +- SlackNet/WebApi/FilesApi.cs | 6 +++--- SlackNet/WebApi/GroupsApi.cs | 22 +++++++++++----------- SlackNet/WebApi/ImApi.cs | 6 +++--- SlackNet/WebApi/MpimApi.cs | 6 +++--- SlackNet/WebApi/PinsApi.cs | 12 ++++++------ SlackNet/WebApi/ReactionsApi.cs | 12 ++++++------ SlackNet/WebApi/RemindersApi.cs | 10 +++++----- SlackNet/WebApi/ScheduledMessagesApi.cs | 2 +- SlackNet/WebApi/StarsApi.cs | 16 ++++++++-------- SlackNet/WebApi/UserGroupUsersApi.cs | 2 +- SlackNet/WebApi/UserGroupsApi.cs | 8 ++++---- SlackNet/WebApi/UserProfileApi.cs | 4 ++-- SlackNet/WebApi/UsersApi.cs | 2 +- 21 files changed, 88 insertions(+), 88 deletions(-) diff --git a/SlackNet/WebApi/ApiApi.cs b/SlackNet/WebApi/ApiApi.cs index 152d0be..b9fe717 100644 --- a/SlackNet/WebApi/ApiApi.cs +++ b/SlackNet/WebApi/ApiApi.cs @@ -38,7 +38,7 @@ public class ApiApi : IApiApi public async Task> Test(string error, Args args, CancellationToken? cancellationToken = null) { var query = new Args(args) { ["error"] = error }; - return (await _client.Get("api.test", query, cancellationToken).ConfigureAwait(false)).Args; + return (await _client.Post("api.test", query, cancellationToken).ConfigureAwait(false)).Args; } } } \ No newline at end of file diff --git a/SlackNet/WebApi/AuthApi.cs b/SlackNet/WebApi/AuthApi.cs index d7cdf3f..3e9589f 100644 --- a/SlackNet/WebApi/AuthApi.cs +++ b/SlackNet/WebApi/AuthApi.cs @@ -40,6 +40,6 @@ public async Task Revoke(bool test, CancellationToken? cancellationToken = /// Checks authentication and tells you who you are. /// public Task Test(CancellationToken? cancellationToken = null) => - _client.Get("auth.test", new Args(), cancellationToken); + _client.Post("auth.test", new Args(), cancellationToken); } } \ No newline at end of file diff --git a/SlackNet/WebApi/ChannelsApi.cs b/SlackNet/WebApi/ChannelsApi.cs index 6de23b7..ee4656f 100644 --- a/SlackNet/WebApi/ChannelsApi.cs +++ b/SlackNet/WebApi/ChannelsApi.cs @@ -162,7 +162,7 @@ public class ChannelsApi : IChannelsApi /// /// public Task Archive(string channelId, CancellationToken? cancellationToken = null) => - _client.Get("channels.archive", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("channels.archive", new Args { { "channel", channelId } }, cancellationToken); /// /// Used to create a channel. @@ -172,7 +172,7 @@ public Task Archive(string channelId, CancellationToken? cancellationToken = nul /// Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria. /// public async Task Create(string name, bool validate = false, CancellationToken? cancellationToken = null) => - (await _client.Get("channels.create", new Args + (await _client.Post("channels.create", new Args { { "name", name }, { "validate", validate } @@ -220,7 +220,7 @@ public async Task Info(string channelId, CancellationToken? cancellatio /// User to invite to channel. /// public async Task Invite(string channelId, string userId, CancellationToken? cancellationToken = null) => - (await _client.Get("channels.invite", new Args + (await _client.Post("channels.invite", new Args { { "channel", channelId }, { "user", userId } @@ -240,7 +240,7 @@ public async Task Invite(string channelId, string userId, CancellationT /// This allows a client to see that the request to join GeNERaL is the same as the channel #general that the user is already in. /// public Task Join(string channelName, bool validate = false, CancellationToken? cancellationToken = null) => - _client.Get("channels.join", new Args + _client.Post("channels.join", new Args { { "channel", channelName }, { "validate", validate } @@ -253,7 +253,7 @@ public Task Join(string channelName, bool validate = false, /// User to remove from channel. /// public Task Kick(string channelId, string userId, CancellationToken? cancellationToken = null) => - _client.Get("channels.kick", new Args + _client.Post("channels.kick", new Args { { "channel", channelId }, { "user", userId } @@ -266,7 +266,7 @@ public Task Kick(string channelId, string userId, CancellationToken? cancellatio /// /// public Task Leave(string channelId, CancellationToken? cancellationToken = null) => - _client.Get("channels.leave", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("channels.leave", new Args { { "channel", channelId } }, cancellationToken); /// /// Returns a list of all channels in the team. @@ -292,7 +292,7 @@ public async Task> List(bool excludeArchived = false, boo /// Timestamp of the most recently seen message. /// public Task Mark(string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Get("channels.mark", new Args + _client.Post("channels.mark", new Args { { "channel", channelId }, { "ts", ts } @@ -308,7 +308,7 @@ public Task Mark(string channelId, string ts, CancellationToken? cancellationTok /// Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria. /// public async Task Rename(string channelId, string name, bool validate = false, CancellationToken? cancellationToken = null) => - (await _client.Get("channels.rename", new Args + (await _client.Post("channels.rename", new Args { { "channel", channelId }, { "name", name }, @@ -338,7 +338,7 @@ public async Task> Replies(string channelId, string /// /// The channel's new purpose. public async Task SetPurpose(string channelId, string purpose, CancellationToken? cancellationToken = null) => - (await _client.Get("channels.setPurpose", new Args + (await _client.Post("channels.setPurpose", new Args { { "channel", channelId }, { "purpose", purpose } @@ -353,7 +353,7 @@ public async Task SetPurpose(string channelId, string purpose, Cancellat /// /// The channel's new topic. public async Task SetTopic(string channelId, string topic, CancellationToken? cancellationToken = null) => - (await _client.Get("channels.setTopic", new Args + (await _client.Post("channels.setTopic", new Args { { "channel", channelId }, { "topic", topic } @@ -366,6 +366,6 @@ public async Task SetTopic(string channelId, string topic, CancellationT /// Channel to unarchive. /// public Task Unarchive(string channelId, CancellationToken? cancellationToken = null) => - _client.Get("channels.unarchive", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("channels.unarchive", new Args { { "channel", channelId } }, cancellationToken); } } \ No newline at end of file diff --git a/SlackNet/WebApi/ChatApi.cs b/SlackNet/WebApi/ChatApi.cs index 969d2ee..1a69eb8 100644 --- a/SlackNet/WebApi/ChatApi.cs +++ b/SlackNet/WebApi/ChatApi.cs @@ -77,7 +77,7 @@ public class ChatApi : IChatApi /// Pass True to delete the message as the authed user. Bot users in this context are considered authed users. /// public Task Delete(string ts, string channelId, bool asUser = false, CancellationToken? cancellationToken = null) => - _client.Get("chat.delete", new Args + _client.Post("chat.delete", new Args { { "ts", ts }, { "channel", channelId }, @@ -104,7 +104,7 @@ public Task GetPermalink(string channelId, string messageTs, /// Text of the message to send. /// public Task MeMessage(string channel, string text, CancellationToken? cancellationToken = null) => - _client.Get("chat.meMessage", new Args + _client.Post("chat.meMessage", new Args { { "channel", channel }, { "text", text } @@ -126,7 +126,7 @@ public Task PostMessage(Message message, CancellationToken? /// Time in the future to send the message. /// public Task ScheduleMessage(Message message, DateTime postAt, CancellationToken? cancellationToken = null) => - _client.Get("chat.scheduleMessage", PopulateMessageArgs(message, new Args + _client.Post("chat.scheduleMessage", PopulateMessageArgs(message, new Args { { "post_at", postAt.ToTimestamp() } }), @@ -186,7 +186,7 @@ public Task PostEphemeral(string userId, Message message, C /// Subsequent attempts with the same and values will modify the same attachments, rather than adding more. /// public Task Unfurl(string channelId, string ts, IDictionary unfurls, bool userAuthRequired = false, CancellationToken? cancellationToken = null) => - _client.Get("chat.unfurl", new Args + _client.Post("chat.unfurl", new Args { { "channel", channelId }, { "ts", ts }, @@ -200,7 +200,7 @@ public Task Unfurl(string channelId, string ts, IDictionary /// Message to update. /// public Task Update(MessageUpdate messageUpdate, CancellationToken? cancellationToken = null) => - _client.Get("chat.update", new Args + _client.Post("chat.update", new Args { { "ts", messageUpdate.Ts }, { "channel", messageUpdate.ChannelId }, diff --git a/SlackNet/WebApi/ConversationsApi.cs b/SlackNet/WebApi/ConversationsApi.cs index e68eee2..5c7c393 100644 --- a/SlackNet/WebApi/ConversationsApi.cs +++ b/SlackNet/WebApi/ConversationsApi.cs @@ -207,7 +207,7 @@ public class ConversationsApi : IConversationsApi /// ID of conversation to archive. /// public Task Archive(string channelId, CancellationToken? cancellationToken = null) => - _client.Get("conversations.archive", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("conversations.archive", new Args { { "channel", channelId } }, cancellationToken); /// /// Closes a direct message or multi-person direct message. @@ -216,7 +216,7 @@ public Task Archive(string channelId, CancellationToken? cancellationToken = nul /// /// public Task Close(string channelId, CancellationToken? cancellationToken = null) => - _client.Get("conversations.close", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("conversations.close", new Args { { "channel", channelId } }, cancellationToken); /// /// Initiates a public or private channel-based conversation. @@ -226,7 +226,7 @@ public Task Close(string channelId, CancellationToken? cancellationToken = null) /// Create a private channel instead of a public one. /// public async Task Create(string name, bool isPrivate, CancellationToken? cancellationToken = null) => - (await _client.Get("conversations.create", new Args + (await _client.Post("conversations.create", new Args { { "name", name }, { "is_private", isPrivate } @@ -281,7 +281,7 @@ public async Task Info(string channelId, bool includeLocale = fals /// A comma separated list of user IDs. Up to 30 users may be listed. /// public async Task Invite(string channelId, IEnumerable userIds, CancellationToken? cancellationToken = null) => - (await _client.Get("conversations.invite", new Args + (await _client.Post("conversations.invite", new Args { { "channel", channelId }, { "users", userIds } @@ -294,7 +294,7 @@ public async Task Invite(string channelId, IEnumerable use /// ID of conversation to join. /// public Task Join(string channelId, CancellationToken? cancellationToken = null) => - _client.Get("conversations.join", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("conversations.join", new Args { { "channel", channelId } }, cancellationToken); /// /// Removes a user from a conversation. @@ -303,7 +303,7 @@ public Task Join(string channelId, CancellationToken? /// User ID to be removed. /// public Task Kick(string channelId, string userId, CancellationToken? cancellationToken = null) => - _client.Get("conversations.kick", new Args + _client.Post("conversations.kick", new Args { { "channel", channelId }, { "user", userId } @@ -315,7 +315,7 @@ public Task Kick(string channelId, string userId, CancellationToken? cancellatio /// Conversation to leave. /// public Task Leave(string channelId, CancellationToken? cancellationToken = null) => - _client.Get("conversations.leave", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("conversations.leave", new Args { { "channel", channelId } }, cancellationToken); /// /// Lists all channels in a Slack team. @@ -396,7 +396,7 @@ public Task OpenAndReturnInfo(IEnumerable userIds, Cancellat Open(true, null, userIds, cancellationToken); private Task Open(bool returnIm, string channelId = null, IEnumerable userIds = null, CancellationToken? cancellationToken = null) where T : class => - _client.Get("conversations.open", new Args + _client.Post("conversations.open", new Args { { "channel", channelId }, { "return_im", returnIm }, @@ -410,7 +410,7 @@ private Task Open(bool returnIm, string channelId = null, IEnumerableNew name for conversation. /// public async Task Rename(string channelId, string name, CancellationToken? cancellationToken = null) => - (await _client.Get("conversations.rename", new Args + (await _client.Post("conversations.rename", new Args { { "channel", channelId }, { "name", name } @@ -451,7 +451,7 @@ public Task Replies(string channelId, string threa /// A new, specialer purpose. /// public async Task SetPurpose(string channelId, string purpose, CancellationToken? cancellationToken = null) => - (await _client.Get("conversations.setPurpose", new Args + (await _client.Post("conversations.setPurpose", new Args { { "channel", channelId }, { "purpose", purpose } @@ -465,7 +465,7 @@ public async Task SetPurpose(string channelId, string purpose, Cancellat /// The new topic string. Does not support formatting or linkification. /// public async Task SetTopic(string channelId, string topic, CancellationToken? cancellationToken = null) => - (await _client.Get("conversations.setTopic", new Args + (await _client.Post("conversations.setTopic", new Args { { "channel", channelId }, { "topic", topic } @@ -478,6 +478,6 @@ public async Task SetTopic(string channelId, string topic, CancellationT /// ID of conversation to unarchive. /// public Task Unarchive(string channelId, CancellationToken? cancellationToken = null) => - _client.Get("conversations.unarchive", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("conversations.unarchive", new Args { { "channel", channelId } }, cancellationToken); } } \ No newline at end of file diff --git a/SlackNet/WebApi/DialogApi.cs b/SlackNet/WebApi/DialogApi.cs index c35a548..9c49032 100644 --- a/SlackNet/WebApi/DialogApi.cs +++ b/SlackNet/WebApi/DialogApi.cs @@ -28,7 +28,7 @@ public class DialogApi : IDialogApi /// The dialog definition. /// public Task Open(string triggerId, Dialog dialog, CancellationToken? cancellationToken = null) => - _client.Get("dialog.open", new Args + _client.Post("dialog.open", new Args { { "dialog", dialog }, { "trigger_id", triggerId } diff --git a/SlackNet/WebApi/DndApi.cs b/SlackNet/WebApi/DndApi.cs index 1ad85f0..fae9021 100644 --- a/SlackNet/WebApi/DndApi.cs +++ b/SlackNet/WebApi/DndApi.cs @@ -59,14 +59,14 @@ public class DndApi : IDndApi /// /// public Task EndDnd(CancellationToken? cancellationToken = null) => - _client.Get("dnd.endDnd", new Args(), cancellationToken); + _client.Post("dnd.endDnd", new Args(), cancellationToken); /// /// Ends the current user's snooze mode immediately. /// /// public Task EndSnooze(CancellationToken? cancellationToken = null) => - _client.Get("dnd.endSnooze", new Args(), cancellationToken); + _client.Post("dnd.endSnooze", new Args(), cancellationToken); /// /// Provides information about the current user's Do Not Disturb settings. diff --git a/SlackNet/WebApi/FileCommentsApi.cs b/SlackNet/WebApi/FileCommentsApi.cs index a5987e5..00ec928 100644 --- a/SlackNet/WebApi/FileCommentsApi.cs +++ b/SlackNet/WebApi/FileCommentsApi.cs @@ -29,7 +29,7 @@ public class FileCommentsApi : IFileCommentsApi /// The comment to delete. /// public Task Delete(string fileId, string commentId, CancellationToken? cancellationToken = null) => - _client.Get("files.comments.delete", new Args + _client.Post("files.comments.delete", new Args { { "file", fileId }, { "id", commentId } diff --git a/SlackNet/WebApi/FilesApi.cs b/SlackNet/WebApi/FilesApi.cs index a643570..234784a 100644 --- a/SlackNet/WebApi/FilesApi.cs +++ b/SlackNet/WebApi/FilesApi.cs @@ -164,7 +164,7 @@ public class FilesApi : IFilesApi /// ID of file to delete. /// public Task Delete(string fileId, CancellationToken? cancellationToken = null) => - _client.Get("files.delete", new Args { { "file", fileId } }, cancellationToken); + _client.Post("files.delete", new Args { { "file", fileId } }, cancellationToken); /// /// Returns information about a file in your team. @@ -219,7 +219,7 @@ public Task List( /// File to revoke /// public Task RevokePublicUrl(string fileId, CancellationToken? cancellationToken = null) => - _client.Get("files.revokePublicURL", new Args { { "file", fileId } }, cancellationToken); + _client.Post("files.revokePublicURL", new Args { { "file", fileId } }, cancellationToken); /// /// Enables public/external sharing for a file. @@ -227,7 +227,7 @@ public Task RevokePublicUrl(string fileId, CancellationToken? canc /// File to share. /// public Task SharedPublicUrl(string fileId, CancellationToken? cancellationToken = null) => - _client.Get("files.sharedPublicURL", new Args { { "file", fileId } }, cancellationToken); + _client.Post("files.sharedPublicURL", new Args { { "file", fileId } }, cancellationToken); /// /// Allows you to create or upload an existing file. diff --git a/SlackNet/WebApi/GroupsApi.cs b/SlackNet/WebApi/GroupsApi.cs index 072acb5..4514f44 100644 --- a/SlackNet/WebApi/GroupsApi.cs +++ b/SlackNet/WebApi/GroupsApi.cs @@ -172,7 +172,7 @@ public class GroupsApi : IGroupsApi /// Private channel to archive. /// public Task Archive(string channelId, CancellationToken? cancellationToken = null) => - _client.Get("groups.archive", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("groups.archive", new Args { { "channel", channelId } }, cancellationToken); /// /// Closes a private channel. @@ -189,7 +189,7 @@ public Task Close(string channelId, CancellationToken? cancellationToken = null) /// Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria. /// public async Task Create(string name, bool validate = false, CancellationToken? cancellationToken = null) => - (await _client.Get("groups.create", new Args + (await _client.Post("groups.create", new Args { { "name", name }, { "validate", validate } @@ -255,7 +255,7 @@ public async Task Info(string channelId, CancellationToken? cancellatio /// User to invite. /// public async Task Invite(string channelId, string userId, CancellationToken? cancellationToken = null) => - (await _client.Get("groups.invite", new Args + (await _client.Post("groups.invite", new Args { { "channel", channelId }, { "user", userId } @@ -270,7 +270,7 @@ public async Task Invite(string channelId, string userId, CancellationT /// /// public Task Kick(string channelId, string userId, CancellationToken? cancellationToken = null) => - _client.Get("groups.kick", new Args + _client.Post("groups.kick", new Args { { "channel", channelId }, { "user", userId } @@ -282,7 +282,7 @@ public Task Kick(string channelId, string userId, CancellationToken? cancellatio /// Private channel to leave. /// public Task Leave(string channelId, CancellationToken? cancellationToken = null) => - _client.Get("groups.leave", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("groups.leave", new Args { { "channel", channelId } }, cancellationToken); /// /// Returns a list of private channels in the team that the caller is in and archived groups that the caller was in. @@ -300,7 +300,7 @@ public async Task> List(bool excludeArchived = false, Can /// Timestamp of the most recently seen message. /// public Task Mark(string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Get("groups.mark", new Args { { "channel", channelId }, { "ts", ts } }, cancellationToken); + _client.Post("groups.mark", new Args { { "channel", channelId }, { "ts", ts } }, cancellationToken); /// /// Opens a private channel. @@ -309,7 +309,7 @@ public Task Mark(string channelId, string ts, CancellationToken? cancellationTok /// /// public Task Open(string channelId, CancellationToken? cancellationToken = null) => - _client.Get("groups.open", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("groups.open", new Args { { "channel", channelId } }, cancellationToken); /// /// Renames a private channel. @@ -319,7 +319,7 @@ public Task Open(string channelId, CancellationToken? cancellationToken = null) /// Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria. /// public async Task Rename(string channelId, string name, bool validate = false, CancellationToken? cancellationToken = null) => - (await _client.Get("groups.rename", new Args + (await _client.Post("groups.rename", new Args { { "channel", channelId }, { "name", name }, @@ -349,7 +349,7 @@ public async Task> Replies(string channelId, string /// /// The group's new purpose. public async Task SetPurpose(string channelId, string purpose, CancellationToken? cancellationToken = null) => - (await _client.Get("groups.setPurpose", new Args + (await _client.Post("groups.setPurpose", new Args { { "channel", channelId }, { "purpose", purpose } @@ -364,7 +364,7 @@ public async Task SetPurpose(string channelId, string purpose, Cancellat /// /// The private channel's new topic. public async Task SetTopic(string channelId, string topic, CancellationToken? cancellationToken = null) => - (await _client.Get("groups.setTopic", new Args + (await _client.Post("groups.setTopic", new Args { { "channel", channelId }, { "topic", topic } @@ -377,6 +377,6 @@ public async Task SetTopic(string channelId, string topic, CancellationT /// Private channel to unarchive. /// public Task Unarchive(string channelId, CancellationToken? cancellationToken = null) => - _client.Get("groups.unarchive", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("groups.unarchive", new Args { { "channel", channelId } }, cancellationToken); } } \ No newline at end of file diff --git a/SlackNet/WebApi/ImApi.cs b/SlackNet/WebApi/ImApi.cs index be573bd..cd2655d 100644 --- a/SlackNet/WebApi/ImApi.cs +++ b/SlackNet/WebApi/ImApi.cs @@ -80,7 +80,7 @@ public class ImApi : IImApi /// Direct message channel to close. /// public Task Close(string channelId, CancellationToken? cancellationToken = null) => - _client.Get("im.close", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("im.close", new Args { { "channel", channelId } }, cancellationToken); /// /// Returns a portion of message events from the specified direct message channel. @@ -129,7 +129,7 @@ public async Task> List(CancellationToken? cancellationToken = /// Timestamp of the most recently seen message. /// public Task Mark(string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Get("im.mark", new Args + _client.Post("im.mark", new Args { { "channel", channelId }, { "ts", ts } @@ -142,7 +142,7 @@ public Task Mark(string channelId, string ts, CancellationToken? cancellationTok /// Indicates you want the full IM channel definition in the response. /// public Task Open(string userId, bool returnIm = false, CancellationToken? cancellationToken = null) => - _client.Get("im.open", new Args + _client.Post("im.open", new Args { { "user", userId }, { "return_im", returnIm } diff --git a/SlackNet/WebApi/MpimApi.cs b/SlackNet/WebApi/MpimApi.cs index cfd9282..3beef15 100644 --- a/SlackNet/WebApi/MpimApi.cs +++ b/SlackNet/WebApi/MpimApi.cs @@ -79,7 +79,7 @@ public class MpimApi : IMpimApi /// MPIM to close. /// public Task Close(string channelId, CancellationToken? cancellationToken = null) => - _client.Get("mpim.close", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("mpim.close", new Args { { "channel", channelId } }, cancellationToken); /// /// Returns a portion of message events from the specified multiparty direct message channel. @@ -128,7 +128,7 @@ public async Task> List(CancellationToken? cancellationTo /// Timestamp of the most recently seen message. /// public Task Mark(string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Get("mpim.mark", new Args + _client.Post("mpim.mark", new Args { { "channel", channelId }, { "ts", ts } @@ -140,7 +140,7 @@ public Task Mark(string channelId, string ts, CancellationToken? cancellationTok /// List of users. The ordering of the users is preserved whenever a MPIM group is returned. /// public async Task Open(IEnumerable userIds, CancellationToken? cancellationToken = null) => - (await _client.Get("mpim.open", new Args { { "users", userIds } }, cancellationToken).ConfigureAwait(false)).Group; + (await _client.Post("mpim.open", new Args { { "users", userIds } }, cancellationToken).ConfigureAwait(false)).Group; /// /// Returns an entire thread (a message plus all the messages in reply to it). diff --git a/SlackNet/WebApi/PinsApi.cs b/SlackNet/WebApi/PinsApi.cs index 2ec983b..a81449d 100644 --- a/SlackNet/WebApi/PinsApi.cs +++ b/SlackNet/WebApi/PinsApi.cs @@ -80,7 +80,7 @@ public class PinsApi : IPinsApi /// File to pin. /// public Task AddFile(string channelId, string fileId, CancellationToken? cancellationToken = null) => - _client.Get("pins.add", new Args + _client.Post("pins.add", new Args { { "channel", channelId }, { "file", fileId } @@ -93,7 +93,7 @@ public Task AddFile(string channelId, string fileId, CancellationToken? cancella /// File comment to pin. /// public Task AddFileComment(string channelId, string fileCommentId, CancellationToken? cancellationToken = null) => - _client.Get("pins.add", new Args + _client.Post("pins.add", new Args { { "channel", channelId }, { "file_comment", fileCommentId }, @@ -106,7 +106,7 @@ public Task AddFileComment(string channelId, string fileCommentId, CancellationT /// Timestamp of the message to pin. /// public Task AddMessage(string channelId, string ts = null, CancellationToken? cancellationToken = null) => - _client.Get("pins.add", new Args + _client.Post("pins.add", new Args { { "channel", channelId }, { "timestamp", ts } @@ -127,7 +127,7 @@ public async Task> List(string channelId, Cancellation /// File to un-pin. /// public Task RemoveFile(string channelId, string fileId, CancellationToken? cancellationToken = null) => - _client.Get("pins.remove", new Args + _client.Post("pins.remove", new Args { { "channel", channelId }, { "file", fileId } @@ -140,7 +140,7 @@ public Task RemoveFile(string channelId, string fileId, CancellationToken? cance /// File comment to un-pin. /// public Task RemoveFileComment(string channelId, string fileCommentId, CancellationToken? cancellationToken = null) => - _client.Get("pins.remove", new Args + _client.Post("pins.remove", new Args { { "channel", channelId }, { "file_comment", fileCommentId } @@ -153,7 +153,7 @@ public Task RemoveFileComment(string channelId, string fileCommentId, Cancellati /// Timestamp of the message to un-pin. /// public Task RemoveMessage(string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Get("pins.remove", new Args + _client.Post("pins.remove", new Args { { "channel", channelId }, { "timestamp", ts } diff --git a/SlackNet/WebApi/ReactionsApi.cs b/SlackNet/WebApi/ReactionsApi.cs index e1f0137..84f67ed 100644 --- a/SlackNet/WebApi/ReactionsApi.cs +++ b/SlackNet/WebApi/ReactionsApi.cs @@ -105,7 +105,7 @@ public class ReactionsApi : IReactionsApi /// File to add reaction to. /// public Task AddToFile(string name, string fileId, CancellationToken? cancellationToken = null) => - _client.Get("reactions.add", new Args + _client.Post("reactions.add", new Args { { "name", name }, { "file", fileId } @@ -118,7 +118,7 @@ public Task AddToFile(string name, string fileId, CancellationToken? cancellatio /// File comment to add reaction to. /// public Task AddToFileComment(string name, string fileCommentId, CancellationToken? cancellationToken = null) => - _client.Get("reactions.add", new Args + _client.Post("reactions.add", new Args { { "name", name }, { "file_comment", fileCommentId } @@ -132,7 +132,7 @@ public Task AddToFileComment(string name, string fileCommentId, CancellationToke /// Timestamp of the message to add reaction to. /// public Task AddToMessage(string name, string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Get("reactions.add", new Args + _client.Post("reactions.add", new Args { { "name", name }, { "channel", channelId }, @@ -207,7 +207,7 @@ public Task List(string userId = null, bool full = fal /// File to remove reaction from. /// public Task RemoveFromFile(string name, string fileId, CancellationToken? cancellationToken = null) => - _client.Get("reactions.remove", new Args + _client.Post("reactions.remove", new Args { { "name", name }, { "file", fileId } @@ -220,7 +220,7 @@ public Task RemoveFromFile(string name, string fileId, CancellationToken? cancel /// File comment to remove reaction from. /// public Task RemoveFromFileComment(string name, string fileCommentId, CancellationToken? cancellationToken = null) => - _client.Get("reactions.remove", new Args + _client.Post("reactions.remove", new Args { { "name", name }, { "file_comment", fileCommentId } @@ -234,7 +234,7 @@ public Task RemoveFromFileComment(string name, string fileCommentId, Cancellatio /// Timestamp of the message to remove reaction from. /// public Task RemoveFromMessage(string name, string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Get("reactions.remove", new Args + _client.Post("reactions.remove", new Args { { "name", name }, { "channel", channelId }, diff --git a/SlackNet/WebApi/RemindersApi.cs b/SlackNet/WebApi/RemindersApi.cs index b8830f1..f354573 100644 --- a/SlackNet/WebApi/RemindersApi.cs +++ b/SlackNet/WebApi/RemindersApi.cs @@ -80,7 +80,7 @@ public class RemindersApi : IRemindersApi /// The user who will receive the reminder. If no user is specified, the reminder will go to user who created it. /// public async Task Add(string text, DateTime time, string userId = null, CancellationToken? cancellationToken = null) => - (await _client.Get("reminders.add", new Args + (await _client.Post("reminders.add", new Args { { "text", text }, { "time", time.ToTimestamp() }, @@ -96,7 +96,7 @@ public async Task Add(string text, DateTime time, string userId = null /// The user who will receive the reminder. If no user is specified, the reminder will go to user who created it. /// public async Task Add(string text, TimeSpan time, string userId = null, CancellationToken? cancellationToken = null) => - (await _client.Get("reminders.add", new Args + (await _client.Post("reminders.add", new Args { { "text", text }, { "time", time.ToOffset(TimeSpan.FromHours(24)) }, @@ -116,7 +116,7 @@ public async Task Add(string text, TimeSpan time, string userId = null /// The user who will receive the reminder. If no user is specified, the reminder will go to user who created it. /// public async Task Add(string text, string time, string userId = null, CancellationToken? cancellationToken = null) => - (await _client.Get("reminders.add", new Args + (await _client.Post("reminders.add", new Args { { "text", text }, { "time", time }, @@ -130,7 +130,7 @@ public async Task Add(string text, string time, string userId = null, /// The ID of the reminder to be marked as complete. /// public Task Complete(string reminderId, CancellationToken? cancellationToken = null) => - _client.Get("reminders.complete", new Args { { "reminder", reminderId } }, cancellationToken); + _client.Post("reminders.complete", new Args { { "reminder", reminderId } }, cancellationToken); /// /// Deletes a reminder. @@ -138,7 +138,7 @@ public Task Complete(string reminderId, CancellationToken? cancellationToken = n /// The ID of the reminder. /// public Task Delete(string reminderId, CancellationToken? cancellationToken = null) => - _client.Get("reminders.delete", new Args { { "reminder", reminderId } }, cancellationToken); + _client.Post("reminders.delete", new Args { { "reminder", reminderId } }, cancellationToken); /// /// Returns information about a reminder. diff --git a/SlackNet/WebApi/ScheduledMessagesApi.cs b/SlackNet/WebApi/ScheduledMessagesApi.cs index 690d138..0e6658e 100644 --- a/SlackNet/WebApi/ScheduledMessagesApi.cs +++ b/SlackNet/WebApi/ScheduledMessagesApi.cs @@ -54,7 +54,7 @@ public Task List( string cursor = null, CancellationToken? cancellationToken = null ) => - _client.Get("chat.scheduledMessages.list", new Args + _client.Post("chat.scheduledMessages.list", new Args { { "channel", channelId }, { "latest", latestTs }, diff --git a/SlackNet/WebApi/StarsApi.cs b/SlackNet/WebApi/StarsApi.cs index d7a4b67..40a653c 100644 --- a/SlackNet/WebApi/StarsApi.cs +++ b/SlackNet/WebApi/StarsApi.cs @@ -85,7 +85,7 @@ public class StarsApi : IStarsApi /// File to add star to. /// public Task AddToFile(string fileId, CancellationToken? cancellationToken = null) => - _client.Get("stars.add", new Args { { "file", fileId } }, cancellationToken); + _client.Post("stars.add", new Args { { "file", fileId } }, cancellationToken); /// /// Adds a star to a file comment. @@ -93,7 +93,7 @@ public Task AddToFile(string fileId, CancellationToken? cancellationToken = null /// File comment to add star to. /// public Task AddToFileComment(string fileCommentId, CancellationToken? cancellationToken = null) => - _client.Get("stars.add", new Args { { "file_comment", fileCommentId } }, cancellationToken); + _client.Post("stars.add", new Args { { "file_comment", fileCommentId } }, cancellationToken); /// /// Adds a star to a channel. @@ -101,7 +101,7 @@ public Task AddToFileComment(string fileCommentId, CancellationToken? cancellati /// Channel, private group, or DM to add star to. /// public Task AddToChannel(string channelId, CancellationToken? cancellationToken = null) => - _client.Get("stars.add", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("stars.add", new Args { { "channel", channelId } }, cancellationToken); /// /// Adds a star to a message. @@ -110,7 +110,7 @@ public Task AddToChannel(string channelId, CancellationToken? cancellationToken /// Timestamp of the message to add star to. /// public Task AddToMessage(string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Get("stars.add", new Args + _client.Post("stars.add", new Args { { "channel", channelId }, { "timestamp", ts } @@ -136,7 +136,7 @@ public Task List(int count = 100, int page = 1, CancellationTo /// File to remove star from. /// public Task RemoveFromFile(string fileId, CancellationToken? cancellationToken = null) => - _client.Get("stars.remove", new Args { { "file", fileId } }, cancellationToken); + _client.Post("stars.remove", new Args { { "file", fileId } }, cancellationToken); /// /// Removes a star from a file comment. @@ -144,7 +144,7 @@ public Task RemoveFromFile(string fileId, CancellationToken? cancellationToken = /// File comment to remove star from. /// public Task RemoveFromFileComment(string fileCommentId, CancellationToken? cancellationToken = null) => - _client.Get("stars.remove", new Args { { "file_comment", fileCommentId } }, cancellationToken); + _client.Post("stars.remove", new Args { { "file_comment", fileCommentId } }, cancellationToken); /// /// Removes a star from a channel. @@ -152,7 +152,7 @@ public Task RemoveFromFileComment(string fileCommentId, CancellationToken? cance /// Channel, private group, or DM to remove star from. /// public Task RemoveFromChannel(string channelId, CancellationToken? cancellationToken = null) => - _client.Get("stars.remove", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("stars.remove", new Args { { "channel", channelId } }, cancellationToken); /// /// Removes a star from a message. @@ -161,7 +161,7 @@ public Task RemoveFromChannel(string channelId, CancellationToken? cancellationT /// Timestamp of the message to remove star from. /// public Task RemoveFromMessage(string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Get("stars.remove", new Args + _client.Post("stars.remove", new Args { { "channel", channelId }, { "timestamp", ts } diff --git a/SlackNet/WebApi/UserGroupUsersApi.cs b/SlackNet/WebApi/UserGroupUsersApi.cs index 59b045c..05fe85f 100644 --- a/SlackNet/WebApi/UserGroupUsersApi.cs +++ b/SlackNet/WebApi/UserGroupUsersApi.cs @@ -54,7 +54,7 @@ public async Task> List(string userGroupId, bool includeDi /// Include the number of users in the User Group. /// public async Task Update(string userGroupId, IEnumerable userIds, bool includeCount = false, CancellationToken? cancellationToken = null) => - (await _client.Get("usergroups.users.update", new Args + (await _client.Post("usergroups.users.update", new Args { { "usergroup", userGroupId }, { "users", userIds }, diff --git a/SlackNet/WebApi/UserGroupsApi.cs b/SlackNet/WebApi/UserGroupsApi.cs index accc7ab..374f0be 100644 --- a/SlackNet/WebApi/UserGroupsApi.cs +++ b/SlackNet/WebApi/UserGroupsApi.cs @@ -93,7 +93,7 @@ public async Task Create( bool includeCount = false, CancellationToken? cancellationToken = null ) => - (await _client.Get("usergroups.create", new Args + (await _client.Post("usergroups.create", new Args { { "name", name }, { "channels", channelIds }, @@ -110,7 +110,7 @@ public async Task Create( /// Include the number of users in the User Group. /// public async Task Disable(string userGroupId, bool includeCount = false, CancellationToken? cancellationToken = null) => - (await _client.Get("usergroups.disable", new Args + (await _client.Post("usergroups.disable", new Args { { "usergroup", userGroupId }, { "include_count", includeCount } @@ -124,7 +124,7 @@ public async Task Disable(string userGroupId, bool includeCount = fal /// Include the number of users in the User Group. /// public async Task Enable(string userGroupId, bool includeCount = false, CancellationToken? cancellationToken = null) => - (await _client.Get("usergroups.enable", new Args + (await _client.Post("usergroups.enable", new Args { { "usergroup", userGroupId }, { "include_count", includeCount } @@ -166,7 +166,7 @@ public async Task Update( string name = null, CancellationToken? cancellationToken = null ) => - (await _client.Get("usergroups.create", new Args + (await _client.Post("usergroups.update", new Args { { "usergroup", userGroupId }, { "channels", channelIds }, diff --git a/SlackNet/WebApi/UserProfileApi.cs b/SlackNet/WebApi/UserProfileApi.cs index 6865935..f528eb6 100644 --- a/SlackNet/WebApi/UserProfileApi.cs +++ b/SlackNet/WebApi/UserProfileApi.cs @@ -59,7 +59,7 @@ public async Task Get(bool includeLabels = false, string userId = n /// ID of user to change (defaults to authed user). This argument may only be specified by team admins on paid teams. /// public async Task Set(string name, string value, string userId = null, CancellationToken? cancellationToken = null) => - (await _client.Get("users.profile.set", new Args + (await _client.Post("users.profile.set", new Args { { "name", name }, { "value", value }, @@ -74,7 +74,7 @@ public async Task Set(string name, string value, string userId = nu /// ID of user to change (defaults to authed user). This argument may only be specified by team admins on paid teams. /// public async Task Set(UserProfile profile, string userId = null, CancellationToken? cancellationToken = null) => - (await _client.Get("users.profile.set", new Args + (await _client.Post("users.profile.set", new Args { { "profile", profile }, { "user", userId } diff --git a/SlackNet/WebApi/UsersApi.cs b/SlackNet/WebApi/UsersApi.cs index 0b6e09c..e24f8be 100644 --- a/SlackNet/WebApi/UsersApi.cs +++ b/SlackNet/WebApi/UsersApi.cs @@ -269,6 +269,6 @@ public Task SetPhoto(Stream image, string contentType, string fileName = "photo" /// User's presence. /// public Task SetPresence(Presence presence, CancellationToken? cancellationToken = null) => - _client.Get("users.setPresence", new Args { { "presence", presence } }, cancellationToken); + _client.Post("users.setPresence", new Args { { "presence", presence } }, cancellationToken); } } From 21384736408ee4aa0b6a306c8f3c0ddfb02620f9 Mon Sep 17 00:00:00 2001 From: mrmurb Date: Mon, 26 Aug 2019 10:18:05 +0200 Subject: [PATCH 6/6] Implements new Post in ISlackApiClient --- SlackNet.Tests/ApiLintTest.cs | 3 +++ SlackNet/SlackApiClient.cs | 36 +++++++++++++++++++++-------- SlackNet/WebApi/ChannelsApi.cs | 10 ++++---- SlackNet/WebApi/ChatApi.cs | 2 +- SlackNet/WebApi/ConversationsApi.cs | 10 ++++---- SlackNet/WebApi/DialogApi.cs | 2 +- SlackNet/WebApi/DndApi.cs | 2 +- SlackNet/WebApi/FileCommentsApi.cs | 2 +- SlackNet/WebApi/FilesApi.cs | 2 +- SlackNet/WebApi/GroupsApi.cs | 12 +++++----- SlackNet/WebApi/ImApi.cs | 4 ++-- SlackNet/WebApi/MpimApi.cs | 4 ++-- SlackNet/WebApi/PinsApi.cs | 12 +++++----- SlackNet/WebApi/ReactionsApi.cs | 12 +++++----- SlackNet/WebApi/RemindersApi.cs | 4 ++-- SlackNet/WebApi/StarsApi.cs | 16 ++++++------- SlackNet/WebApi/UsersApi.cs | 2 +- 17 files changed, 77 insertions(+), 58 deletions(-) diff --git a/SlackNet.Tests/ApiLintTest.cs b/SlackNet.Tests/ApiLintTest.cs index d559ee2..4131632 100644 --- a/SlackNet.Tests/ApiLintTest.cs +++ b/SlackNet.Tests/ApiLintTest.cs @@ -140,6 +140,9 @@ public Task Post(string apiMethod, Args args, HttpContent content, CancellationT return Task.FromResult(0); } + public Task Post(string apiMethod, Args args, CancellationToken? cancellationToken) => + Post(apiMethod, args, cancellationToken); + public Task Post(string apiMethod, Args args, CancellationToken? cancellationToken) where T : class { HttpMethod = "POST"; diff --git a/SlackNet/SlackApiClient.cs b/SlackNet/SlackApiClient.cs index afd9379..d6e709e 100644 --- a/SlackNet/SlackApiClient.cs +++ b/SlackNet/SlackApiClient.cs @@ -62,20 +62,28 @@ public interface ISlackApiClient /// Calls a Slack API that requires POST content. /// /// Name of Slack method. - /// Arguments to send to Slack. The "token" parameter will be filled in automatically. - /// POST body content. Should be either or . + /// Arguments to send to Slack. Authorization headers will be added automatically. /// - Task Post(string apiMethod, Args args, HttpContent content, CancellationToken? cancellationToken); - + Task Post(string apiMethod, Args args, CancellationToken? cancellationToken); + /// /// Calls a Slack API that requires POST content. /// /// Type of response expected. /// Name of Slack method. - /// Arguments to send to Slack. Authorization headers will be added automagically. + /// Arguments to send to Slack. Authorization headers will be added automatically. /// Task Post(string apiMethod, Args args, CancellationToken? cancellationToken) where T : class; + /// + /// Calls a Slack API that requires POST content. + /// + /// Name of Slack method. + /// Arguments to send to Slack. The "token" parameter will be filled in automatically. + /// POST body content. Should be either or . + /// + Task Post(string apiMethod, Args args, HttpContent content, CancellationToken? cancellationToken); + /// /// Calls a Slack API that requires POST content. /// @@ -161,17 +169,15 @@ public async Task Get(string apiMethod, Args args, CancellationToken? canc var requestMessage = new HttpRequestMessage(HttpMethod.Get, Url(apiMethod, args)); return Deserialize(await _http.Execute(requestMessage, cancellationToken ?? CancellationToken.None).ConfigureAwait(false)); } - - + /// /// Calls a Slack API that requires POST content. /// /// Name of Slack method. /// Arguments to send to Slack. The "token" parameter will be filled in automatically. - /// POST body content. Should be either or . /// - public Task Post(string apiMethod, Args args, HttpContent content, CancellationToken? cancellationToken) => - Post(apiMethod, args, content, cancellationToken); + public Task Post(string apiMethod, Args args, CancellationToken? cancellationToken) => + Post(apiMethod, args, cancellationToken); /// /// Calls a Slack API that requires POST content. @@ -190,6 +196,16 @@ public async Task Post(string apiMethod, Args args, CancellationToken? can return Deserialize(response); } + /// + /// Calls a Slack API that requires POST content. + /// + /// Name of Slack method. + /// Arguments to send to Slack. The "token" parameter will be filled in automatically. + /// POST body content. Should be either or . + /// + public Task Post(string apiMethod, Args args, HttpContent content, CancellationToken? cancellationToken) => + Post(apiMethod, args, content, cancellationToken); + /// /// Calls a Slack API that requires POST content. /// diff --git a/SlackNet/WebApi/ChannelsApi.cs b/SlackNet/WebApi/ChannelsApi.cs index ee4656f..bdd985b 100644 --- a/SlackNet/WebApi/ChannelsApi.cs +++ b/SlackNet/WebApi/ChannelsApi.cs @@ -162,7 +162,7 @@ public class ChannelsApi : IChannelsApi /// /// public Task Archive(string channelId, CancellationToken? cancellationToken = null) => - _client.Post("channels.archive", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("channels.archive", new Args { { "channel", channelId } }, cancellationToken); /// /// Used to create a channel. @@ -253,7 +253,7 @@ public Task Join(string channelName, bool validate = false, /// User to remove from channel. /// public Task Kick(string channelId, string userId, CancellationToken? cancellationToken = null) => - _client.Post("channels.kick", new Args + _client.Post("channels.kick", new Args { { "channel", channelId }, { "user", userId } @@ -266,7 +266,7 @@ public Task Kick(string channelId, string userId, CancellationToken? cancellatio /// /// public Task Leave(string channelId, CancellationToken? cancellationToken = null) => - _client.Post("channels.leave", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("channels.leave", new Args { { "channel", channelId } }, cancellationToken); /// /// Returns a list of all channels in the team. @@ -292,7 +292,7 @@ public async Task> List(bool excludeArchived = false, boo /// Timestamp of the most recently seen message. /// public Task Mark(string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Post("channels.mark", new Args + _client.Post("channels.mark", new Args { { "channel", channelId }, { "ts", ts } @@ -366,6 +366,6 @@ public async Task SetTopic(string channelId, string topic, CancellationT /// Channel to unarchive. /// public Task Unarchive(string channelId, CancellationToken? cancellationToken = null) => - _client.Post("channels.unarchive", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("channels.unarchive", new Args { { "channel", channelId } }, cancellationToken); } } \ No newline at end of file diff --git a/SlackNet/WebApi/ChatApi.cs b/SlackNet/WebApi/ChatApi.cs index 1a69eb8..34494da 100644 --- a/SlackNet/WebApi/ChatApi.cs +++ b/SlackNet/WebApi/ChatApi.cs @@ -186,7 +186,7 @@ public Task PostEphemeral(string userId, Message message, C /// Subsequent attempts with the same and values will modify the same attachments, rather than adding more. /// public Task Unfurl(string channelId, string ts, IDictionary unfurls, bool userAuthRequired = false, CancellationToken? cancellationToken = null) => - _client.Post("chat.unfurl", new Args + _client.Post("chat.unfurl", new Args { { "channel", channelId }, { "ts", ts }, diff --git a/SlackNet/WebApi/ConversationsApi.cs b/SlackNet/WebApi/ConversationsApi.cs index 5c7c393..da81237 100644 --- a/SlackNet/WebApi/ConversationsApi.cs +++ b/SlackNet/WebApi/ConversationsApi.cs @@ -207,7 +207,7 @@ public class ConversationsApi : IConversationsApi /// ID of conversation to archive. /// public Task Archive(string channelId, CancellationToken? cancellationToken = null) => - _client.Post("conversations.archive", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("conversations.archive", new Args { { "channel", channelId } }, cancellationToken); /// /// Closes a direct message or multi-person direct message. @@ -216,7 +216,7 @@ public Task Archive(string channelId, CancellationToken? cancellationToken = nul /// /// public Task Close(string channelId, CancellationToken? cancellationToken = null) => - _client.Post("conversations.close", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("conversations.close", new Args { { "channel", channelId } }, cancellationToken); /// /// Initiates a public or private channel-based conversation. @@ -303,7 +303,7 @@ public Task Join(string channelId, CancellationToken? /// User ID to be removed. /// public Task Kick(string channelId, string userId, CancellationToken? cancellationToken = null) => - _client.Post("conversations.kick", new Args + _client.Post("conversations.kick", new Args { { "channel", channelId }, { "user", userId } @@ -315,7 +315,7 @@ public Task Kick(string channelId, string userId, CancellationToken? cancellatio /// Conversation to leave. /// public Task Leave(string channelId, CancellationToken? cancellationToken = null) => - _client.Post("conversations.leave", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("conversations.leave", new Args { { "channel", channelId } }, cancellationToken); /// /// Lists all channels in a Slack team. @@ -478,6 +478,6 @@ public async Task SetTopic(string channelId, string topic, CancellationT /// ID of conversation to unarchive. /// public Task Unarchive(string channelId, CancellationToken? cancellationToken = null) => - _client.Post("conversations.unarchive", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("conversations.unarchive", new Args { { "channel", channelId } }, cancellationToken); } } \ No newline at end of file diff --git a/SlackNet/WebApi/DialogApi.cs b/SlackNet/WebApi/DialogApi.cs index 9c49032..37db3d4 100644 --- a/SlackNet/WebApi/DialogApi.cs +++ b/SlackNet/WebApi/DialogApi.cs @@ -28,7 +28,7 @@ public class DialogApi : IDialogApi /// The dialog definition. /// public Task Open(string triggerId, Dialog dialog, CancellationToken? cancellationToken = null) => - _client.Post("dialog.open", new Args + _client.Post("dialog.open", new Args { { "dialog", dialog }, { "trigger_id", triggerId } diff --git a/SlackNet/WebApi/DndApi.cs b/SlackNet/WebApi/DndApi.cs index fae9021..f3afb65 100644 --- a/SlackNet/WebApi/DndApi.cs +++ b/SlackNet/WebApi/DndApi.cs @@ -59,7 +59,7 @@ public class DndApi : IDndApi /// /// public Task EndDnd(CancellationToken? cancellationToken = null) => - _client.Post("dnd.endDnd", new Args(), cancellationToken); + _client.Post("dnd.endDnd", new Args(), cancellationToken); /// /// Ends the current user's snooze mode immediately. diff --git a/SlackNet/WebApi/FileCommentsApi.cs b/SlackNet/WebApi/FileCommentsApi.cs index 00ec928..1a37722 100644 --- a/SlackNet/WebApi/FileCommentsApi.cs +++ b/SlackNet/WebApi/FileCommentsApi.cs @@ -29,7 +29,7 @@ public class FileCommentsApi : IFileCommentsApi /// The comment to delete. /// public Task Delete(string fileId, string commentId, CancellationToken? cancellationToken = null) => - _client.Post("files.comments.delete", new Args + _client.Post("files.comments.delete", new Args { { "file", fileId }, { "id", commentId } diff --git a/SlackNet/WebApi/FilesApi.cs b/SlackNet/WebApi/FilesApi.cs index 234784a..3a4970e 100644 --- a/SlackNet/WebApi/FilesApi.cs +++ b/SlackNet/WebApi/FilesApi.cs @@ -164,7 +164,7 @@ public class FilesApi : IFilesApi /// ID of file to delete. /// public Task Delete(string fileId, CancellationToken? cancellationToken = null) => - _client.Post("files.delete", new Args { { "file", fileId } }, cancellationToken); + _client.Post("files.delete", new Args { { "file", fileId } }, cancellationToken); /// /// Returns information about a file in your team. diff --git a/SlackNet/WebApi/GroupsApi.cs b/SlackNet/WebApi/GroupsApi.cs index 4514f44..9a8a4b0 100644 --- a/SlackNet/WebApi/GroupsApi.cs +++ b/SlackNet/WebApi/GroupsApi.cs @@ -172,7 +172,7 @@ public class GroupsApi : IGroupsApi /// Private channel to archive. /// public Task Archive(string channelId, CancellationToken? cancellationToken = null) => - _client.Post("groups.archive", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("groups.archive", new Args { { "channel", channelId } }, cancellationToken); /// /// Closes a private channel. @@ -270,7 +270,7 @@ public async Task Invite(string channelId, string userId, CancellationT /// /// public Task Kick(string channelId, string userId, CancellationToken? cancellationToken = null) => - _client.Post("groups.kick", new Args + _client.Post("groups.kick", new Args { { "channel", channelId }, { "user", userId } @@ -282,7 +282,7 @@ public Task Kick(string channelId, string userId, CancellationToken? cancellatio /// Private channel to leave. /// public Task Leave(string channelId, CancellationToken? cancellationToken = null) => - _client.Post("groups.leave", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("groups.leave", new Args { { "channel", channelId } }, cancellationToken); /// /// Returns a list of private channels in the team that the caller is in and archived groups that the caller was in. @@ -300,7 +300,7 @@ public async Task> List(bool excludeArchived = false, Can /// Timestamp of the most recently seen message. /// public Task Mark(string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Post("groups.mark", new Args { { "channel", channelId }, { "ts", ts } }, cancellationToken); + _client.Post("groups.mark", new Args { { "channel", channelId }, { "ts", ts } }, cancellationToken); /// /// Opens a private channel. @@ -309,7 +309,7 @@ public Task Mark(string channelId, string ts, CancellationToken? cancellationTok /// /// public Task Open(string channelId, CancellationToken? cancellationToken = null) => - _client.Post("groups.open", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("groups.open", new Args { { "channel", channelId } }, cancellationToken); /// /// Renames a private channel. @@ -377,6 +377,6 @@ public async Task SetTopic(string channelId, string topic, CancellationT /// Private channel to unarchive. /// public Task Unarchive(string channelId, CancellationToken? cancellationToken = null) => - _client.Post("groups.unarchive", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("groups.unarchive", new Args { { "channel", channelId } }, cancellationToken); } } \ No newline at end of file diff --git a/SlackNet/WebApi/ImApi.cs b/SlackNet/WebApi/ImApi.cs index cd2655d..f06cc08 100644 --- a/SlackNet/WebApi/ImApi.cs +++ b/SlackNet/WebApi/ImApi.cs @@ -80,7 +80,7 @@ public class ImApi : IImApi /// Direct message channel to close. /// public Task Close(string channelId, CancellationToken? cancellationToken = null) => - _client.Post("im.close", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("im.close", new Args { { "channel", channelId } }, cancellationToken); /// /// Returns a portion of message events from the specified direct message channel. @@ -129,7 +129,7 @@ public async Task> List(CancellationToken? cancellationToken = /// Timestamp of the most recently seen message. /// public Task Mark(string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Post("im.mark", new Args + _client.Post("im.mark", new Args { { "channel", channelId }, { "ts", ts } diff --git a/SlackNet/WebApi/MpimApi.cs b/SlackNet/WebApi/MpimApi.cs index 3beef15..83a5646 100644 --- a/SlackNet/WebApi/MpimApi.cs +++ b/SlackNet/WebApi/MpimApi.cs @@ -79,7 +79,7 @@ public class MpimApi : IMpimApi /// MPIM to close. /// public Task Close(string channelId, CancellationToken? cancellationToken = null) => - _client.Post("mpim.close", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("mpim.close", new Args { { "channel", channelId } }, cancellationToken); /// /// Returns a portion of message events from the specified multiparty direct message channel. @@ -128,7 +128,7 @@ public async Task> List(CancellationToken? cancellationTo /// Timestamp of the most recently seen message. /// public Task Mark(string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Post("mpim.mark", new Args + _client.Post("mpim.mark", new Args { { "channel", channelId }, { "ts", ts } diff --git a/SlackNet/WebApi/PinsApi.cs b/SlackNet/WebApi/PinsApi.cs index a81449d..d23e198 100644 --- a/SlackNet/WebApi/PinsApi.cs +++ b/SlackNet/WebApi/PinsApi.cs @@ -80,7 +80,7 @@ public class PinsApi : IPinsApi /// File to pin. /// public Task AddFile(string channelId, string fileId, CancellationToken? cancellationToken = null) => - _client.Post("pins.add", new Args + _client.Post("pins.add", new Args { { "channel", channelId }, { "file", fileId } @@ -93,7 +93,7 @@ public Task AddFile(string channelId, string fileId, CancellationToken? cancella /// File comment to pin. /// public Task AddFileComment(string channelId, string fileCommentId, CancellationToken? cancellationToken = null) => - _client.Post("pins.add", new Args + _client.Post("pins.add", new Args { { "channel", channelId }, { "file_comment", fileCommentId }, @@ -106,7 +106,7 @@ public Task AddFileComment(string channelId, string fileCommentId, CancellationT /// Timestamp of the message to pin. /// public Task AddMessage(string channelId, string ts = null, CancellationToken? cancellationToken = null) => - _client.Post("pins.add", new Args + _client.Post("pins.add", new Args { { "channel", channelId }, { "timestamp", ts } @@ -127,7 +127,7 @@ public async Task> List(string channelId, Cancellation /// File to un-pin. /// public Task RemoveFile(string channelId, string fileId, CancellationToken? cancellationToken = null) => - _client.Post("pins.remove", new Args + _client.Post("pins.remove", new Args { { "channel", channelId }, { "file", fileId } @@ -140,7 +140,7 @@ public Task RemoveFile(string channelId, string fileId, CancellationToken? cance /// File comment to un-pin. /// public Task RemoveFileComment(string channelId, string fileCommentId, CancellationToken? cancellationToken = null) => - _client.Post("pins.remove", new Args + _client.Post("pins.remove", new Args { { "channel", channelId }, { "file_comment", fileCommentId } @@ -153,7 +153,7 @@ public Task RemoveFileComment(string channelId, string fileCommentId, Cancellati /// Timestamp of the message to un-pin. /// public Task RemoveMessage(string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Post("pins.remove", new Args + _client.Post("pins.remove", new Args { { "channel", channelId }, { "timestamp", ts } diff --git a/SlackNet/WebApi/ReactionsApi.cs b/SlackNet/WebApi/ReactionsApi.cs index 84f67ed..7ff2090 100644 --- a/SlackNet/WebApi/ReactionsApi.cs +++ b/SlackNet/WebApi/ReactionsApi.cs @@ -105,7 +105,7 @@ public class ReactionsApi : IReactionsApi /// File to add reaction to. /// public Task AddToFile(string name, string fileId, CancellationToken? cancellationToken = null) => - _client.Post("reactions.add", new Args + _client.Post("reactions.add", new Args { { "name", name }, { "file", fileId } @@ -118,7 +118,7 @@ public Task AddToFile(string name, string fileId, CancellationToken? cancellatio /// File comment to add reaction to. /// public Task AddToFileComment(string name, string fileCommentId, CancellationToken? cancellationToken = null) => - _client.Post("reactions.add", new Args + _client.Post("reactions.add", new Args { { "name", name }, { "file_comment", fileCommentId } @@ -132,7 +132,7 @@ public Task AddToFileComment(string name, string fileCommentId, CancellationToke /// Timestamp of the message to add reaction to. /// public Task AddToMessage(string name, string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Post("reactions.add", new Args + _client.Post("reactions.add", new Args { { "name", name }, { "channel", channelId }, @@ -207,7 +207,7 @@ public Task List(string userId = null, bool full = fal /// File to remove reaction from. /// public Task RemoveFromFile(string name, string fileId, CancellationToken? cancellationToken = null) => - _client.Post("reactions.remove", new Args + _client.Post("reactions.remove", new Args { { "name", name }, { "file", fileId } @@ -220,7 +220,7 @@ public Task RemoveFromFile(string name, string fileId, CancellationToken? cancel /// File comment to remove reaction from. /// public Task RemoveFromFileComment(string name, string fileCommentId, CancellationToken? cancellationToken = null) => - _client.Post("reactions.remove", new Args + _client.Post("reactions.remove", new Args { { "name", name }, { "file_comment", fileCommentId } @@ -234,7 +234,7 @@ public Task RemoveFromFileComment(string name, string fileCommentId, Cancellatio /// Timestamp of the message to remove reaction from. /// public Task RemoveFromMessage(string name, string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Post("reactions.remove", new Args + _client.Post("reactions.remove", new Args { { "name", name }, { "channel", channelId }, diff --git a/SlackNet/WebApi/RemindersApi.cs b/SlackNet/WebApi/RemindersApi.cs index f354573..cc8db8b 100644 --- a/SlackNet/WebApi/RemindersApi.cs +++ b/SlackNet/WebApi/RemindersApi.cs @@ -130,7 +130,7 @@ public async Task Add(string text, string time, string userId = null, /// The ID of the reminder to be marked as complete. /// public Task Complete(string reminderId, CancellationToken? cancellationToken = null) => - _client.Post("reminders.complete", new Args { { "reminder", reminderId } }, cancellationToken); + _client.Post("reminders.complete", new Args { { "reminder", reminderId } }, cancellationToken); /// /// Deletes a reminder. @@ -138,7 +138,7 @@ public Task Complete(string reminderId, CancellationToken? cancellationToken = n /// The ID of the reminder. /// public Task Delete(string reminderId, CancellationToken? cancellationToken = null) => - _client.Post("reminders.delete", new Args { { "reminder", reminderId } }, cancellationToken); + _client.Post("reminders.delete", new Args { { "reminder", reminderId } }, cancellationToken); /// /// Returns information about a reminder. diff --git a/SlackNet/WebApi/StarsApi.cs b/SlackNet/WebApi/StarsApi.cs index 40a653c..19b2d07 100644 --- a/SlackNet/WebApi/StarsApi.cs +++ b/SlackNet/WebApi/StarsApi.cs @@ -85,7 +85,7 @@ public class StarsApi : IStarsApi /// File to add star to. /// public Task AddToFile(string fileId, CancellationToken? cancellationToken = null) => - _client.Post("stars.add", new Args { { "file", fileId } }, cancellationToken); + _client.Post("stars.add", new Args { { "file", fileId } }, cancellationToken); /// /// Adds a star to a file comment. @@ -93,7 +93,7 @@ public Task AddToFile(string fileId, CancellationToken? cancellationToken = null /// File comment to add star to. /// public Task AddToFileComment(string fileCommentId, CancellationToken? cancellationToken = null) => - _client.Post("stars.add", new Args { { "file_comment", fileCommentId } }, cancellationToken); + _client.Post("stars.add", new Args { { "file_comment", fileCommentId } }, cancellationToken); /// /// Adds a star to a channel. @@ -101,7 +101,7 @@ public Task AddToFileComment(string fileCommentId, CancellationToken? cancellati /// Channel, private group, or DM to add star to. /// public Task AddToChannel(string channelId, CancellationToken? cancellationToken = null) => - _client.Post("stars.add", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("stars.add", new Args { { "channel", channelId } }, cancellationToken); /// /// Adds a star to a message. @@ -110,7 +110,7 @@ public Task AddToChannel(string channelId, CancellationToken? cancellationToken /// Timestamp of the message to add star to. /// public Task AddToMessage(string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Post("stars.add", new Args + _client.Post("stars.add", new Args { { "channel", channelId }, { "timestamp", ts } @@ -136,7 +136,7 @@ public Task List(int count = 100, int page = 1, CancellationTo /// File to remove star from. /// public Task RemoveFromFile(string fileId, CancellationToken? cancellationToken = null) => - _client.Post("stars.remove", new Args { { "file", fileId } }, cancellationToken); + _client.Post("stars.remove", new Args { { "file", fileId } }, cancellationToken); /// /// Removes a star from a file comment. @@ -144,7 +144,7 @@ public Task RemoveFromFile(string fileId, CancellationToken? cancellationToken = /// File comment to remove star from. /// public Task RemoveFromFileComment(string fileCommentId, CancellationToken? cancellationToken = null) => - _client.Post("stars.remove", new Args { { "file_comment", fileCommentId } }, cancellationToken); + _client.Post("stars.remove", new Args { { "file_comment", fileCommentId } }, cancellationToken); /// /// Removes a star from a channel. @@ -152,7 +152,7 @@ public Task RemoveFromFileComment(string fileCommentId, CancellationToken? cance /// Channel, private group, or DM to remove star from. /// public Task RemoveFromChannel(string channelId, CancellationToken? cancellationToken = null) => - _client.Post("stars.remove", new Args { { "channel", channelId } }, cancellationToken); + _client.Post("stars.remove", new Args { { "channel", channelId } }, cancellationToken); /// /// Removes a star from a message. @@ -161,7 +161,7 @@ public Task RemoveFromChannel(string channelId, CancellationToken? cancellationT /// Timestamp of the message to remove star from. /// public Task RemoveFromMessage(string channelId, string ts, CancellationToken? cancellationToken = null) => - _client.Post("stars.remove", new Args + _client.Post("stars.remove", new Args { { "channel", channelId }, { "timestamp", ts } diff --git a/SlackNet/WebApi/UsersApi.cs b/SlackNet/WebApi/UsersApi.cs index e24f8be..107f12e 100644 --- a/SlackNet/WebApi/UsersApi.cs +++ b/SlackNet/WebApi/UsersApi.cs @@ -269,6 +269,6 @@ public Task SetPhoto(Stream image, string contentType, string fileName = "photo" /// User's presence. /// public Task SetPresence(Presence presence, CancellationToken? cancellationToken = null) => - _client.Post("users.setPresence", new Args { { "presence", presence } }, cancellationToken); + _client.Post("users.setPresence", new Args { { "presence", presence } }, cancellationToken); } }