create method

Future<RoomNewResponse> create(
  1. RoomNew roomNew,
  2. Authentication authentication
)

Implementation

Future<RoomNewResponse> create(
  RoomNew roomNew,
  Authentication authentication,
) async {
  http.Response response = await _httpService.post(
    '/api/v1/im.create',
    jsonEncode(roomNew.toMap()),
    authentication,
  );

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