# This file was auto-generated by lib/tasks/web.rake

module Slack
  module Web
    module Api
      module Endpoints
        module Dialog
          #
          # Open a dialog with a user by exchanging a trigger_id received from another interaction. See the dialogs documentation to learn how to obtain triggers define form elements.
          #
          # @option options [Object] :dialog
          #   The dialog definition. This must be a JSON-encoded string.
          # @option options [Object] :trigger_id
          #   Exchange a trigger to post to the user.
          # @see https://api.slack.com/methods/dialog.open
          # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/dialog/dialog.open.json
          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
      end
    end
  end
end
