Skip to content

Commit

Permalink
use preferred HTTP method according to Slack Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmurb committed Aug 20, 2019
1 parent 390b4cf commit 3e8e4ee
Show file tree
Hide file tree
Showing 21 changed files with 88 additions and 88 deletions.
2 changes: 1 addition & 1 deletion SlackNet/WebApi/ApiApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class ApiApi : IApiApi
public async Task<IReadOnlyDictionary<string, string>> Test(string error, Args args, CancellationToken? cancellationToken = null)
{
var query = new Args(args) { ["error"] = error };
return (await _client.Get<TestResponse>("api.test", query, cancellationToken).ConfigureAwait(false)).Args;
return (await _client.Post<TestResponse>("api.test", query, cancellationToken).ConfigureAwait(false)).Args;
}
}
}
2 changes: 1 addition & 1 deletion SlackNet/WebApi/AuthApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public async Task<bool> Revoke(bool test, CancellationToken? cancellationToken =
/// Checks authentication and tells you who you are.
/// </summary>
public Task<AuthTestResponse> Test(CancellationToken? cancellationToken = null) =>
_client.Get<AuthTestResponse>("auth.test", new Args(), cancellationToken);
_client.Post<AuthTestResponse>("auth.test", new Args(), cancellationToken);
}
}
22 changes: 11 additions & 11 deletions SlackNet/WebApi/ChannelsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public class ChannelsApi : IChannelsApi
/// <param name="cancellationToken"></param>
/// <returns></returns>
public Task Archive(string channelId, CancellationToken? cancellationToken = null) =>
_client.Get("channels.archive", new Args { { "channel", channelId } }, cancellationToken);
_client.Post<object>("channels.archive", new Args { { "channel", channelId } }, cancellationToken);

