Method: App42::User::UserService#update_email

Defined in:
lib/user/UserService.rb

#update_email(user_name, email_id) ⇒ Object

Updates the User based on userName. Note: Only email can be updated. Username cannot be updated.

Parameters:

  • uName
    • UserName which should be unique for the App

  • emailAddress
    • Email address of the user

Returns:

  • updated User Object

Raises:

  • App42Exception



434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
# File 'lib/user/UserService.rb', line 434

def update_email(user_name,  email_id)
  puts "Update User Called "
  puts "Base url #{@base_url}"
  response, usr = nil
  usr, util = User.new, Util.new
  util.throwExceptionIfNullOrBlank(user_name, "UserName")
  util.throwExceptionIfNullOrBlank(email_id, "EmailAddress")
  util.throwExceptionIfNullOrBlank(email_id, "Email Address")
  begin
    connection = App42::Connection::RESTConnection.new(@base_url)
    body = {'app42' => {"user"=> {
      "userName" => user_name,
      "email" => email_id
      }}}.to_json
    puts "Body #{body}"
    query_params = {}
    params = {
      'apiKey'=> @api_key,
      'version' => @version,
      'timeStamp' => util.get_timestamp_utc,
    }
    query_params = params.clone
    params.store("body", body)
    puts query_params
    signature = util.sign(@secret_key, params)
    resource_url = "#{@version}/#{@resource}"
    response = connection.put(signature, resource_url, query_params, body)
    user = UserResponseBuilder.new
    usr = user.buildResponse(response)
  rescue  App42Exception =>e
    raise e
  rescue  Exception => e
    raise App42Exception.new(e)
  end
  return usr
end