CatapushMessage.fromMap constructor

CatapushMessage.fromMap(
  1. Map<String, dynamic> json
)

Implementation

factory CatapushMessage.fromMap(Map<String, dynamic> json) => CatapushMessage(
      id: json['messageId'] as String,
      sender: json['sender'] as String,
      body: json['body'] as String?,
      channel: json['channel'] as String?,
      optionalData: json['optionalData'] != null
          ? (json['optionalData'] as Map<dynamic, dynamic>)
              .cast<String, dynamic>()
          : null,
      state: CatapushMessageState.values.firstWhere((e) {
        return e.toString() ==
            'CatapushMessageState.${json['state'] as String}';
      }),
      sentTime: DateTime.tryParse(json['sentTime'] as String? ?? ''),
      hasAttachment: json['hasAttachment'] as bool,
    );