Module: Facebook::Messenger::Profile
- Includes:
- HTTParty
- Defined in:
- lib/facebook/messenger/profile.rb
Overview
This module provide functionality to manage the messenger profile.
Defined Under Namespace
Classes: Error
Class Method Summary collapse
-
.default_options ⇒ Hash
Default HTTParty options.
-
.raise_errors(response) ⇒ Object
Function raise error if response has error key.
-
.set(settings, access_token:) ⇒ Boolean
Set the messenger profile.
-
.unset(settings, access_token:) ⇒ Boolean
Unset the messenger profile.
Class Method Details
.default_options ⇒ Hash
Default HTTParty options.
78 79 80 81 82 83 84 |
# File 'lib/facebook/messenger/profile.rb', line 78 def super.merge( headers: { 'Content-Type' => 'application/json' } ) end |
.raise_errors(response) ⇒ Object
Function raise error if response has error key.
69 70 71 |
# File 'lib/facebook/messenger/profile.rb', line 69 def raise_errors(response) raise Error, response['error'] if response.key? 'error' end |
.set(settings, access_token:) ⇒ Boolean
Set the messenger profile.
30 31 32 33 34 35 36 37 38 |
# File 'lib/facebook/messenger/profile.rb', line 30 def set(settings, access_token:) response = post '/messenger_profile', body: settings.to_json, query: { access_token: access_token } raise_errors(response) true end |
.unset(settings, access_token:) ⇒ Boolean
Unset the messenger profile.
51 52 53 54 55 56 57 58 59 |
# File 'lib/facebook/messenger/profile.rb', line 51 def unset(settings, access_token:) response = delete '/messenger_profile', body: settings.to_json, query: { access_token: access_token } raise_errors(response) true end |