create method

Future<ChannelNewResponse> create(
  1. ChannelNew channelNew,
  2. Authentication authentication
)

Implementation

Future<ChannelNewResponse> create(
    ChannelNew channelNew, Authentication authentication) async {
  http.Response response = await _httpService.post(
    '/api/v1/channels.create',
    jsonEncode(channelNew.toMap()),
    authentication,
  );

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