Module: Parse::API::CloudFunctions
- Included in:
- Client
- Defined in:
- lib/parse/api/cloud_functions.rb
Overview
Defines the CloudCode interface for the Parse REST API
Instance Method Summary collapse
-
#call_function(name, body = {}, opts: {}, context: nil) ⇒ Parse::Response
Call a cloud function.
-
#call_function_with_session(name, body = {}, session_token, context: nil) ⇒ Parse::Response
Call a cloud function with a specific session token.
-
#trigger_job(name, body = {}, opts: {}) ⇒ Parse::Response
Trigger a job.
-
#trigger_job_with_session(name, body = {}, session_token) ⇒ Parse::Response
Trigger a job with a specific session token.
Instance Method Details
#call_function(name, body = {}, opts: {}, context: nil) ⇒ Parse::Response
Call a cloud function.
20 21 22 23 24 25 |
# File 'lib/parse/api/cloud_functions.rb', line 20 def call_function(name, body = {}, opts: {}, context: nil) safe = Parse::API::PathSegment.identifier!(name, kind: "function name") headers = {} headers[Parse::Protocol::CLOUD_CONTEXT] = context.to_json unless context.nil? request :post, "functions/#{safe}", body: body, headers: headers, opts: opts end |
#call_function_with_session(name, body = {}, session_token, context: nil) ⇒ Parse::Response
Call a cloud function with a specific session token. This is a convenience method that ensures the session token is properly passed.
47 48 49 50 51 |
# File 'lib/parse/api/cloud_functions.rb', line 47 def call_function_with_session(name, body = {}, session_token, context: nil) opts = {} opts[:session_token] = session_token if session_token.present? call_function(name, body, opts: opts, context: context) end |
#trigger_job(name, body = {}, opts: {}) ⇒ Parse::Response
Trigger a job.
34 35 36 37 |
# File 'lib/parse/api/cloud_functions.rb', line 34 def trigger_job(name, body = {}, opts: {}) safe = Parse::API::PathSegment.identifier!(name, kind: "job name") request :post, "jobs/#{safe}", body: body, opts: opts end |
#trigger_job_with_session(name, body = {}, session_token) ⇒ Parse::Response
Trigger a job with a specific session token. This is a convenience method that ensures the session token is properly passed.
59 60 61 62 63 |
# File 'lib/parse/api/cloud_functions.rb', line 59 def trigger_job_with_session(name, body = {}, session_token) opts = {} opts[:session_token] = session_token if session_token.present? trigger_job(name, body, opts: opts) end |