elCaribe app - customization and branding
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import 'package:news/utils/api.dart';
|
||||
import 'package:news/utils/strings.dart';
|
||||
|
||||
class VideoRemoteDataSource {
|
||||
Future<dynamic> getVideos({required String limit, required String offset, required String langId, String? latitude, String? longitude}) async {
|
||||
try {
|
||||
final body = {LIMIT: limit, OFFSET: offset, LANGUAGE_ID: langId};
|
||||
if (latitude != null && latitude != "null") body[LATITUDE] = latitude;
|
||||
if (longitude != null && longitude != "null") body[LONGITUDE] = longitude;
|
||||
|
||||
final result = await Api.sendApiRequest(body: body, url: Api.getVideosApi);
|
||||
|
||||
return result;
|
||||
} catch (e) {
|
||||
throw ApiMessageAndCodeException(errorMessage: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
23
news-app/lib/data/repositories/Videos/videosRepository.dart
Normal file
23
news-app/lib/data/repositories/Videos/videosRepository.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:news/data/models/NewsModel.dart';
|
||||
import 'package:news/utils/strings.dart';
|
||||
import 'package:news/data/repositories/Videos/videoRemoteDataSource.dart';
|
||||
|
||||
class VideoRepository {
|
||||
static final VideoRepository _videoRepository = VideoRepository._internal();
|
||||
|
||||
late VideoRemoteDataSource _videoRemoteDataSource;
|
||||
|
||||
factory VideoRepository() {
|
||||
_videoRepository._videoRemoteDataSource = VideoRemoteDataSource();
|
||||
return _videoRepository;
|
||||
}
|
||||
|
||||
VideoRepository._internal();
|
||||
|
||||
Future<Map<String, dynamic>> getVideo({required String offset, required String limit, required String langId, String? latitude, String? longitude}) async {
|
||||
final result = await _videoRemoteDataSource.getVideos(limit: limit, offset: offset, langId: langId, latitude: latitude, longitude: longitude);
|
||||
return (result[ERROR])
|
||||
? {ERROR: result[ERROR], MESSAGE: result[MESSAGE]}
|
||||
: {ERROR: result[ERROR], "total": result[TOTAL], "Video": (result[DATA] as List).map((e) => NewsModel.fromVideos(e)).toList()};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user