Class: MessageQuickly::Api::ThreadSettings

Inherits:
Base
  • Object
show all
Defined in:
lib/message_quickly/api/thread_settings.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

client, #initialize

Constructor Details

This class inherits a constructor from MessageQuickly::Api::Base

Class Method Details

.get_started_button(payload) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/message_quickly/api/thread_settings.rb', line 15

def self.get_started_button(payload)
  # curl -X POST -H "Content-Type: application/json" -d '{
  #   "setting_type":"call_to_actions",
  #   "thread_state":"new_thread",
  #   "call_to_actions":[
  #     {
  #       "payload":"USER_DEFINED_PAYLOAD"
  #     }
  #   ]
  # }' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"
  ThreadSettings.new.get_started_button(payload)
end

.greeting(text) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/message_quickly/api/thread_settings.rb', line 5

def self.greeting(text)
  # curl -X POST -H "Content-Type: application/json" -d '{
  #   "setting_type":"greeting",
  #   "greeting":{
  #       "text":"Welcome to My Company!"
  #   }
  # }' "https://graph.facebook.com/v2.6/<PAGE_ID>/thread_settings?access_token=<PAGE_ACCESS_TOKEN>"
  ThreadSettings.new.greeting(text)
end

.persistent_menu(payloads = []) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/message_quickly/api/thread_settings.rb', line 36

def self.persistent_menu(payloads = [])
  # curl -X POST -H "Content-Type: application/json" -d '{
  #   "setting_type" : "call_to_actions",
  #   "thread_state" : "existing_thread",
  #   "call_to_actions":[
  #     {
  #       "type":"postback",
  #       "title":"Help",
  #       "payload":"DEVELOPER_DEFINED_PAYLOAD_FOR_HELP"
  #     },
  #     {
  #       "type":"postback",
  #       "title":"Start a New Order",
  #       "payload":"DEVELOPER_DEFINED_PAYLOAD_FOR_START_ORDER"
  #     },
  #     {
  #       "type":"web_url",
  #       "title":"View Website",
  #       "url":"http://petersapparel.parseapp.com/"
  #     }
  #   ]
  # }' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"
  ThreadSettings.new.persistent_menu(payloads)
end

.remove_get_started_buttonObject



28
29
30
31
32
33
34
# File 'lib/message_quickly/api/thread_settings.rb', line 28

def self.remove_get_started_button
  # curl -X DELETE -H "Content-Type: application/json" -d '{
  #   "setting_type":"call_to_actions",
  #   "thread_state":"new_thread"
  # }' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"
  ThreadSettings.new.remove_get_started_button
end

.remove_persistent_menuObject



61
62
63
# File 'lib/message_quickly/api/thread_settings.rb', line 61

def self.remove_persistent_menu
  ThreadSettings.new.remove_persistent_menu
end

Instance Method Details

#get_started_button(payload) ⇒ Object



70
71
72
73
# File 'lib/message_quickly/api/thread_settings.rb', line 70

def get_started_button(payload)
  json = @client.post(request_string, { setting_type: 'call_to_actions', thread_state: 'new_thread', call_to_actions: [payload: payload] })
  json['result'] == "Successfully added new_thread's CTAs"
end

#greeting(text) ⇒ Object



65
66
67
68
# File 'lib/message_quickly/api/thread_settings.rb', line 65

def greeting(text)
  json = @client.post(request_string, { setting_type: 'greeting', greeting: { text: text } })
  json['result'] == "Successfully updated greeting"
end

#persistent_menu(payloads = []) ⇒ Object



80
81
82
83
# File 'lib/message_quickly/api/thread_settings.rb', line 80

def persistent_menu(payloads = [])
  json = @client.post(request_string, { setting_type: 'call_to_actions', thread_state: 'existing_thread', call_to_actions: payloads })
  json['result'] == "Successfully added structured menu CTAs"
end

#remove_get_started_buttonObject



75
76
77
78
# File 'lib/message_quickly/api/thread_settings.rb', line 75

def remove_get_started_button
  json = @client.delete(request_string, { setting_type: 'call_to_actions', thread_state: 'new_thread' })
  json['result'] == "Successfully deleted all new_thread's CTAs"
end

#remove_persistent_menu(payloads = []) ⇒ Object



85
86
87
88
# File 'lib/message_quickly/api/thread_settings.rb', line 85

def remove_persistent_menu(payloads = [])
  json = @client.delete(request_string, { setting_type: 'call_to_actions', thread_state: 'existing_thread' })
  json['result'] == "Successfully deleted structured menu CTAs"
end