modifyUser method

Future<MdmEmpty> modifyUser(
  1. String apiKey, {
  2. required String userId,
  3. required ModifyUserRequestDto modifyUserRequestDto,
})

Implementation

Future<MdmEmpty> modifyUser(
  String apiKey, {
  required String userId,
  required ModifyUserRequestDto modifyUserRequestDto,
}) async {
  final String url = '$channel/api/v1/mdm/users/$userId';

  final requestDto = modifyUserRequestDto.toJson();
  requestDto.removeWhere((key, value) => value == null);

  final response = await http.put(
    Uri.parse(url),
    headers: {
      'Authorization': 'Zoho-oauthtoken $apiKey',
      'Content-Type': 'application/json;charset=UTF-8',
    },
  );

  if (!response.statusCode.isSuccessful) {
    throw MdmEngineException(
      method: response.request?.method,
      url: url,
      statusCode: response.statusCode,
      error: response.body,
    );
  }

  return MdmEmpty();
}