User.fromJson constructor

User.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory User.fromJson(Map<String, dynamic> json) {
  if (json['guest_id'] != null) json['user_id'] = json['guest_id'];
  if (json['session_tokens'] != null &&
      (json['session_tokens'] as List).isNotEmpty) {
    final tokens = List<Map>.from(json['session_tokens'] as List);
    json['session_token'] = tokens.first['session_token'];
  }
  if (json['is_online'] != null) {
    bool isOnline = json['is_online'];
    json['connection_status'] = isOnline ? 'online' : 'offline';
  }
  return _$UserFromJson(json);
}