updateUser method

Future<void> updateUser({
  1. required String organizationId,
  2. required String userId,
  3. String? city,
  4. String? company,
  5. String? country,
  6. String? department,
  7. String? displayName,
  8. String? firstName,
  9. bool? hiddenFromGlobalAddressList,
  10. String? identityProviderUserId,
  11. String? initials,
  12. String? jobTitle,
  13. String? lastName,
  14. String? office,
  15. UserRole? role,
  16. String? street,
  17. String? telephone,
  18. String? zipCode,
})

Updates data for the user. To have the latest information, it must be preceded by a DescribeUser call. The dataset in the request should be the one expected when performing another DescribeUser call.

May throw DirectoryServiceAuthenticationFailedException. May throw DirectoryUnavailableException. May throw EntityNotFoundException. May throw EntityStateException. May throw InvalidParameterException. May throw OrganizationNotFoundException. May throw OrganizationStateException. May throw UnsupportedOperationException.

Parameter organizationId : The identifier for the organization under which the user exists.

Parameter userId : The identifier for the user to be updated.

The identifier can be the UserId, Username, or email. The following identity formats are available:

  • User ID: 12345678-1234-1234-1234-123456789012 or S-1-1-12-1234567890-123456789-123456789-1234
  • Email address: user@domain.tld
  • User name: user

Parameter city : Updates the user's city.

Parameter company : Updates the user's company.

Parameter country : Updates the user's country.

Parameter department : Updates the user's department.

Parameter displayName : Updates the display name of the user.

Parameter firstName : Updates the user's first name.

Parameter hiddenFromGlobalAddressList : If enabled, the user is hidden from the global address list.

Parameter identityProviderUserId : User ID from the IAM Identity Center. If this parameter is empty it will be updated automatically when the user logs in for the first time to the mailbox associated with WorkMail.

Parameter initials : Updates the user's initials.

Parameter jobTitle : Updates the user's job title.

Parameter lastName : Updates the user's last name.

Parameter office : Updates the user's office.

Parameter role : Updates the user role.

You cannot pass SYSTEM_USER or RESOURCE.

Parameter street : Updates the user's street address.

Parameter telephone : Updates the user's contact details.

Parameter zipCode : Updates the user's zip code.

Implementation

Future<void> updateUser({
  required String organizationId,
  required String userId,
  String? city,
  String? company,
  String? country,
  String? department,
  String? displayName,
  String? firstName,
  bool? hiddenFromGlobalAddressList,
  String? identityProviderUserId,
  String? initials,
  String? jobTitle,
  String? lastName,
  String? office,
  UserRole? role,
  String? street,
  String? telephone,
  String? zipCode,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'WorkMailService.UpdateUser'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'OrganizationId': organizationId,
      'UserId': userId,
      if (city != null) 'City': city,
      if (company != null) 'Company': company,
      if (country != null) 'Country': country,
      if (department != null) 'Department': department,
      if (displayName != null) 'DisplayName': displayName,
      if (firstName != null) 'FirstName': firstName,
      if (hiddenFromGlobalAddressList != null)
        'HiddenFromGlobalAddressList': hiddenFromGlobalAddressList,
      if (identityProviderUserId != null)
        'IdentityProviderUserId': identityProviderUserId,
      if (initials != null) 'Initials': initials,
      if (jobTitle != null) 'JobTitle': jobTitle,
      if (lastName != null) 'LastName': lastName,
      if (office != null) 'Office': office,
      if (role != null) 'Role': role.value,
      if (street != null) 'Street': street,
      if (telephone != null) 'Telephone': telephone,
      if (zipCode != null) 'ZipCode': zipCode,
    },
  );
}