-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8417e3a
commit fffbce7
Showing
10 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This file was auto-generated by lib/tasks/web.rake | ||
|
||
desc 'Dialog methods.' | ||
command 'dialog' do |g| | ||
g.desc 'Open a dialog with a user' | ||
g.long_desc %( Open a dialog with a user ) | ||
g.command 'open' do |c| | ||
c.flag 'dialog', desc: 'The dialog definition. This must be a JSON-encoded string.' | ||
c.flag 'trigger_id', desc: 'Exchange a trigger to post to the user.' | ||
c.action do |_global_options, options, _args| | ||
puts JSON.dump($client.dialog_open(options)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
lib/slack/web/api/patches/dialog.1.open-json-support.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
diff --git a/lib/slack/web/api/endpoints/dialog.rb b/lib/slack/web/api/endpoints/dialog.rb | ||
index 01f9dfd..d017adf 100644 | ||
--- a/lib/slack/web/api/endpoints/dialog.rb | ||
+++ b/lib/slack/web/api/endpoints/dialog.rb | ||
@@ -17,6 +17,12 @@ module Slack | ||
def dialog_open(options = {}) | ||
throw ArgumentError.new('Required arguments :dialog missing') if options[:dialog].nil? | ||
throw ArgumentError.new('Required arguments :trigger_id missing') if options[:trigger_id].nil? | ||
+ # dialog must be passed as an encoded JSON string | ||
+ if options.key?(:dialog) | ||
+ dialog = options[:dialog] | ||
+ dialog = JSON.dump(dialog) unless dialog.is_a?(String) | ||
+ options = options.merge(dialog: dialog) | ||
+ end | ||
post('dialog.open', options) | ||
end | ||
end |
Submodule slack-api-ref
updated
4 files
+3 −0 | groups/dialog.json | |
+1 −1 | methods/conversations/conversations.create.json | |
+2 −1 | methods/conversations/conversations.history.json | |
+43 −0 | methods/dialog/dialog.open.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Slack::Web::Api::Endpoints::Dialog do | ||
let(:client) { Slack::Web::Client.new } | ||
context 'dialog_open' do | ||
it 'automatically converts dialog into JSON' do | ||
expect(client).to receive(:post).with( | ||
'dialog.open', | ||
trigger_id: '12345.98765.abcd2358fdea', | ||
dialog: '[]' | ||
) | ||
client.dialog_open(trigger_id: '12345.98765.abcd2358fdea', dialog: []) | ||
end | ||
|
||
context 'arguments' do | ||
it 'requires dialog' do | ||
expect { client.dialog_open(trigger_id: '123') }.to raise_error ArgumentError, /Required arguments :dialog missing/ | ||
end | ||
it 'requires trigger_id' do | ||
expect { client.dialog_open(dialog: []) }.to raise_error ArgumentError, /Required arguments :trigger_id missing/ | ||
end | ||
it 'likes both dialog and trigger_id' do | ||
expect(client).to receive(:post).with('dialog.open', hash_including(trigger_id: '123', dialog: '[]')) | ||
expect { client.dialog_open(dialog: [], trigger_id: '123') }.to_not raise_error | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This file was auto-generated by lib/tasks/web.rake | ||
|
||
require 'spec_helper' | ||
|
||
RSpec.describe Slack::Web::Api::Endpoints::Dialog do | ||
let(:client) { Slack::Web::Client.new } | ||
context 'dialog_open' do | ||
it 'requires dialog' do | ||
expect { client.dialog_open(trigger_id: '12345.98765.abcd2358fdea') }.to raise_error ArgumentError, /Required arguments :dialog missing/ | ||
end | ||
it 'requires trigger_id' do | ||
expect { client.dialog_open(dialog: ' ') }.to raise_error ArgumentError, /Required arguments :trigger_id missing/ | ||
end | ||
end | ||
end |