Skip to content

Commit

Permalink
Update API from slack-api-ref@8a22e57 (2024-02-15)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-flow committed Feb 15, 2024
1 parent 9e6d117 commit 1f7dd38
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 9 deletions.
33 changes: 33 additions & 0 deletions bin/commands/apps_datastore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,39 @@ module Cli
class App
desc 'AppsDatastore methods.'
command 'apps_datastore' do |g|
g.desc 'Delete items from a datastore in bulk'
g.long_desc %( Delete items from a datastore in bulk )
g.command 'bulkDelete' do |c|
c.flag 'datastore', desc: 'name of the datastore.'
c.flag 'ids', desc: 'IDs of items to be deleted.'
c.flag 'app_id', desc: '.'
c.action do |_global_options, options, _args|
puts JSON.dump(@client.apps_datastore_bulkDelete(options))
end
end

g.desc 'Get items from a datastore in bulk'
g.long_desc %( Get items from a datastore in bulk )
g.command 'bulkGet' do |c|
c.flag 'datastore', desc: 'name of the datastore.'
c.flag 'ids', desc: "items' ids."
c.flag 'app_id', desc: '.'
c.action do |_global_options, options, _args|
puts JSON.dump(@client.apps_datastore_bulkGet(options))
end
end

g.desc 'Creates or replaces existing items in bulk'
g.long_desc %( Creates or replaces existing items in bulk )
g.command 'bulkPut' do |c|
c.flag 'datastore', desc: 'name of the datastore.'
c.flag 'items', desc: 'attribute names and values of the items.'
c.flag 'app_id', desc: '.'
c.action do |_global_options, options, _args|
puts JSON.dump(@client.apps_datastore_bulkPut(options))
end
end

g.desc 'Delete an item from a datastore'
g.long_desc %( Delete an item from a datastore )
g.command 'delete' do |c|
Expand Down
4 changes: 2 additions & 2 deletions bin/commands/oauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class App
g.desc 'Exchanges a temporary OAuth verifier code for an access token.'
g.long_desc %( Exchanges a temporary OAuth verifier code for an access token. )
g.command 'access' do |c|
c.flag 'client_id', desc: 'Issued when you created your application.'
c.flag 'client_secret', desc: 'Issued when you created your application.'
c.flag 'client_id', desc: 'Issued when you created your application. If possible, avoid sending client_id and client_secret as parameters in your request and instead supply the Client ID and Client Secret using the HTTP Basic authentication scheme.'
c.flag 'client_secret', desc: 'Issued when you created your application. If possible, avoid sending client_id and client_secret as parameters in your request and instead supply the Client ID and Client Secret using the HTTP Basic authentication scheme.'
c.flag 'code', desc: 'The code param returned via the OAuth callback.'
c.flag 'redirect_uri', desc: 'This must match the originally submitted URI (if one was sent).'
c.flag 'single_channel', desc: 'Request the user to add your app only to a single channel. Only valid with a legacy workspace app.'
Expand Down
4 changes: 2 additions & 2 deletions bin/commands/oauth_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class App
g.desc 'Exchanges a temporary OAuth verifier code for an access token.'
g.long_desc %( Exchanges a temporary OAuth verifier code for an access token. )
g.command 'access' do |c|
c.flag 'client_id', desc: 'Issued when you created your application.'
c.flag 'client_secret', desc: 'Issued when you created your application.'
c.flag 'client_id', desc: 'Issued when you created your application. If possible, avoid sending client_id and client_secret as parameters in your request and instead supply the Client ID and Client Secret using the HTTP Basic authentication scheme.'
c.flag 'client_secret', desc: 'Issued when you created your application. If possible, avoid sending client_id and client_secret as parameters in your request and instead supply the Client ID and Client Secret using the HTTP Basic authentication scheme.'
c.flag 'code', desc: 'The code param returned via the OAuth callback.'
c.flag 'grant_type', desc: 'The grant_type param as described in the OAuth spec.'
c.flag 'redirect_uri', desc: 'This must match the originally submitted URI (if one was sent).'
Expand Down
51 changes: 51 additions & 0 deletions lib/slack/web/api/endpoints/apps_datastore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,57 @@ module Web
module Api
module Endpoints
module AppsDatastore
#
# Delete items from a datastore in bulk
#
# @option options [string] :datastore
# name of the datastore.
# @option options [array] :ids
# IDs of items to be deleted.
# @option options [Object] :app_id
# .
# @see https://api.slack.com/methods/apps.datastore.bulkDelete
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/apps.datastore/apps.datastore.bulkDelete.json
def apps_datastore_bulkDelete(options = {})
raise ArgumentError, 'Required arguments :datastore missing' if options[:datastore].nil?
raise ArgumentError, 'Required arguments :ids missing' if options[:ids].nil?
post('apps.datastore.bulkDelete', options)
end

#
# Get items from a datastore in bulk
#
# @option options [string] :datastore
# name of the datastore.
# @option options [array] :ids
# items' ids.
# @option options [Object] :app_id
# .
# @see https://api.slack.com/methods/apps.datastore.bulkGet
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/apps.datastore/apps.datastore.bulkGet.json
def apps_datastore_bulkGet(options = {})
raise ArgumentError, 'Required arguments :datastore missing' if options[:datastore].nil?
raise ArgumentError, 'Required arguments :ids missing' if options[:ids].nil?
post('apps.datastore.bulkGet', options)
end

