Class: Slack::BlockKit::Layout::Video

Inherits:
Object
  • Object
show all
Defined in:
lib/slack/block_kit/layout/video.rb

Overview

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.

api.slack.com/reference/messaging/blocks#context

Constant Summary collapse

TYPE =
'video'

Instance Method Summary collapse

Constructor Details

#initialize(alt_text:, thumbnail_url:, video_url:, title:, description:, **optional_args) ⇒ Video

Returns a new instance of Video.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/slack/block_kit/layout/video.rb', line 14

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

Instance Method Details

#as_jsonObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/slack/block_kit/layout/video.rb', line 33

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