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

Instance Method Details

#get_job(job_id) ⇒ json

Retrieves a job. Useful to check its status.

Parameters:

  • job_id (string)

    The id of the job.

Returns:

  • (json)

    Returns the job status and properties.

Raises:

See Also:



13
14
15
16
17
# File 'lib/auth0/api/v2/jobs.rb', line 13

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

#import_users(users_file, connection_id) ⇒ json

Imports users to a connection from a file using a long running job. Important: The documentation for the file format is at docs.auth0.com/bulk-import.

Parameters:

  • users_file (file)

    A file containing the users to import.

  • connection_id (string)

    The connection id of the connection to which users will be inserted.

Returns:

  • (json)

    Returns the job status and properties.

Raises:

See Also:



26
27
28
29
30
31
32
33
34
35
# File 'lib/auth0/api/v2/jobs.rb', line 26

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
  }
  path = "#{jobs_path}/users-imports"
  post_file(path, request_params)
end

#send_verification_email(user_id) ⇒ json

Send an email to the specified user that asks them to click a link to verify their email address.

Parameters:

  • user_id (string)

    The user_id of the user to whom the email will be sent.

Returns:

  • (json)

    Returns the job status and properties.

Raises:

See Also:



42
43
44
45
46
47
48
49
# File 'lib/auth0/api/v2/jobs.rb', line 42

def send_verification_email(user_id)
  raise Auth0::InvalidParameter, 'Must specify a user id' if user_id.to_s.empty?
  request_params = {
    user_id: user_id
  }
  path = "#{jobs_path}/verification-email"
  post(path, request_params)
end