Class: Whatsapp::Webhook::Message::Referral

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/whatsapp/webhook/message/referral.rb

Overview

Present when an inbound message originated from a Click-to-WhatsApp ad or a post/story with an embedded WhatsApp link.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_url:, source_type:, source_id:, headline:, body:, media_type:, image_url: nil, video_url: nil, thumbnail_url: nil) ⇒ Referral

Returns a new instance of Referral.



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ruby/whatsapp/webhook/message/referral.rb', line 45

def initialize(source_url:, source_type:, source_id:, headline:, body:, media_type:, image_url: nil,
  video_url: nil, thumbnail_url: nil)
  @source_url = source_url
  @source_type = source_type
  @source_id = source_id
  @headline = headline
  @body = body
  @media_type = media_type
  @image_url = image_url
  @video_url = video_url
  @thumbnail_url = thumbnail_url
end

Instance Attribute Details

#bodyString?

Returns:

  • (String, nil)


27
28
29
# File 'lib/ruby/whatsapp/webhook/message/referral.rb', line 27

def body
  @body
end

#headlineString?

Returns:

  • (String, nil)


23
24
25
# File 'lib/ruby/whatsapp/webhook/message/referral.rb', line 23

def headline
  @headline
end

#image_urlString?

Returns:

  • (String, nil)


35
36
37
# File 'lib/ruby/whatsapp/webhook/message/referral.rb', line 35

def image_url
  @image_url
end

#media_typeString?

Returns:

  • (String, nil)


31
32
33
# File 'lib/ruby/whatsapp/webhook/message/referral.rb', line 31

def media_type
  @media_type
end

#source_idString?

Returns:

  • (String, nil)


19
20
21
# File 'lib/ruby/whatsapp/webhook/message/referral.rb', line 19

def source_id
  @source_id
end

#source_typeString?

Returns:

  • (String, nil)


15
16
17
# File 'lib/ruby/whatsapp/webhook/message/referral.rb', line 15

def source_type
  @source_type
end

#source_urlString?

Returns:

  • (String, nil)


11
12
13
# File 'lib/ruby/whatsapp/webhook/message/referral.rb', line 11

def source_url
  @source_url
end

#thumbnail_urlString?

Returns:

  • (String, nil)


43
44
45
# File 'lib/ruby/whatsapp/webhook/message/referral.rb', line 43

def thumbnail_url
  @thumbnail_url
end

#video_urlString?

Returns:

  • (String, nil)


39
40
41
# File 'lib/ruby/whatsapp/webhook/message/referral.rb', line 39

def video_url
  @video_url
end

Class Method Details

.deserialize(data) ⇒ Referral?

Parameters:

  • data (Hash, nil)

    The raw referral hash.

Returns:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/ruby/whatsapp/webhook/message/referral.rb', line 61

def deserialize(data)
  return if data.nil?

  new(
    source_url: data["source_url"],
    source_type: data["source_type"],
    source_id: data["source_id"],
    headline: data["headline"],
    body: data["body"],
    media_type: data["media_type"],
    image_url: data["image_url"],
    video_url: data["video_url"],
    thumbnail_url: data["thumbnail_url"]
  )
end