Module: Parse::API::Hooks
- Included in:
- Client
- Defined in:
- lib/parse/api/hooks.rb
Overview
Defines the Parse webhooks interface for the Parse REST API
Constant Summary collapse
- TRIGGER_NAMES =
The allowed set of Parse triggers.
[:afterDelete, :afterFind, :afterSave, :beforeDelete, :beforeFind, :beforeSave].freeze
Instance Method Summary collapse
-
#create_function(functionName, url) ⇒ Parse::Response
Register a cloud code webhook function pointing to a endpoint url.
-
#create_trigger(triggerName, className, url) ⇒ Parse::Response
Register a new cloud code webhook trigger with an endpoint url.
-
#delete_function(functionName) ⇒ Parse::Response
Remove a registered cloud code webhook function.
-
#delete_trigger(triggerName, className) ⇒ Parse::Response
Remove a registered cloud code webhook trigger.
-
#fetch_function(functionName) ⇒ Parse::Response
Fetch information about a specific registered cloud function.
-
#fetch_trigger(triggerName, className) ⇒ Parse::Response
Fetch information about a registered webhook trigger.
-
#functions ⇒ Parse::Response
Fetch all defined cloud code functions.
-
#triggers ⇒ Parse::Response
Get the set of registered triggers.
-
#update_function(functionName, url) ⇒ Parse::Response
Updated the endpoint url for a registered cloud code webhook function.
-
#update_trigger(triggerName, className, url) ⇒ Parse::Response
Updated the registered endpoint for this cloud code webhook trigger.
Instance Method Details
#create_function(functionName, url) ⇒ Parse::Response
Register a cloud code webhook function pointing to a endpoint url.
41 42 43 |
# File 'lib/parse/api/hooks.rb', line 41 def create_function(functionName, url) request :post, "#{HOOKS_PREFIX}functions", body: {functionName: functionName, url: url} end |
#create_trigger(triggerName, className, url) ⇒ Parse::Response
Register a new cloud code webhook trigger with an endpoint url.
85 86 87 88 89 |
# File 'lib/parse/api/hooks.rb', line 85 def create_trigger(triggerName, className, url) triggerName = _verify_trigger(triggerName) body = {className: className, triggerName: triggerName, url: url } request :post, "#{HOOKS_PREFIX}triggers", body: body end |
#delete_function(functionName) ⇒ Parse::Response
Remove a registered cloud code webhook function.
58 59 60 |
# File 'lib/parse/api/hooks.rb', line 58 def delete_function(functionName) request :put, "#{HOOKS_PREFIX}functions/#{functionName}", body: { __op: "Delete" } end |
#delete_trigger(triggerName, className) ⇒ Parse::Response
Remove a registered cloud code webhook trigger.
107 108 109 110 |
# File 'lib/parse/api/hooks.rb', line 107 def delete_trigger(triggerName, className) triggerName = _verify_trigger(triggerName) request :put, "#{HOOKS_PREFIX}triggers/#{className}/#{triggerName}", body: { __op: "Delete" } end |
#fetch_function(functionName) ⇒ Parse::Response
Fetch information about a specific registered cloud function.
33 34 35 |
# File 'lib/parse/api/hooks.rb', line 33 def fetch_function(functionName) request :get, "#{HOOKS_PREFIX}functions/#{functionName}" end |
#fetch_trigger(triggerName, className) ⇒ Parse::Response
Fetch information about a registered webhook trigger.
74 75 76 77 |
# File 'lib/parse/api/hooks.rb', line 74 def fetch_trigger(triggerName, className) triggerName = _verify_trigger(triggerName) request :get, "#{HOOKS_PREFIX}triggers/#{className}/#{triggerName}" end |
#functions ⇒ Parse::Response
Fetch all defined cloud code functions.
25 26 27 28 |
# File 'lib/parse/api/hooks.rb', line 25 def functions opts = {cache: false} request :get, "#{HOOKS_PREFIX}functions", opts: opts end |
#triggers ⇒ Parse::Response
Get the set of registered triggers.
64 65 66 67 |
# File 'lib/parse/api/hooks.rb', line 64 def triggers opts = {cache: false} request :get, "#{HOOKS_PREFIX}triggers", opts: opts end |
#update_function(functionName, url) ⇒ Parse::Response
Updated the endpoint url for a registered cloud code webhook function.
49 50 51 52 53 |
# File 'lib/parse/api/hooks.rb', line 49 def update_function(functionName, url) # If you add _method => "PUT" to the JSON body, # and send it as a POST request and parse will accept it as a PUT. request :put, "#{HOOKS_PREFIX}functions/#{functionName}", body: { url: url } end |
#update_trigger(triggerName, className, url) ⇒ Parse::Response
Updated the registered endpoint for this cloud code webhook trigger.
97 98 99 100 |
# File 'lib/parse/api/hooks.rb', line 97 def update_trigger(triggerName, className, url) triggerName = _verify_trigger(triggerName) request :put, "#{HOOKS_PREFIX}triggers/#{className}/#{triggerName}", body: { url: url } end |