Skip to content

Commit

Permalink
Marking deprecated APIs as Obsolete and updating readme
Browse files Browse the repository at this point in the history
Resolves #63
  • Loading branch information
Simon Oxtoby committed Dec 21, 2020
1 parent 9b00419 commit defd404
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 17 deletions.
4 changes: 4 additions & 0 deletions SlackNet/SlackApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public interface ISlackApiClient
IAppsEventsAuthorizationsApi AppsEventsAuthorizations { get; }
IAuthApi Auth { get; }
IBotsApi Bots { get; }
[Obsolete("Use Conversations instead")]
IChannelsApi Channels { get; }
IChatApi Chat { get; }
IConversationsApi Conversations { get; }
Expand All @@ -26,9 +27,12 @@ public interface ISlackApiClient
IEmojiApi Emoji { get; }
IFileCommentsApi FileComments { get; }
IFilesApi Files { get; }
[Obsolete("Use Conversations instead")]
IGroupsApi Groups { get; }
[Obsolete("Use Conversations instead")]
IImApi Im { get; }
IMigrationApi Migration { get; }
[Obsolete("Use Conversations instead")]
IMpimApi Mpim { get; }
IOAuthApi OAuth { get; }
IPinsApi Pins { get; }
Expand Down
23 changes: 13 additions & 10 deletions SlackNet/WebApi/ChannelsApi.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -6,6 +7,7 @@

