Class: MessengerPlatform::Entities::Welcome

Inherits:
Object
  • Object
show all
Defined in:
lib/messenger_platform/entities/welcome.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page_id) ⇒ Welcome

Returns a new instance of Welcome.



6
7
8
# File 'lib/messenger_platform/entities/welcome.rb', line 6

def initialize(page_id)
  @page_id = page_id
end

Instance Attribute Details

#page_idObject

Returns the value of attribute page_id.



4
5
6
# File 'lib/messenger_platform/entities/welcome.rb', line 4

def page_id
  @page_id
end

Instance Method Details

#call(text) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/messenger_platform/entities/welcome.rb', line 10

def call(text)
  params = {
    access_token: Config.token,
    setting_type: 'call_to_actions',
    thread_state: 'new_thread',
    call_to_actions: [{ message: { text: text } }]
  }

  Typhoeus.post("#{Config.end_point}/#{page_id || Config.page_id}/thread_settings", body: params)
end