Class: Whatsapp::Messages::Sticker

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

Overview

Sticker messages display animated or static sticker images in a WhatsApp message. Source: https://developers.facebook.com/documentation/business-messaging/whatsapp/messages/sticker-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) ⇒ Sticker

Returns a new instance of Sticker.

Parameters:

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

    ID of the uploaded media asset.

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

    URL of a publicly hosted media asset. Prefer uploading via Media#upload and passing id for better performance.

  • kwargs (Hash)

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



27
28
29
30
31
32
33
34
# File 'lib/ruby/whatsapp/messages/sticker.rb', line 27

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

  @id = id
  @link = link

  validate!
end

Instance Attribute Details

#idString

Returns:

  • (String)


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

def id
  @id
end

Returns:

  • (String)


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

def link
  @link
end

Instance Method Details

#serializeHash

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

Returns:

  • (Hash)

    The serialized sticker message.



38
39
40
# File 'lib/ruby/whatsapp/messages/sticker.rb', line 38

def serialize
  envelope(type: Defaults::TYPE, sticker:)
end