namespace SlackNet.WebApi
{
[Obsolete("Use IConversationsApi instead")]
public interface IChannelsApi
{
/// <summary>
Expand Down Expand Up @@ -64,8 +66,8 @@ public interface IChannelsApi
/// <param name="cancellationToken"></param>
/// <returns>
/// If successful, the command returns a channel object, including state information.
/// If you are already in the channel, the response is slightly different.
/// <see cref="ChannelJoinResponse.AlreadyInChannel"/> will be true, and a limited channel object will be returned.
/// If you are already in the channel, the response is slightly different.
/// <see cref="ChannelJoinResponse.AlreadyInChannel"/> will be true, and a limited channel object will be returned.
/// 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>
Task<ChannelJoinResponse> Join(string channelName, bool validate = false, CancellationToken? cancellationToken = null);
Expand All @@ -87,8 +89,8 @@ public interface IChannelsApi
Task Leave(string channelId, CancellationToken? cancellationToken = null);

/// <summary>
/// Returns a list of all channels in the team.
/// This includes channels the caller is in, channels they are not currently in, and archived channels but does not include private channels.
/// Returns a list of all channels in the team.
/// This includes channels the caller is in, channels they are not currently in, and archived channels but does not include private channels.
/// The number of (non-deactivated) members in each channel is also returned.
/// To retrieve a list of private channels, use groups.list.
/// </summary>
Expand All @@ -107,7 +109,7 @@ public interface IChannelsApi

/// <summary>
/// Renames a team channel.
/// The only people who can rename a channel are Team Admins, or the person that originally created the channel.
/// The only people who can rename a channel are Team Admins, or the person that originally created the channel.
/// Others will receive a "not_authorized" error.
/// </summary>
/// <param name="channelId">Channel to rename</param>
Expand Down Expand Up @@ -150,6 +152,7 @@ public interface IChannelsApi
Task Unarchive(string channelId, CancellationToken? cancellationToken = null);
}

[Obsolete("Use ConversationsApi instead")]
public class ChannelsApi : IChannelsApi
{
private readonly ISlackApiClient _client;
Expand Down Expand Up @@ -235,8 +238,8 @@ public async Task<Channel> Invite(string channelId, string userId, CancellationT
/// <param name="cancellationToken"></param>
/// <returns>
/// If successful, the command returns a channel object, including state information.
/// If you are already in the channel, the response is slightly different.
/// <see cref="ChannelJoinResponse.AlreadyInChannel"/> will be true, and a limited channel object will be returned.
/// If you are already in the channel, the response is slightly different.
/// <see cref="ChannelJoinResponse.AlreadyInChannel"/> will be true, and a limited channel object will be returned.
/// 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) =>
Expand Down Expand Up @@ -269,8 +272,8 @@ public Task Leave(string channelId, CancellationToken? cancellationToken = null)
_client.Post("channels.leave", new Args { { "channel", channelId } }, cancellationToken);

/// <summary>
/// Returns a list of all channels in the team.
/// This includes channels the caller is in, channels they are not currently in, and archived channels but does not include private channels.
/// Returns a list of all channels in the team.
/// This includes channels the caller is in, channels they are not currently in, and archived channels but does not include private channels.
/// The number of (non-deactivated) members in each channel is also returned.
/// To retrieve a list of private channels, use groups.list.
/// </summary>
Expand Down Expand Up @@ -300,7 +303,7 @@ public Task Mark(string channelId, string ts, CancellationToken? cancellationTok

/// <summary>
/// Renames a team channel.
/// The only people who can rename a channel are Team Admins, or the person that originally created the channel.
/// The only people who can rename a channel are Team Admins, or the person that originally created the channel.
/// Others will receive a "not_authorized" error.
/// </summary>
/// <param name="channelId">Channel to rename</param>
Expand Down
9 changes: 6 additions & 3 deletions SlackNet/WebApi/GroupsApi.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using SlackNet.Events;
using Args = System.Collections.Generic.Dictionary<string, object>;

namespace SlackNet.WebApi
{
[Obsolete("Use IConversationsApi instead")]
public interface IGroupsApi
{
/// <summary>
Expand Down Expand Up @@ -95,7 +97,7 @@ Task<ChannelHistoryResponse> History(
Task Leave(string channelId, CancellationToken? cancellationToken = null);

/// <summary>
/// Returns a list of private channels in the team that the caller is in and archived groups that the caller was in.
/// Returns a list of private channels in the team that the caller is in and archived groups that the caller was in.
/// The list of (non-deactivated) members in each private channel is also returned.
/// </summary>
/// <param name="excludeArchived">Don't return archived private channels.</param>
Expand Down Expand Up @@ -161,6 +163,7 @@ Task<ChannelHistoryResponse> History(
Task Unarchive(string channelId, CancellationToken? cancellationToken = null);
}

[Obsolete("Use ConversationsApi instead")]
public class GroupsApi : IGroupsApi
{
private readonly ISlackApiClient _client;
Expand Down Expand Up @@ -285,7 +288,7 @@ public Task Leave(string channelId, CancellationToken? cancellationToken = null)
_client.Post("groups.leave", new Args { { "channel", channelId } }, cancellationToken);

/// <summary>
/// Returns a list of private channels in the team that the caller is in and archived groups that the caller was in.
/// Returns a list of private channels in the team that the caller is in and archived groups that the caller was in.
/// The list of (non-deactivated) members in each private channel is also returned.
/// </summary>
/// <param name="excludeArchived">Don't return archived private channels.</param>
Expand Down
5 changes: 4 additions & 1 deletion SlackNet/WebApi/ImApi.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using SlackNet.Events;
using Args = System.Collections.Generic.Dictionary<string, object>;

namespace SlackNet.WebApi
{
[Obsolete("Use IConversationsApi instead")]
public interface IImApi
{
/// <summary>
Expand Down Expand Up @@ -69,6 +71,7 @@ Task<ChannelHistoryResponse> History(
Task<IReadOnlyList<MessageEvent>> Replies(string channelId, string threadTs, CancellationToken? cancellationToken = null);
}

[Obsolete("Use IConversationsApi instead")]
public class ImApi : IImApi
{
private readonly ISlackApiClient _client;
Expand Down
5 changes: 4 additions & 1 deletion SlackNet/WebApi/MpimApi.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using SlackNet.Events;
using Args = System.Collections.Generic.Dictionary<string, object>;

namespace SlackNet.WebApi
{
[Obsolete("Use IConversationsApi instead")]
public interface IMpimApi
{
/// <summary>
Expand Down Expand Up @@ -68,6 +70,7 @@ Task<ChannelHistoryResponse> History(
Task<IReadOnlyList<MessageEvent>> Replies(string channelId, string threadTs, CancellationToken? cancellationToken = null);
}

[Obsolete("Use IConversationsApi instead")]
public class MpimApi : IMpimApi
{
private readonly ISlackApiClient _client;
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var api = new SlackApiClient("<your OAuth access token here>");
```
then start calling methods:
```c#
var channels = await api.Channels.List();
var channels = await api.Conversations.List();
```

To use the RTM API:
Expand Down Expand Up @@ -62,7 +62,7 @@ message.ReplyWith(async () => {
SlackNet.Bot includes a simplified API for getting common information from Slack:
```c#
var user = await bot.GetUserByName("someuser");
var channels = await bot.GetChannels();
var conversations = await bot.GetConversations();
// etc.
```
Everything is cached, so go nuts getting the information you need. You can clear the cache with `bot.ClearCache()`.
Expand Down

0 comments on commit defd404

Please sign in to comment.