#
# Creates or replaces existing items in bulk
#
# @option options [string] :datastore
# name of the datastore.
# @option options [array] :items
# attribute names and values of the items.
# @option options [Object] :app_id
# .
# @see https://api.slack.com/methods/apps.datastore.bulkPut
# @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/apps.datastore/apps.datastore.bulkPut.json
def apps_datastore_bulkPut(options = {})
raise ArgumentError, 'Required arguments :datastore missing' if options[:datastore].nil?
raise ArgumentError, 'Required arguments :items missing' if options[:items].nil?
post('apps.datastore.bulkPut', options)
end

#
# Delete an item from a datastore
#
Expand Down
4 changes: 2 additions & 2 deletions lib/slack/web/api/endpoints/oauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ module Oauth
# Exchanges a temporary OAuth verifier code for an access token.
#
# @option options [string] :client_id
# Issued when you created your application.
# Issued when you created your application. If possible, avoid sending client_id and client_secret as parameters in your request and instead supply the Client ID and Client Secret using the HTTP Basic authentication scheme.
# @option options [string] :client_secret
# Issued when you created your application.
# Issued when you created your application. If possible, avoid sending client_id and client_secret as parameters in your request and instead supply the Client ID and Client Secret using the HTTP Basic authentication scheme.
# @option options [string] :code
# The code param returned via the OAuth callback.
# @option options [string] :redirect_uri
Expand Down
4 changes: 2 additions & 2 deletions lib/slack/web/api/endpoints/oauth_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ module OauthV2
# Exchanges a temporary OAuth verifier code for an access token.
#
# @option options [string] :client_id
# Issued when you created your application.
# Issued when you created your application. If possible, avoid sending client_id and client_secret as parameters in your request and instead supply the Client ID and Client Secret using the HTTP Basic authentication scheme.
# @option options [string] :client_secret
# Issued when you created your application.
# Issued when you created your application. If possible, avoid sending client_id and client_secret as parameters in your request and instead supply the Client ID and Client Secret using the HTTP Basic authentication scheme.
# @option options [string] :code
# The code param returned via the OAuth callback.
# @option options [string] :grant_type
Expand Down
2 changes: 2 additions & 0 deletions lib/slack/web/api/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ class PaidTeamsOnly < SlackError; end
class ParameterValidationFailed < SlackError; end
class ParentBookmarkDisabled < SlackError; end
class ParentWithLink < SlackError; end
class PartialFailure < SlackError; end
class PartialProfileSetFailed < SlackError; end
class PermissionDenied < SlackError; end
class PlanUpgradeRequired < SlackError; end
Expand Down Expand Up @@ -1103,6 +1104,7 @@ class WorkflowsExportCsvNotEnabled < SlackError; end
'parameter_validation_failed' => ParameterValidationFailed,
'parent_bookmark_disabled' => ParentBookmarkDisabled,
'parent_with_link' => ParentWithLink,
'partial_failure' => PartialFailure,
'partial_profile_set_failed' => PartialProfileSetFailed,
'permission_denied' => PermissionDenied,
'plan_upgrade_required' => PlanUpgradeRequired,
Expand Down
24 changes: 24 additions & 0 deletions spec/slack/web/api/endpoints/apps_datastore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,30 @@

RSpec.describe Slack::Web::Api::Endpoints::AppsDatastore do
let(:client) { Slack::Web::Client.new }
context 'apps.datastore_bulkDelete' do
it 'requires datastore' do
expect { client.apps_datastore_bulkDelete(ids: %q[["7c6dd137", "c7d6d731"]]) }.to raise_error ArgumentError, /Required arguments :datastore missing/
end
it 'requires ids' do
expect { client.apps_datastore_bulkDelete(datastore: %q[]) }.to raise_error ArgumentError, /Required arguments :ids missing/
end
end
context 'apps.datastore_bulkGet' do
it 'requires datastore' do
expect { client.apps_datastore_bulkGet(ids: %q[["7c6dd137", "c7d6d731"]]) }.to raise_error ArgumentError, /Required arguments :datastore missing/
end
it 'requires ids' do
expect { client.apps_datastore_bulkGet(datastore: %q[]) }.to raise_error ArgumentError, /Required arguments :ids missing/
end
end
context 'apps.datastore_bulkPut' do
it 'requires datastore' do
expect { client.apps_datastore_bulkPut(items: %q[[{"id": "7c6dd137", "favourite_meal": "Shawarma", "reason": "Who doesn't like Shawarma?"}]]) }.to raise_error ArgumentError, /Required arguments :datastore missing/
end
it 'requires items' do
expect { client.apps_datastore_bulkPut(datastore: %q[]) }.to raise_error ArgumentError, /Required arguments :items missing/
end
end
context 'apps.datastore_delete' do
it 'requires datastore' do
expect { client.apps_datastore_delete(id: %q[]) }.to raise_error ArgumentError, /Required arguments :datastore missing/
Expand Down

0 comments on commit 1f7dd38

Please sign in to comment.