/// <summary>
/// Used to create a channel.
Expand All @@ -172,7 +172,7 @@ public Task Archive(string channelId, CancellationToken? cancellationToken = nul
/// <param name="validate">Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.</param>
/// <param name="cancellationToken"></param>
public async Task<Channel> Create(string name, bool validate = false, CancellationToken? cancellationToken = null) =>
(await _client.Get<ChannelResponse>("channels.create", new Args
(await _client.Post<ChannelResponse>("channels.create", new Args
{
{ "name", name },
{ "validate", validate }
Expand Down Expand Up @@ -220,7 +220,7 @@ public async Task<Channel> Info(string channelId, CancellationToken? cancellatio
/// <param name="userId">User to invite to channel.</param>
/// <param name="cancellationToken"></param>
public async Task<Channel> Invite(string channelId, string userId, CancellationToken? cancellationToken = null) =>
(await _client.Get<ChannelResponse>("channels.invite", new Args
(await _client.Post<ChannelResponse>("channels.invite", new Args
{
{ "channel", channelId },
{ "user", userId }
Expand All @@ -240,7 +240,7 @@ public async Task<Channel> 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.
/// </returns>
public Task<ChannelJoinResponse> Join(string channelName, bool validate = false, CancellationToken? cancellationToken = null) =>
_client.Get<ChannelJoinResponse>("channels.join", new Args
_client.Post<ChannelJoinResponse>("channels.join", new Args
{
{ "channel", channelName },
{ "validate", validate }
Expand All @@ -253,7 +253,7 @@ public Task<ChannelJoinResponse> Join(string channelName, bool validate = false,
/// <param name="userId">User to remove from channel.</param>
/// <param name="cancellationToken"></param>
public Task Kick(string channelId, string userId, CancellationToken? cancellationToken = null) =>
_client.Get("channels.kick", new Args
_client.Post<object>("channels.kick", new Args
{
{ "channel", channelId },
{ "user", userId }
Expand All @@ -266,7 +266,7 @@ public Task Kick(string channelId, string userId, CancellationToken? cancellatio
/// <param name="cancellationToken"></param>
/// <returns></returns>
public Task Leave(string channelId, CancellationToken? cancellationToken = null) =>
_client.Get("channels.leave", new Args { { "channel", channelId } }, cancellationToken);
_client.Post<object>("channels.leave", new Args { { "channel", channelId } }, cancellationToken);

/// <summary>
/// Returns a list of all channels in the team.
Expand All @@ -292,7 +292,7 @@ public async Task<IReadOnlyList<Channel>> List(bool excludeArchived = false, boo
/// <param name="ts">Timestamp of the most recently seen message.</param>
/// <param name="cancellationToken"></param>
public Task Mark(string channelId, string ts, CancellationToken? cancellationToken = null) =>
_client.Get("channels.mark", new Args
_client.Post<object>("channels.mark", new Args
{
{ "channel", channelId },
{ "ts", ts }
Expand All @@ -308,7 +308,7 @@ public Task Mark(string channelId, string ts, CancellationToken? cancellationTok
/// <param name="validate">Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.</param>
/// <param name="cancellationToken"></param>
public async Task<Channel> Rename(string channelId, string name, bool validate = false, CancellationToken? cancellationToken = null) =>
(await _client.Get<ChannelResponse>("channels.rename", new Args
(await _client.Post<ChannelResponse>("channels.rename", new Args
{
{ "channel", channelId },
{ "name", name },
Expand Down Expand Up @@ -338,7 +338,7 @@ public async Task<IReadOnlyList<MessageEvent>> Replies(string channelId, string
/// <param name="cancellationToken"></param>
/// <returns>The channel's new purpose.</returns>
public async Task<string> SetPurpose(string channelId, string purpose, CancellationToken? cancellationToken = null) =>
(await _client.Get<PurposeResponse>("channels.setPurpose", new Args
(await _client.Post<PurposeResponse>("channels.setPurpose", new Args
{
{ "channel", channelId },
{ "purpose", purpose }
Expand All @@ -353,7 +353,7 @@ public async Task<string> SetPurpose(string channelId, string purpose, Cancellat
/// <param name="cancellationToken"></param>
/// <returns>The channel's new topic.</returns>
public async Task<string> SetTopic(string channelId, string topic, CancellationToken? cancellationToken = null) =>
(await _client.Get<TopicResponse>("channels.setTopic", new Args
(await _client.Post<TopicResponse>("channels.setTopic", new Args
{
{ "channel", channelId },
{ "topic", topic }
Expand All @@ -366,6 +366,6 @@ public async Task<string> SetTopic(string channelId, string topic, CancellationT
/// <param name="channelId">Channel to unarchive.</param>
/// <param name="cancellationToken"></param>
public Task Unarchive(string channelId, CancellationToken? cancellationToken = null) =>
_client.Get("channels.unarchive", new Args { { "channel", channelId } }, cancellationToken);
_client.Post<object>("channels.unarchive", new Args { { "channel", channelId } }, cancellationToken);
}
}
10 changes: 5 additions & 5 deletions SlackNet/WebApi/ChatApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class ChatApi : IChatApi
/// <param name="asUser">Pass True to delete the message as the authed user. Bot users in this context are considered authed users.</param>
/// <param name="cancellationToken"></param>
public Task<MessageTsResponse> Delete(string ts, string channelId, bool asUser = false, CancellationToken? cancellationToken = null) =>
_client.Get<MessageTsResponse>("chat.delete", new Args
_client.Post<MessageTsResponse>("chat.delete", new Args
{
{ "ts", ts },
{ "channel", channelId },
Expand All @@ -104,7 +104,7 @@ public Task<PermalinkResponse> GetPermalink(string channelId, string messageTs,
/// <param name="text">Text of the message to send.</param>
/// <param name="cancellationToken"></param>
public Task<MessageTsResponse> MeMessage(string channel, string text, CancellationToken? cancellationToken = null) =>
_client.Get<MessageTsResponse>("chat.meMessage", new Args
_client.Post<MessageTsResponse>("chat.meMessage", new Args
{
{ "channel", channel },
{ "text", text }
Expand All @@ -126,7 +126,7 @@ public Task<PostMessageResponse> PostMessage(Message message, CancellationToken?
/// <param name="postAt">Time in the future to send the message.</param>
/// <param name="cancellationToken"></param>
public Task<ScheduleMessageResponse> ScheduleMessage(Message message, DateTime postAt, CancellationToken? cancellationToken = null) =>
_client.Get<ScheduleMessageResponse>("chat.scheduleMessage", PopulateMessageArgs(message, new Args
_client.Post<ScheduleMessageResponse>("chat.scheduleMessage", PopulateMessageArgs(message, new Args
{
{ "post_at", postAt.ToTimestamp() }
}),
Expand Down Expand Up @@ -186,7 +186,7 @@ public Task<PostMessageResponse> PostEphemeral(string userId, Message message, C
/// Subsequent attempts with the same <see cref="ts"/> and <see cref="channelId"/> values will modify the same attachments, rather than adding more.
/// </remarks>
public Task Unfurl(string channelId, string ts, IDictionary<string, Attachment> unfurls, bool userAuthRequired = false, CancellationToken? cancellationToken = null) =>
_client.Get("chat.unfurl", new Args
_client.Post<object>("chat.unfurl", new Args
{
{ "channel", channelId },
{ "ts", ts },
Expand All @@ -200,7 +200,7 @@ public Task Unfurl(string channelId, string ts, IDictionary<string, Attachment>
/// <param name="messageUpdate">Message to update.</param>
/// <param name="cancellationToken"></param>
public Task<MessageUpdateResponse> Update(MessageUpdate messageUpdate, CancellationToken? cancellationToken = null) =>
_client.Get<MessageUpdateResponse>("chat.update", new Args
_client.Post<MessageUpdateResponse>("chat.update", new Args
{
{ "ts", messageUpdate.Ts },
{ "channel", messageUpdate.ChannelId },
Expand Down
24 changes: 12 additions & 12 deletions SlackNet/WebApi/ConversationsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public class ConversationsApi : IConversationsApi
/// <param name="channelId">ID of conversation to archive.</param>
/// <param name="cancellationToken"></param>
public Task Archive(string channelId, CancellationToken? cancellationToken = null) =>
_client.Get("conversations.archive", new Args { { "channel", channelId } }, cancellationToken);
_client.Post<object>("conversations.archive", new Args { { "channel", channelId } }, cancellationToken);

/// <summary>
/// Closes a direct message or multi-person direct message.
Expand All @@ -216,7 +216,7 @@ public Task Archive(string channelId, CancellationToken? cancellationToken = nul
/// <param name="cancellationToken"></param>
/// <returns></returns>
public Task Close(string channelId, CancellationToken? cancellationToken = null) =>
_client.Get("conversations.close", new Args { { "channel", channelId } }, cancellationToken);
_client.Post<object>("conversations.close", new Args { { "channel", channelId } }, cancellationToken);

/// <summary>
/// Initiates a public or private channel-based conversation.
Expand All @@ -226,7 +226,7 @@ public Task Close(string channelId, CancellationToken? cancellationToken = null)
/// <param name="isPrivate">Create a private channel instead of a public one.</param>
/// <param name="cancellationToken"></param>
public async Task<Conversation> Create(string name, bool isPrivate, CancellationToken? cancellationToken = null) =>
(await _client.Get<ConversationResponse>("conversations.create", new Args
(await _client.Post<ConversationResponse>("conversations.create", new Args
{
{ "name", name },
{ "is_private", isPrivate }
Expand Down Expand Up @@ -281,7 +281,7 @@ public async Task<Conversation> Info(string channelId, bool includeLocale = fals
/// <param name="userIds">A comma separated list of user IDs. Up to 30 users may be listed.</param>
/// <param name="cancellationToken"></param>
public async Task<Conversation> Invite(string channelId, IEnumerable<string> userIds, CancellationToken? cancellationToken = null) =>
(await _client.Get<ConversationResponse>("conversations.invite", new Args
(await _client.Post<ConversationResponse>("conversations.invite", new Args
{
{ "channel", channelId },
{ "users", userIds }
Expand All @@ -294,7 +294,7 @@ public async Task<Conversation> Invite(string channelId, IEnumerable<string> use
/// <param name="channelId">ID of conversation to join.</param>
/// <param name="cancellationToken"></param>
public Task<ConversationJoinResponse> Join(string channelId, CancellationToken? cancellationToken = null) =>
_client.Get<ConversationJoinResponse>("conversations.join", new Args { { "channel", channelId } }, cancellationToken);
_client.Post<ConversationJoinResponse>("conversations.join", new Args { { "channel", channelId } }, cancellationToken);

/// <summary>
/// Removes a user from a conversation.
Expand All @@ -303,7 +303,7 @@ public Task<ConversationJoinResponse> Join(string channelId, CancellationToken?
/// <param name="userId">User ID to be removed.</param>
/// <param name="cancellationToken"></param>
public Task Kick(string channelId, string userId, CancellationToken? cancellationToken = null) =>
_client.Get("conversations.kick", new Args
_client.Post<object>("conversations.kick", new Args
{
{ "channel", channelId },
{ "user", userId }
Expand All @@ -315,7 +315,7 @@ public Task Kick(string channelId, string userId, CancellationToken? cancellatio
/// <param name="channelId">Conversation to leave.</param>
/// <param name="cancellationToken"></param>
public Task Leave(string channelId, CancellationToken? cancellationToken = null) =>
_client.Get("conversations.leave", new Args { { "channel", channelId } }, cancellationToken);
_client.Post<object>("conversations.leave", new Args { { "channel", channelId } }, cancellationToken);

/// <summary>
/// Lists all channels in a Slack team.
Expand Down Expand Up @@ -396,7 +396,7 @@ public Task<ImResponse> OpenAndReturnInfo(IEnumerable<string> userIds, Cancellat
Open<ImResponse>(true, null, userIds, cancellationToken);

private Task<T> Open<T>(bool returnIm, string channelId = null, IEnumerable<string> userIds = null, CancellationToken? cancellationToken = null) where T : class =>
_client.Get<T>("conversations.open", new Args
_client.Post<T>("conversations.open", new Args
{
{ "channel", channelId },
{ "return_im", returnIm },
Expand All @@ -410,7 +410,7 @@ private Task<T> Open<T>(bool returnIm, string channelId = null, IEnumerable<stri
/// <param name="name">New name for conversation.</param>
/// <param name="cancellationToken"></param>
public async Task<Conversation> Rename(string channelId, string name, CancellationToken? cancellationToken = null) =>
(await _client.Get<ConversationResponse>("conversations.rename", new Args
(await _client.Post<ConversationResponse>("conversations.rename", new Args
{
{ "channel", channelId },
{ "name", name }
Expand Down Expand Up @@ -451,7 +451,7 @@ public Task<ConversationMessagesResponse> Replies(string channelId, string threa
/// <param name="purpose">A new, specialer purpose.</param>
/// <param name="cancellationToken"></param>
public async Task<string> SetPurpose(string channelId, string purpose, CancellationToken? cancellationToken = null) =>
(await _client.Get<PurposeResponse>("conversations.setPurpose", new Args
(await _client.Post<PurposeResponse>("conversations.setPurpose", new Args
{
{ "channel", channelId },
{ "purpose", purpose }
Expand All @@ -465,7 +465,7 @@ public async Task<string> SetPurpose(string channelId, string purpose, Cancellat
/// <param name="topic">The new topic string. Does not support formatting or linkification.</param>
/// <param name="cancellationToken"></param>
public async Task<string> SetTopic(string channelId, string topic, CancellationToken? cancellationToken = null) =>
(await _client.Get<TopicResponse>("conversations.setTopic", new Args
(await _client.Post<TopicResponse>("conversations.setTopic", new Args
{
{ "channel", channelId },
{ "topic", topic }
Expand All @@ -478,6 +478,6 @@ public async Task<string> SetTopic(string channelId, string topic, CancellationT
/// <param name="channelId">ID of conversation to unarchive.</param>
/// <param name="cancellationToken"></param>
public Task Unarchive(string channelId, CancellationToken? cancellationToken = null) =>
_client.Get("conversations.unarchive", new Args { { "channel", channelId } }, cancellationToken);
_client.Post<object>("conversations.unarchive", new Args { { "channel", channelId } }, cancellationToken);
}
}
2 changes: 1 addition & 1 deletion SlackNet/WebApi/DialogApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class DialogApi : IDialogApi
/// <param name="dialog">The dialog definition.</param>
/// <param name="cancellationToken"></param>
public Task Open(string triggerId, Dialog dialog, CancellationToken? cancellationToken = null) =>
_client.Get("dialog.open", new Args
_client.Post<object>("dialog.open", new Args
{
{ "dialog", dialog },
{ "trigger_id", triggerId }
Expand Down
4 changes: 2 additions & 2 deletions SlackNet/WebApi/DndApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ public class DndApi : IDndApi
/// </summary>
/// <param name="cancellationToken"></param>
public Task EndDnd(CancellationToken? cancellationToken = null) =>
_client.Get("dnd.endDnd", new Args(), cancellationToken);
_client.Post<object>("dnd.endDnd", new Args(), cancellationToken);

/// <summary>
/// Ends the current user's snooze mode immediately.
/// </summary>
/// <param name="cancellationToken"></param>
public Task<DndResponse> EndSnooze(CancellationToken? cancellationToken = null) =>
_client.Get<DndResponse>("dnd.endSnooze", new Args(), cancellationToken);
_client.Post<DndResponse>("dnd.endSnooze", new Args(), cancellationToken);

/// <summary>
/// Provides information about the current user's Do Not Disturb settings.
Expand Down
2 changes: 1 addition & 1 deletion SlackNet/WebApi/FileCommentsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class FileCommentsApi : IFileCommentsApi
/// <param name="commentId">The comment to delete.</param>
/// <param name="cancellationToken"></param>
public Task Delete(string fileId, string commentId, CancellationToken? cancellationToken = null) =>
_client.Get("files.comments.delete", new Args
_client.Post<object>("files.comments.delete", new Args
{
{ "file", fileId },
{ "id", commentId }
Expand Down
Loading

0 comments on commit 3e8e4ee

Please sign in to comment.