Sha256: 8ad2cafa854af0e1a14b9f4d5b6e1f41d367fe2abe11799924a0774f34028183

Contents?: true

Size: 1.44 KB

Versions: 4

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

module Slack
  module BlockKit
    module Composition
      # An object that defines a dialog that provides a confirmation step to any
      # interactive element. This dialog will ask the user to confirm their
      # action by offering confirm and deny buttons.
      #
      # https://api.slack.com/reference/messaging/composition-objects#confirm
      class ConfirmationDialog
        def initialize
          @title, @confirm, @text, @style = nil
        end

        def title(text:, emoji: nil)
          @title = PlainText.new(text: text, emoji: emoji)

          self
        end

        def confirm(text:, emoji: nil)
          @confirm = PlainText.new(text: text, emoji: emoji)

          self
        end

        def deny(text:, emoji: nil)
          @deny = PlainText.new(text: text, emoji: emoji)

          self
        end

        def plain_text(text:, emoji: nil)
          @text = PlainText.new(text: text, emoji: emoji)

          self
        end

        def style(value)
          @style = value

          self
        end

        def mrkdwn(text:, verbatim: nil)
          @text = Mrkdwn.new(text: text, verbatim: verbatim)

          self
        end

        def as_json(*)
          {
            title: @title.as_json,
            text: @text.as_json,
            confirm: @confirm.as_json,
            deny: @deny.as_json,
            style: @style
          }.compact
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
slack-ruby-block-kit-0.10.0 lib/slack/block_kit/composition/confirmation_dialog.rb
slack-ruby-block-kit-0.9.0 lib/slack/block_kit/composition/confirmation_dialog.rb
slack-ruby-block-kit-0.8.0 lib/slack/block_kit/composition/confirmation_dialog.rb
slack-ruby-block-kit-0.7.0 lib/slack/block_kit/composition/confirmation_dialog.rb