create method

Future<User> create(
  1. UserNew userNew,
  2. Authentication authentication
)

Implementation

Future<User> create(UserNew userNew, Authentication authentication) async {
  http.Response response = await _httpService.post(
    '/api/v1/users.create',
    jsonEncode(userNew.toMap()),
    authentication,
  );

  if (response.statusCode == 200) {
    if (response.body.isNotEmpty == true) {
      return User.fromMap(jsonDecode(response.body));
    } else {
      return User();
    }
  }
  throw RocketChatException(response.body);
}