Class: Auth0::Jobs::UsersImports::Client
- Inherits:
-
Object
- Object
- Auth0::Jobs::UsersImports::Client
- Defined in:
- lib/auth0/jobs/users_imports/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Auth0::Types::CreateImportUsersResponseContent
Import users from a formatted file into a connection via a long-running job.
- #initialize(client:) ⇒ void constructor
Constructor Details
#initialize(client:) ⇒ void
10 11 12 |
# File 'lib/auth0/jobs/users_imports/client.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Auth0::Types::CreateImportUsersResponseContent
Import users from a formatted file into a
connection via a long-running job. When importing users, with or without upsert, the email_verified is set
to false when the email address is added or updated. Users must verify their email address. To avoid this
behavior, set email_verified to true in the imported data.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/auth0/jobs/users_imports/client.rb', line 29 def create(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) body = Internal::Multipart::FormData.new body.add_part(params[:users].to_form_data_part(name: "users")) if params[:users] if params[:connection_id] body.add( name: "connection_id", value: params[:connection_id] ) end if params[:upsert] body.add( name: "upsert", value: params[:upsert] ) end if params[:external_id] body.add( name: "external_id", value: params[:external_id] ) end if params[:send_completion_email] body.add( name: "send_completion_email", value: params[:send_completion_email] ) end request = Auth0::Internal::Multipart::Request.new( base_url: [:base_url], method: "POST", path: "jobs/users-imports", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Auth0::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Auth0::Types::CreateImportUsersResponseContent.load(response.body) else error_class = Auth0::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |