Module: Auth0::Api::V2::Jobs
- Included in:
- Auth0::Api::V2
- Defined in:
- lib/auth0/api/v2/jobs.rb
Overview
Methods to use the jobs endpoints
Instance Method Summary collapse
-
#export_users(options = {}) ⇒ json
Export all users to a file using a long running job.
-
#get_job(job_id) ⇒ json
Retrieves a job.
-
#get_job_errors(job_id) ⇒ json
Retrieve error details based on the id of the job.
-
#import_users(users_file, connection_id, options = {}) ⇒ json
Imports users to a connection from a file using a long running job.
-
#send_verification_email(user_id, client_id = nil, identity: nil, organization_id: nil) ⇒ json
Send an email to the specified user that asks them to click a link to verify their email address.
Instance Method Details
#export_users(options = {}) ⇒ json
Export all users to a file using a long running job.
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/auth0/api/v2/jobs.rb', line 69 def export_users( = {}) request_params = { connection_id: .fetch(:connection_id, nil), format: .fetch(:format, nil), limit: .fetch(:limit, nil), fields: fields_for_export(.fetch(:fields, nil)) } path = "#{jobs_path}/users-exports" post(path, request_params) end |
#get_job(job_id) ⇒ json
Retrieves a job. Useful to check its status.
11 12 13 14 15 16 |
# File 'lib/auth0/api/v2/jobs.rb', line 11 def get_job(job_id) raise Auth0::InvalidParameter, 'Must specify a job id' if job_id.to_s.empty? path = "#{jobs_path}/#{job_id}" get(path) end |
#get_job_errors(job_id) ⇒ json
Retrieve error details based on the id of the job. Useful to check its status.
23 24 25 26 27 28 |
# File 'lib/auth0/api/v2/jobs.rb', line 23 def get_job_errors(job_id) raise Auth0::InvalidParameter, 'Must specify a job id' if job_id.to_s.empty? path = "#{jobs_path}/#{job_id}/errors" get(path) end |
#import_users(users_file, connection_id, options = {}) ⇒ json
Imports users to a connection from a file using a long running job. Documentation for the file format: docs.auth0.com/bulk-import
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/auth0/api/v2/jobs.rb', line 41 def import_users(users_file, connection_id, = {}) raise Auth0::InvalidParameter, 'Must specify a valid file' if users_file.to_s.empty? raise Auth0::InvalidParameter, 'Must specify a connection_id' if connection_id.to_s.empty? request_params = { users: users_file, connection_id: connection_id, upsert: .fetch(:upsert, false), external_id: .fetch(:external_id, nil), send_completion_email: .fetch(:send_completion_email, true) } path = "#{jobs_path}/users-imports" post_file(path, request_params) end |
#send_verification_email(user_id, client_id = nil, identity: nil, organization_id: nil) ⇒ json
Send an email to the specified user that asks them to click a link to verify their email address.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/auth0/api/v2/jobs.rb', line 90 def send_verification_email(user_id, client_id = nil, identity: nil, organization_id: nil) raise Auth0::InvalidParameter, 'Must specify a user id' if user_id.to_s.empty? request_params = { user_id: user_id } request_params[:client_id] = client_id unless client_id.nil? request_params[:organization_id] = organization_id unless organization_id.nil? if identity unless identity.is_a? Hash raise Auth0::InvalidParameter, 'Identity must be a hash send an email verification' end request_params[:identity] = identity end path = "#{jobs_path}/verification-email" post(path, request_params) end |