class MessageQuickly::Api::ThreadSettings

Public Class Methods

get_started_button(payload) click to toggle source
# 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) click to toggle source
# 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 = []) click to toggle source
# 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_button() click to toggle source
# 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_menu() click to toggle source
# File lib/message_quickly/api/thread_settings.rb, line 61
def self.remove_persistent_menu
  ThreadSettings.new.remove_persistent_menu
end

Public Instance Methods

get_started_button(payload) click to toggle source
# 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) click to toggle source
# 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 = []) click to toggle source
# 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_button() click to toggle source
# 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 = []) click to toggle source
# 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

Private Instance Methods

request_string() click to toggle source
# File lib/message_quickly/api/thread_settings.rb, line 92
def request_string
  "#{ENV['FACEBOOK_MESSENGER_PAGE_ID']}/thread_settings"
end