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 CategoryRemoteDataSource {
|
||||
Future<dynamic> getCategory({required String limit, required String offset, required String langId}) async {
|
||||
try {
|
||||
final body = {LIMIT: limit, OFFSET: offset, LANGUAGE_ID: langId};
|
||||
final result = await Api.sendApiRequest(body: body, url: Api.getCatApi);
|
||||
return result;
|
||||
} catch (e) {
|
||||
throw ApiMessageAndCodeException(errorMessage: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import 'package:news/data/models/CategoryModel.dart';
|
||||
import 'package:news/data/repositories/Category/categoryRemoteDataSource.dart';
|
||||
import 'package:news/utils/strings.dart';
|
||||
|
||||
class CategoryRepository {
|
||||
static final CategoryRepository _notificationRepository = CategoryRepository._internal();
|
||||
|
||||
late CategoryRemoteDataSource _notificationRemoteDataSource;
|
||||
|
||||
factory CategoryRepository() {
|
||||
_notificationRepository._notificationRemoteDataSource = CategoryRemoteDataSource();
|
||||
return _notificationRepository;
|
||||
}
|
||||
|
||||
CategoryRepository._internal();
|
||||
|
||||
Future<Map<String, dynamic>> getCategory({required String offset, required String limit, required String langId}) async {
|
||||
final result = await _notificationRemoteDataSource.getCategory(limit: limit, offset: offset, langId: langId);
|
||||
|
||||
return (result[ERROR])
|
||||
? {ERROR: result[ERROR], MESSAGE: result[MESSAGE]}
|
||||
: {ERROR: result[ERROR], "total": result[TOTAL], "Category": (result[DATA] as List).map((e) => CategoryModel.fromJson(e)).toList()};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user