toJson method

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() {
  final ret = <String, dynamic>{
    'custom_type': customType,
    'data': data,
    'mention_type': mentionType?.asString(),
    if (mentionType == MentionType.users)
      'mentioned_user_ids': mentionedUserIds,
    'metaarray': metaArrays?.map((e) => e.toJson()).toList(),
    if (pushOption == PushNotificationDeliveryOption.suppress)
      'push_option': pushOption.asString(),
    'parent_message_id': parentMessageId,
    'reply_to_channel': replyToChannel,
    'mentioned_users': mentionedUsers?.map((e) => e.toJson()).toList(),
    'pin_message': isPinnedMessage,
  };

  ret.removeWhere((key, value) => value == null);
  return ret;
}