ChannelUserMessageSendApiRequest constructor Null safety

ChannelUserMessageSendApiRequest(
  1. {required UserMessageParams params,
  2. required ChannelType channelType,
  3. required String channelUrl,
  4. String? senderId,
  5. bool markAsRead = false,
  6. List<String>? additionalMentionedUserIds}
)

Implementation

ChannelUserMessageSendApiRequest({
  required UserMessageParams params,
  required this.channelType,
  required String channelUrl,
  String? senderId,
  bool markAsRead = false,
  List<String>? additionalMentionedUserIds,
}) : super(userId: senderId) {
  url = '${channelType.urlString}/$channelUrl/messages';
  body = {
    'message_type': CommandString.userMessage,
    'user_id': senderId,
    'mark_as_read': markAsRead,
    if (additionalMentionedUserIds != null)
      'mentioned_user_ids': additionalMentionedUserIds,
  };

  body.addAll(params.toJson());
  body.removeWhere((key, value) => value == null);
}