Sha256: 22fd9a4dee7a5b80d545251df1d8faec954c4714eac8516f3f6db4b4fb281c79

Contents?: true

Size: 1.67 KB

Versions: 7

Compression:

Stored size: 1.67 KB

Contents

# frozen_string_literal: true

module Slack
  module BlockKit
    module Layout
      # A video block is designed to embed videos in all app surfaces
      # (e.g. link unfurls, messages, modals, App Home)  — anywhere you can put blocks!
      # To use the video block within your app, you must have the links.embed:write scope.
      #
      # https://api.slack.com/reference/messaging/blocks#context
      class Video
        TYPE = 'video'

        def initialize(alt_text:, thumbnail_url:, video_url:, title:, description:, **optional_args)
          @alt_text = alt_text
          @thumbnail_url = thumbnail_url
          @video_url = video_url
          @author_name = optional_args[:author_name]
          @block_id = optional_args[:block_id]
          @provider_icon_url = optional_args[:provider_icon_url]
          @provider_name = optional_args[:provider_name]
          @title_url = optional_args[:title_url]
          @description = Composition::PlainText.new(
            text: description,
            emoji: optional_args[:emoji]
          )
          @title = Composition::PlainText.new(
            text: title,
            emoji: optional_args[:emoji]
          )
        end

        def as_json(*)
          {
            type: TYPE,
            alt_text: @alt_text,
            thumbnail_url: @thumbnail_url,
            video_url: @video_url,
            author_name: @author_name,
            block_id: @block_id,
            provider_icon_url: @provider_icon_url,
            provider_name: @provider_name,
            title_url: @title_url,
            description: @description.as_json,
            title: @title.as_json
          }.compact
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
slack-ruby-block-kit-0.25.0 lib/slack/block_kit/layout/video.rb
slack-ruby-block-kit-0.24.0 lib/slack/block_kit/layout/video.rb
slack-ruby-block-kit-0.23.0 lib/slack/block_kit/layout/video.rb
slack-ruby-block-kit-0.22.0 lib/slack/block_kit/layout/video.rb
slack-ruby-block-kit-0.21.0 lib/slack/block_kit/layout/video.rb
slack-ruby-block-kit-0.20.0 lib/slack/block_kit/layout/video.rb
slack-ruby-block-kit-0.19.0 lib/slack/block_kit/layout/video.rb