ChannelMessagesGetRequest constructor Null safety

ChannelMessagesGetRequest(
  1. {required ChannelType channelType,
  2. required String channelUrl,
  3. required Map<String, dynamic> params,
  4. int timestamp = 0,
  5. int messageId = 0,
  6. int parentMessageId = 0}
)

Implementation

ChannelMessagesGetRequest({
  required this.channelType,
  required String channelUrl,
  required Map<String, dynamic> params,
  int timestamp = 0,
  int messageId = 0,
  int parentMessageId = 0,
}) : super() {
  if (messageId <= 0 && timestamp <= 0) {
    throw InvalidParameterError();
  }

  url = '${channelType.urlString}/$channelUrl/messages';

  queryParams = params;
  queryParams['is_sdk'] = true;
  if (messageId > 0) {
    queryParams['message_id'] = messageId;
  } else {
    queryParams['message_ts'] = timestamp;
  }

  if (parentMessageId > 0) {
    queryParams['root_message_id'] = parentMessageId;
  }
}