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 webhook triggers. Mirrors Parse Server's
triggers.Typesso registration of the auth / LiveQuery / password- reset hooks is no longer pre-rejected by the SDK.NOTE: this allowlist gates registration only. The webhook router in Webhooks currently shapes payloads for the object triggers (before/after save/delete/find); the login / connect / subscribe / password-reset payloads carry a different shape (no
object) and their first-class routing is a follow-up.beforeConnectis a connection-global trigger whose Parse-canonical className is the@Connectsentinel; file triggers use@File. Both are accepted by the trigger-className validator (PathSegment.trigger_class_name!). [ :afterDelete, :afterFind, :afterSave, :beforeDelete, :beforeFind, :beforeSave, :beforeLogin, :afterLogin, :afterLogout, :beforePasswordResetRequest, :beforeConnect, :beforeSubscribe, :afterEvent, ].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.
77 78 79 |
# File 'lib/parse/api/hooks.rb', line 77 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.
124 125 126 127 128 |
# File 'lib/parse/api/hooks.rb', line 124 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.
95 96 97 98 |
# File 'lib/parse/api/hooks.rb', line 95 def delete_function(functionName) safe = Parse::API::PathSegment.identifier!(functionName, kind: "function name") request :put, "#{HOOKS_PREFIX}functions/#{safe}", body: { __op: "Delete" } end |
#delete_trigger(triggerName, className) ⇒ Parse::Response
Remove a registered cloud code webhook trigger.
147 148 149 150 151 |
# File 'lib/parse/api/hooks.rb', line 147 def delete_trigger(triggerName, className) triggerName = _verify_trigger(triggerName) safe_class = Parse::API::PathSegment.trigger_class_name!(className, kind: "class name") request :put, "#{HOOKS_PREFIX}triggers/#{safe_class}/#{triggerName}", body: { __op: "Delete" } end |
#fetch_function(functionName) ⇒ Parse::Response
Fetch information about a specific registered cloud function.
68 69 70 71 |
# File 'lib/parse/api/hooks.rb', line 68 def fetch_function(functionName) safe = Parse::API::PathSegment.identifier!(functionName, kind: "function name") request :get, "#{HOOKS_PREFIX}functions/#{safe}" end |
#fetch_trigger(triggerName, className) ⇒ Parse::Response
Fetch information about a registered webhook trigger.
112 113 114 115 116 |
# File 'lib/parse/api/hooks.rb', line 112 def fetch_trigger(triggerName, className) triggerName = _verify_trigger(triggerName) safe_class = Parse::API::PathSegment.trigger_class_name!(className, kind: "class name") request :get, "#{HOOKS_PREFIX}triggers/#{safe_class}/#{triggerName}" end |
#functions ⇒ Parse::Response
Fetch all defined cloud code functions.
60 61 62 63 |
# File 'lib/parse/api/hooks.rb', line 60 def functions opts = { cache: false } request :get, "#{HOOKS_PREFIX}functions", opts: opts end |
#triggers ⇒ Parse::Response
Get the set of registered triggers.
102 103 104 105 |
# File 'lib/parse/api/hooks.rb', line 102 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.
85 86 87 88 89 90 |
# File 'lib/parse/api/hooks.rb', line 85 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. safe = Parse::API::PathSegment.identifier!(functionName, kind: "function name") request :put, "#{HOOKS_PREFIX}functions/#{safe}", body: { url: url } end |
#update_trigger(triggerName, className, url) ⇒ Parse::Response
Updated the registered endpoint for this cloud code webhook trigger.
136 137 138 139 140 |
# File 'lib/parse/api/hooks.rb', line 136 def update_trigger(triggerName, className, url) triggerName = _verify_trigger(triggerName) safe_class = Parse::API::PathSegment.trigger_class_name!(className, kind: "class name") request :put, "#{HOOKS_PREFIX}triggers/#{safe_class}/#{triggerName}", body: { url: url } end |