Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log when methods are deprecated #329

Merged
merged 8 commits into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* [#324](https://github.com/slack-ruby/slack-ruby-client/pull/324): Require Faraday >= 1.0 - [@dblock](https://github.com/dblock).
* [#324](https://github.com/slack-ruby/slack-ruby-client/pull/324): Upgrade slack-ruby-danger, rubocop, rubocop-rspec and rubocop-performance - [@dblock](https://github.com/dblock).
* [#327](https://github.com/slack-ruby/slack-ruby-client/pull/327), [#326](https://github.com/slack-ruby/slack-ruby-client/pull/326): Added `admin_conversations_whitelist`, `admin_usergroups`, `calls` and `calls_participants` endpoints - [@wasabigeek](https://github.com/wasabigeek).
* [#329](https://github.com/slack-ruby/slack-ruby-client/pull/329): Log when methods are deprecated - [@wasabigeek](https://github.com/wasabigeek).
* Your contribution here.

### 0.14.6 (2020/3/28)
Expand Down
15 changes: 15 additions & 0 deletions lib/slack/web/api/endpoints/channels.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module Channels
def channels_archive(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
logger.warn('channels.archive: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.archive.')
post('channels.archive', options)
end

Expand All @@ -30,6 +31,7 @@ def channels_archive(options = {})
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.create.json
def channels_create(options = {})
throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
logger.warn('channels.create: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.create.')
post('channels.create', options)
end

Expand Down Expand Up @@ -64,6 +66,7 @@ def channels_delete(options = {})
def channels_history(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
logger.warn('channels.history: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.history.')
post('channels.history', options)
end

Expand All @@ -79,6 +82,7 @@ def channels_history(options = {})
def channels_info(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
logger.warn('channels.info: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.info.')
post('channels.info', options)
end

Expand All @@ -96,6 +100,7 @@ def channels_invite(options = {})
throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
options = options.merge(user: users_id(options)['user']['id']) if options[:user]
logger.warn('channels.invite: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.invite.')
post('channels.invite', options)
end

Expand All @@ -110,6 +115,7 @@ def channels_invite(options = {})
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.join.json
def channels_join(options = {})
throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
logger.warn('channels.join: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.join.')
post('channels.join', options)
end

Expand All @@ -127,6 +133,7 @@ def channels_kick(options = {})
throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
options = options.merge(user: users_id(options)['user']['id']) if options[:user]
logger.warn('channels.kick: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.kick.')
post('channels.kick', options)
end

Expand All @@ -140,6 +147,7 @@ def channels_kick(options = {})
def channels_leave(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
logger.warn('channels.leave: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.leave.')
post('channels.leave', options)
end

Expand All @@ -157,6 +165,7 @@ def channels_leave(options = {})
# @see https://api.slack.com/methods/channels.list
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/channels/channels.list.json
def channels_list(options = {})
logger.warn('channels.list: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.list, users.conversations.')
if block_given?
Pagination::Cursor.new(self, :channels_list, options).each do |page|
yield page
Expand All @@ -179,6 +188,7 @@ def channels_mark(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
logger.warn('channels.mark: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: .')
post('channels.mark', options)
end

Expand All @@ -197,6 +207,7 @@ def channels_rename(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
logger.warn('channels.rename: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.rename.')
post('channels.rename', options)
end

Expand All @@ -213,6 +224,7 @@ def channels_replies(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
throw ArgumentError.new('Required arguments :thread_ts missing') if options[:thread_ts].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
logger.warn('channels.replies: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.replies.')
post('channels.replies', options)
end

Expand All @@ -231,6 +243,7 @@ def channels_setPurpose(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
throw ArgumentError.new('Required arguments :purpose missing') if options[:purpose].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
logger.warn('channels.setPurpose: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.setPurpose.')
post('channels.setPurpose', options)
end

Expand All @@ -247,6 +260,7 @@ def channels_setTopic(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
throw ArgumentError.new('Required arguments :topic missing') if options[:topic].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
logger.warn('channels.setTopic: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.setTopic.')
post('channels.setTopic', options)
end

Expand All @@ -260,6 +274,7 @@ def channels_setTopic(options = {})
def channels_unarchive(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
logger.warn('channels.unarchive: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.unarchive.')
post('channels.unarchive', options)
end
end
Expand Down
16 changes: 16 additions & 0 deletions lib/slack/web/api/endpoints/groups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module Groups
def groups_archive(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
logger.warn('groups.archive: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.archive.')
post('groups.archive', options)
end

Expand All @@ -30,6 +31,7 @@ def groups_archive(options = {})
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.create.json
def groups_create(options = {})
throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
logger.warn('groups.create: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.create.')
post('groups.create', options)
end

Expand All @@ -43,6 +45,7 @@ def groups_create(options = {})
def groups_createChild(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
logger.warn('groups.createChild: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: .')
post('groups.createChild', options)
end

Expand All @@ -64,6 +67,7 @@ def groups_createChild(options = {})
def groups_history(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
logger.warn('groups.history: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.history.')
post('groups.history', options)
end

Expand All @@ -79,6 +83,7 @@ def groups_history(options = {})
def groups_info(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
logger.warn('groups.info: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.info.')
post('groups.info', options)
end

Expand All @@ -96,6 +101,7 @@ def groups_invite(options = {})
throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
options = options.merge(user: users_id(options)['user']['id']) if options[:user]
logger.warn('groups.invite: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.invite.')
post('groups.invite', options)
end

Expand All @@ -113,6 +119,7 @@ def groups_kick(options = {})
throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
options = options.merge(user: users_id(options)['user']['id']) if options[:user]
logger.warn('groups.kick: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.kick.')
post('groups.kick', options)
end

Expand All @@ -126,6 +133,7 @@ def groups_kick(options = {})
def groups_leave(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
logger.warn('groups.leave: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.leave.')
post('groups.leave', options)
end

Expand All @@ -143,6 +151,7 @@ def groups_leave(options = {})
# @see https://api.slack.com/methods/groups.list
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/groups/groups.list.json
def groups_list(options = {})
logger.warn('groups.list: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.list, users.conversations.')
if block_given?
Pagination::Cursor.new(self, :groups_list, options).each do |page|
yield page
Expand All @@ -165,6 +174,7 @@ def groups_mark(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
logger.warn('groups.mark: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: .')
post('groups.mark', options)
end

Expand All @@ -178,6 +188,7 @@ def groups_mark(options = {})
def groups_open(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
logger.warn('groups.open: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: .')
post('groups.open', options)
end

Expand All @@ -196,6 +207,7 @@ def groups_rename(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
logger.warn('groups.rename: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.rename.')
post('groups.rename', options)
end

Expand All @@ -212,6 +224,7 @@ def groups_replies(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
throw ArgumentError.new('Required arguments :thread_ts missing') if options[:thread_ts].nil?
options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
logger.warn('groups.replies: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.replies.')
post('groups.replies', options)
end

Expand All @@ -228,6 +241,7 @@ def groups_setPurpose(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
throw ArgumentError.new('Required arguments :purpose missing') if options[:purpose].nil?
options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
logger.warn('groups.setPurpose: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.setPurpose.')
post('groups.setPurpose', options)
end

Expand All @@ -244,6 +258,7 @@ def groups_setTopic(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
throw ArgumentError.new('Required arguments :topic missing') if options[:topic].nil?
options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
logger.warn('groups.setTopic: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.setTopic.')
post('groups.setTopic', options)
end

Expand All @@ -257,6 +272,7 @@ def groups_setTopic(options = {})
def groups_unarchive(options = {})
throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
logger.warn('groups.unarchive: This method is deprecated. It will stop functioning in February 2021 and will not work with newly created apps after June 10th, 2020. Alternative methods: conversations.unarchive.')
post('groups.unarchive', options)
end
end
Expand Down
Loading