Implementation
ChannelUserMessageSendRequest({
required this.channelType,
required this.channelUrl,
required this.params,
}) : super() {
//
payload.addAll({
'channel_url': channelUrl,
'message': params.message,
'data': params.data,
'custom_type': params.customType
});
if (params.targetLanguages.isNotEmpty) {
payload['target_langs'] = params.targetLanguages;
payload['translations'] = {for (var e in params.targetLanguages) e: ''};
}
if (params.pushOption == PushNotificationDeliveryOption.suppress) {
payload['push_option'] = params.pushOption.asString();
}
payload['mention_type'] = params.mentionType?.asString();
if (params.mentionType == MentionType.users) {
payload['mentioned_user_ids'] = params.mentionedUserIds;
}
payload['created_at'] = DateTime.now().millisecondsSinceEpoch;
payload['metaarray'] = params.metaArrays?.map((e) => e.toJson()).toList();
if (params.parentMessageId != null) {
payload['parent_message_id'] = params.parentMessageId;
payload['root_message_id'] = params.parentMessageId;
}
payload.removeWhere((key, value) => value == null);
}