elCaribe app - customization and branding
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import 'package:news/utils/api.dart';
|
||||
import 'package:news/utils/strings.dart';
|
||||
|
||||
class BreakingNewsRemoteDataSource {
|
||||
Future<dynamic> getBreakingNews({required String langId}) async {
|
||||
try {
|
||||
final body = {LANGUAGE_ID: langId};
|
||||
final result = await Api.sendApiRequest(body: body, url: Api.getBreakingNewsApi);
|
||||
return result;
|
||||
} catch (e) {
|
||||
throw ApiMessageAndCodeException(errorMessage: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:news/data/models/BreakingNewsModel.dart';
|
||||
import 'package:news/data/repositories/BreakingNews/breakNewsRemoteDataSource.dart';
|
||||
import 'package:news/utils/strings.dart';
|
||||
|
||||
class BreakingNewsRepository {
|
||||
static final BreakingNewsRepository _breakingNewsRepository = BreakingNewsRepository._internal();
|
||||
|
||||
late BreakingNewsRemoteDataSource _breakingNewsRemoteDataSource;
|
||||
|
||||
factory BreakingNewsRepository() {
|
||||
_breakingNewsRepository._breakingNewsRemoteDataSource = BreakingNewsRemoteDataSource();
|
||||
return _breakingNewsRepository;
|
||||
}
|
||||
|
||||
BreakingNewsRepository._internal();
|
||||
|
||||
Future<dynamic> getBreakingNews({required String langId}) async {
|
||||
final result = await _breakingNewsRemoteDataSource.getBreakingNews(langId: langId);
|
||||
|
||||
return (result[ERROR]) ? {ERROR: result[ERROR], MESSAGE: result[MESSAGE]} : {ERROR: result[ERROR], "BreakingNews": (result[DATA] as List).map((e) => BreakingNewsModel.fromJson(e)).toList()};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user