feat(app): clean architecture with typed repositories, DTO models and calendar event logos
This commit is contained in:
@@ -39,27 +39,29 @@ class NewsArticleModel extends Equatable {
|
||||
|
||||
factory NewsArticleModel.fromJson(Map<String, dynamic> json) {
|
||||
List<MatchedAssetModel> assets = [];
|
||||
final mList = json['matchedAssets'] ?? json['MatchedAssets'];
|
||||
final mList = json['matchedAssets'];
|
||||
if (mList != null && mList is List) {
|
||||
assets = mList.map((e) => MatchedAssetModel.fromJson(e as Map<String, dynamic>)).toList();
|
||||
assets = mList
|
||||
.whereType<Map<String, dynamic>>()
|
||||
.map((e) => MatchedAssetModel.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
|
||||
return NewsArticleModel(
|
||||
id: json['id']?.toString() ?? json['Id']?.toString() ?? '',
|
||||
title: json['title']?.toString() ?? json['Title']?.toString() ?? 'No Title',
|
||||
author: json['author']?.toString() ?? json['Author']?.toString() ?? 'Unknown',
|
||||
summary: json['summary']?.toString() ?? json['Summary']?.toString() ?? '',
|
||||
contentRaw: json['contentRaw']?.toString() ?? json['ContentRaw']?.toString() ?? '',
|
||||
sourceUrl: json['sourceUrl']?.toString() ?? json['SourceUrl']?.toString() ?? '',
|
||||
scrapedAt: DateTime.tryParse(json['scrapedAt']?.toString() ?? json['ScrapedAt']?.toString() ?? '') ?? DateTime.now(),
|
||||
publishedAt: DateTime.tryParse(json['publishedAt']?.toString() ?? json['PublishedAt']?.toString() ?? '') ?? DateTime.now(),
|
||||
status: json['status']?.toString() ?? json['Status']?.toString() ?? 'Completed',
|
||||
sentiment: json['sentiment']?.toString() ?? json['Sentiment']?.toString() ?? '',
|
||||
|
||||
sentimentScore: (json['sentimentScore'] ?? json['SentimentScore'] ?? 0.0).toDouble(),
|
||||
confidence: (json['confidence'] ?? json['Confidence'] ?? 0.0).toDouble(),
|
||||
finbertResult: (json['finbertResult'] != null || json['FinbertResult'] != null)
|
||||
? FinbertResultModel.fromJson(json['finbertResult'] ?? json['FinbertResult'])
|
||||
id: json['id']?.toString() ?? '',
|
||||
title: json['title']?.toString() ?? 'No Title',
|
||||
author: json['author']?.toString() ?? 'Unknown',
|
||||
summary: json['summary']?.toString() ?? '',
|
||||
contentRaw: json['contentRaw']?.toString() ?? '',
|
||||
sourceUrl: json['sourceUrl']?.toString() ?? '',
|
||||
scrapedAt: DateTime.tryParse(json['scrapedAt']?.toString() ?? '') ?? DateTime.now(),
|
||||
publishedAt: DateTime.tryParse(json['publishedAt']?.toString() ?? '') ?? DateTime.now(),
|
||||
status: json['status']?.toString() ?? 'Completed',
|
||||
sentiment: json['sentiment']?.toString() ?? '',
|
||||
sentimentScore: (json['sentimentScore'] as num?)?.toDouble() ?? 0.0,
|
||||
confidence: (json['confidence'] as num?)?.toDouble() ?? 0.0,
|
||||
finbertResult: json['finbertResult'] != null
|
||||
? FinbertResultModel.fromJson(json['finbertResult'] as Map<String, dynamic>)
|
||||
: null,
|
||||
matchedAssets: assets,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user