Class: Whatsapp::Messages::Video

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby/whatsapp/messages/video.rb

Overview

Video messages display a thumbnail preview of a video with an optional caption. Source: https://developers.facebook.com/documentation/business-messaging/whatsapp/messages/video-messages

Defined Under Namespace

Modules: Defaults

Instance Attribute Summary collapse

Attributes inherited from Base

#to

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, link: nil, caption: nil) ⇒ Video

Returns a new instance of Video.

Parameters:

  • id (String, nil) (defaults to: nil)

    ID of the uploaded media asset.

  • link (String, nil) (defaults to: nil)

    URL of the media asset hosted on your public server.

  • caption (String, nil) (defaults to: nil)

    Video caption text (maximum 1024 characters).

  • kwargs (Hash)

    Additional keyword arguments. @raise [ActiveModel::ValidationError] if validation fails.



32
33
34
35
36
37
38
39
40
# File 'lib/ruby/whatsapp/messages/video.rb', line 32

def initialize(id: nil, link: nil, caption: nil, **)
  super(**)

  @id = id
  @link = link
  @caption = caption

  validate!
end

Instance Attribute Details

#captionString?

Returns:

  • (String, nil)


22
23
24
# File 'lib/ruby/whatsapp/messages/video.rb', line 22

def caption
  @caption
end

#idString?

Returns:

  • (String, nil)


14
15
16
# File 'lib/ruby/whatsapp/messages/video.rb', line 14

def id
  @id
end

Returns:

  • (String, nil)


18
19
20
# File 'lib/ruby/whatsapp/messages/video.rb', line 18

def link
  @link
end

Instance Method Details

#serializeHash

Serializes the video message to a hash format suitable for the WhatsApp API.

Returns:

  • (Hash)

    The serialized video message.



44
45
46
# File 'lib/ruby/whatsapp/messages/video.rb', line 44

def serialize
  envelope(type: Defaults::TYPE, video: video_payload)
end