refactor(settings): rename alerts_* data layer to notifications_*

This commit is contained in:
2026-04-23 03:38:02 +02:00
parent 929ccadb0f
commit 383ea3d053
19 changed files with 266 additions and 243 deletions

View File

@@ -1,9 +0,0 @@
import '../../domain/entities/alert_entity.dart';
abstract class AlertsRemoteDatasource {
Future<(List<AlertEntity>, int totalPages)> getAlerts({
required int page,
int pageSize,
String? type,
});
}

View File

@@ -0,0 +1,9 @@
import '../../domain/entities/notification_entity.dart';
abstract class NotificationsRemoteDatasource {
Future<(List<NotificationEntity>, int totalPages)> getNotifications({
required int page,
int pageSize,
String? type,
});
}

View File

@@ -1,17 +1,17 @@
import 'package:sf_infrastructure/sf_infrastructure.dart'; import 'package:sf_infrastructure/sf_infrastructure.dart';
import 'package:utils/utils.dart'; import 'package:utils/utils.dart';
import '../../domain/entities/alert_entity.dart'; import '../../domain/entities/notification_entity.dart';
import '../models/alerts_response_dto.dart'; import '../models/notifications_response_dto.dart';
import 'alerts_remote_datasource.dart'; import 'notifications_remote_datasource.dart';
class AlertsRemoteDatasourceImpl implements AlertsRemoteDatasource { class NotificationsRemoteDatasourceImpl implements NotificationsRemoteDatasource {
AlertsRemoteDatasourceImpl(this._repository); NotificationsRemoteDatasourceImpl(this._repository);
final SaveFamilyRepository _repository; final SaveFamilyRepository _repository;
@override @override
Future<(List<AlertEntity>, int totalPages)> getAlerts({ Future<(List<NotificationEntity>, int totalPages)> getNotifications({
required int page, required int page,
int pageSize = 20, int pageSize = 20,
String? type, String? type,
@@ -36,9 +36,9 @@ class AlertsRemoteDatasourceImpl implements AlertsRemoteDatasource {
); );
final data = response.data; final data = response.data;
if (data == null || data.isEmpty) return (<AlertEntity>[], 1); if (data == null || data.isEmpty) return (<NotificationEntity>[], 1);
final model = AlertsResponseDto.fromJson(data); final model = NotificationsResponseDto.fromJson(data);
return (model.toEntities(), model.pages); return (model.toEntities(), model.pages);
} }
} }

View File

@@ -1,56 +1,56 @@
import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:freezed_annotation/freezed_annotation.dart';
import '../../domain/entities/alert_entity.dart'; import '../../domain/entities/notification_entity.dart';
part 'alerts_response_dto.freezed.dart'; part 'notifications_response_dto.freezed.dart';
part 'alerts_response_dto.g.dart'; part 'notifications_response_dto.g.dart';
@freezed @freezed
abstract class AlertsResponseDto with _$AlertsResponseDto { abstract class NotificationsResponseDto with _$NotificationsResponseDto {
const factory AlertsResponseDto({ const factory NotificationsResponseDto({
@Default(0) int total, @Default(0) int total,
@Default([]) List<AlertItemDto> items, @Default([]) List<NotificationItemDto> items,
@Default(1) int page, @Default(1) int page,
@Default(1) int pages, @Default(1) int pages,
}) = _AlertsResponseDto; }) = _AlertsResponseDto;
factory AlertsResponseDto.fromJson(Map<String, dynamic> json) => factory NotificationsResponseDto.fromJson(Map<String, dynamic> json) =>
_$AlertsResponseDtoFromJson(json); _$AlertsResponseDtoFromJson(json);
} }
@freezed @freezed
abstract class AlertItemDto with _$AlertItemDto { abstract class NotificationItemDto with _$NotificationItemDto {
const factory AlertItemDto({ const factory NotificationItemDto({
required String id, required String id,
@Default('') String deviceIdentificator, @Default('') String deviceIdentificator,
@Default('') String deviceName, @Default('') String deviceName,
@Default('') String type, @Default('') String type,
AlertGeofenceDto? geofenceAlert, NotificationGeofenceDto? geofenceAlert,
String? delegationId, String? delegationId,
String? userId, String? userId,
@Default(0) int createdAt, @Default(0) int createdAt,
}) = _AlertItemDto; }) = _AlertItemDto;
factory AlertItemDto.fromJson(Map<String, dynamic> json) => factory NotificationItemDto.fromJson(Map<String, dynamic> json) =>
_$AlertItemDtoFromJson(json); _$AlertItemDtoFromJson(json);
} }
@freezed @freezed
abstract class AlertGeofenceDto with _$AlertGeofenceDto { abstract class NotificationGeofenceDto with _$NotificationGeofenceDto {
const factory AlertGeofenceDto({ const factory NotificationGeofenceDto({
required String id, required String id,
required String name, required String name,
}) = _AlertGeofenceDto; }) = _AlertGeofenceDto;
factory AlertGeofenceDto.fromJson(Map<String, dynamic> json) => factory NotificationGeofenceDto.fromJson(Map<String, dynamic> json) =>
_$AlertGeofenceDtoFromJson(json); _$AlertGeofenceDtoFromJson(json);
} }
extension AlertsResponseDtoMapper on AlertsResponseDto { extension NotificationsResponseDtoMapper on NotificationsResponseDto {
List<AlertEntity> toEntities() { List<NotificationEntity> toEntities() {
return items return items
.map( .map(
(item) => AlertEntity( (item) => NotificationEntity(
id: item.id, id: item.id,
deviceIdentificator: item.deviceIdentificator, deviceIdentificator: item.deviceIdentificator,
deviceName: item.deviceName, deviceName: item.deviceName,

View File

@@ -3,7 +3,7 @@
// ignore_for_file: type=lint // ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'alerts_response_dto.dart'; part of 'notifications_response_dto.dart';
// ************************************************************************** // **************************************************************************
// FreezedGenerator // FreezedGenerator
@@ -11,24 +11,31 @@ part of 'alerts_response_dto.dart';
// dart format off // dart format off
T _$identity<T>(T value) => value; T _$identity<T>(T value) => value;
NotificationsResponseDto _$NotificationsResponseDtoFromJson(
Map<String, dynamic> json
) {
return _AlertsResponseDto.fromJson(
json
);
}
/// @nodoc /// @nodoc
mixin _$AlertsResponseDto { mixin _$NotificationsResponseDto {
int get total; List<AlertItemDto> get items; int get page; int get pages; int get total; List<NotificationItemDto> get items; int get page; int get pages;
/// Create a copy of AlertsResponseDto /// Create a copy of NotificationsResponseDto
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$AlertsResponseDtoCopyWith<AlertsResponseDto> get copyWith => _$AlertsResponseDtoCopyWithImpl<AlertsResponseDto>(this as AlertsResponseDto, _$identity); $NotificationsResponseDtoCopyWith<NotificationsResponseDto> get copyWith => _$NotificationsResponseDtoCopyWithImpl<NotificationsResponseDto>(this as NotificationsResponseDto, _$identity);
/// Serializes this AlertsResponseDto to a JSON map. /// Serializes this NotificationsResponseDto to a JSON map.
Map<String, dynamic> toJson(); Map<String, dynamic> toJson();
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is AlertsResponseDto&&(identical(other.total, total) || other.total == total)&&const DeepCollectionEquality().equals(other.items, items)&&(identical(other.page, page) || other.page == page)&&(identical(other.pages, pages) || other.pages == pages)); return identical(this, other) || (other.runtimeType == runtimeType&&other is NotificationsResponseDto&&(identical(other.total, total) || other.total == total)&&const DeepCollectionEquality().equals(other.items, items)&&(identical(other.page, page) || other.page == page)&&(identical(other.pages, pages) || other.pages == pages));
} }
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@@ -37,18 +44,18 @@ int get hashCode => Object.hash(runtimeType,total,const DeepCollectionEquality()
@override @override
String toString() { String toString() {
return 'AlertsResponseDto(total: $total, items: $items, page: $page, pages: $pages)'; return 'NotificationsResponseDto(total: $total, items: $items, page: $page, pages: $pages)';
} }
} }
/// @nodoc /// @nodoc
abstract mixin class $AlertsResponseDtoCopyWith<$Res> { abstract mixin class $NotificationsResponseDtoCopyWith<$Res> {
factory $AlertsResponseDtoCopyWith(AlertsResponseDto value, $Res Function(AlertsResponseDto) _then) = _$AlertsResponseDtoCopyWithImpl; factory $NotificationsResponseDtoCopyWith(NotificationsResponseDto value, $Res Function(NotificationsResponseDto) _then) = _$NotificationsResponseDtoCopyWithImpl;
@useResult @useResult
$Res call({ $Res call({
int total, List<AlertItemDto> items, int page, int pages int total, List<NotificationItemDto> items, int page, int pages
}); });
@@ -56,20 +63,20 @@ $Res call({
} }
/// @nodoc /// @nodoc
class _$AlertsResponseDtoCopyWithImpl<$Res> class _$NotificationsResponseDtoCopyWithImpl<$Res>
implements $AlertsResponseDtoCopyWith<$Res> { implements $NotificationsResponseDtoCopyWith<$Res> {
_$AlertsResponseDtoCopyWithImpl(this._self, this._then); _$NotificationsResponseDtoCopyWithImpl(this._self, this._then);
final AlertsResponseDto _self; final NotificationsResponseDto _self;
final $Res Function(AlertsResponseDto) _then; final $Res Function(NotificationsResponseDto) _then;
/// Create a copy of AlertsResponseDto /// Create a copy of NotificationsResponseDto
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? total = null,Object? items = null,Object? page = null,Object? pages = null,}) { @pragma('vm:prefer-inline') @override $Res call({Object? total = null,Object? items = null,Object? page = null,Object? pages = null,}) {
return _then(_self.copyWith( return _then(_self.copyWith(
total: null == total ? _self.total : total // ignore: cast_nullable_to_non_nullable total: null == total ? _self.total : total // ignore: cast_nullable_to_non_nullable
as int,items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable as int,items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable
as List<AlertItemDto>,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable as List<NotificationItemDto>,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable
as int,pages: null == pages ? _self.pages : pages // ignore: cast_nullable_to_non_nullable as int,pages: null == pages ? _self.pages : pages // ignore: cast_nullable_to_non_nullable
as int, as int,
)); ));
@@ -78,8 +85,8 @@ as int,
} }
/// Adds pattern-matching-related methods to [AlertsResponseDto]. /// Adds pattern-matching-related methods to [NotificationsResponseDto].
extension AlertsResponseDtoPatterns on AlertsResponseDto { extension NotificationsResponseDtoPatterns on NotificationsResponseDto {
/// A variant of `map` that fallback to returning `orElse`. /// A variant of `map` that fallback to returning `orElse`.
/// ///
/// It is equivalent to doing: /// It is equivalent to doing:
@@ -156,7 +163,7 @@ return $default(_that);case _:
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int total, List<AlertItemDto> items, int page, int pages)? $default,{required TResult orElse(),}) {final _that = this; @optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int total, List<NotificationItemDto> items, int page, int pages)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) { switch (_that) {
case _AlertsResponseDto() when $default != null: case _AlertsResponseDto() when $default != null:
return $default(_that.total,_that.items,_that.page,_that.pages);case _: return $default(_that.total,_that.items,_that.page,_that.pages);case _:
@@ -177,7 +184,7 @@ return $default(_that.total,_that.items,_that.page,_that.pages);case _:
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int total, List<AlertItemDto> items, int page, int pages) $default,) {final _that = this; @optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int total, List<NotificationItemDto> items, int page, int pages) $default,) {final _that = this;
switch (_that) { switch (_that) {
case _AlertsResponseDto(): case _AlertsResponseDto():
return $default(_that.total,_that.items,_that.page,_that.pages);case _: return $default(_that.total,_that.items,_that.page,_that.pages);case _:
@@ -197,7 +204,7 @@ return $default(_that.total,_that.items,_that.page,_that.pages);case _:
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int total, List<AlertItemDto> items, int page, int pages)? $default,) {final _that = this; @optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int total, List<NotificationItemDto> items, int page, int pages)? $default,) {final _that = this;
switch (_that) { switch (_that) {
case _AlertsResponseDto() when $default != null: case _AlertsResponseDto() when $default != null:
return $default(_that.total,_that.items,_that.page,_that.pages);case _: return $default(_that.total,_that.items,_that.page,_that.pages);case _:
@@ -211,13 +218,13 @@ return $default(_that.total,_that.items,_that.page,_that.pages);case _:
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _AlertsResponseDto implements AlertsResponseDto { class _AlertsResponseDto implements NotificationsResponseDto {
const _AlertsResponseDto({this.total = 0, final List<AlertItemDto> items = const [], this.page = 1, this.pages = 1}): _items = items; const _AlertsResponseDto({this.total = 0, final List<NotificationItemDto> items = const [], this.page = 1, this.pages = 1}): _items = items;
factory _AlertsResponseDto.fromJson(Map<String, dynamic> json) => _$AlertsResponseDtoFromJson(json); factory _AlertsResponseDto.fromJson(Map<String, dynamic> json) => _$AlertsResponseDtoFromJson(json);
@override@JsonKey() final int total; @override@JsonKey() final int total;
final List<AlertItemDto> _items; final List<NotificationItemDto> _items;
@override@JsonKey() List<AlertItemDto> get items { @override@JsonKey() List<NotificationItemDto> get items {
if (_items is EqualUnmodifiableListView) return _items; if (_items is EqualUnmodifiableListView) return _items;
// ignore: implicit_dynamic_type // ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_items); return EqualUnmodifiableListView(_items);
@@ -226,7 +233,7 @@ class _AlertsResponseDto implements AlertsResponseDto {
@override@JsonKey() final int page; @override@JsonKey() final int page;
@override@JsonKey() final int pages; @override@JsonKey() final int pages;
/// Create a copy of AlertsResponseDto /// Create a copy of NotificationsResponseDto
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false) @override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@@ -248,18 +255,18 @@ int get hashCode => Object.hash(runtimeType,total,const DeepCollectionEquality()
@override @override
String toString() { String toString() {
return 'AlertsResponseDto(total: $total, items: $items, page: $page, pages: $pages)'; return 'NotificationsResponseDto(total: $total, items: $items, page: $page, pages: $pages)';
} }
} }
/// @nodoc /// @nodoc
abstract mixin class _$AlertsResponseDtoCopyWith<$Res> implements $AlertsResponseDtoCopyWith<$Res> { abstract mixin class _$AlertsResponseDtoCopyWith<$Res> implements $NotificationsResponseDtoCopyWith<$Res> {
factory _$AlertsResponseDtoCopyWith(_AlertsResponseDto value, $Res Function(_AlertsResponseDto) _then) = __$AlertsResponseDtoCopyWithImpl; factory _$AlertsResponseDtoCopyWith(_AlertsResponseDto value, $Res Function(_AlertsResponseDto) _then) = __$AlertsResponseDtoCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $Res call({
int total, List<AlertItemDto> items, int page, int pages int total, List<NotificationItemDto> items, int page, int pages
}); });
@@ -274,13 +281,13 @@ class __$AlertsResponseDtoCopyWithImpl<$Res>
final _AlertsResponseDto _self; final _AlertsResponseDto _self;
final $Res Function(_AlertsResponseDto) _then; final $Res Function(_AlertsResponseDto) _then;
/// Create a copy of AlertsResponseDto /// Create a copy of NotificationsResponseDto
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? total = null,Object? items = null,Object? page = null,Object? pages = null,}) { @override @pragma('vm:prefer-inline') $Res call({Object? total = null,Object? items = null,Object? page = null,Object? pages = null,}) {
return _then(_AlertsResponseDto( return _then(_AlertsResponseDto(
total: null == total ? _self.total : total // ignore: cast_nullable_to_non_nullable total: null == total ? _self.total : total // ignore: cast_nullable_to_non_nullable
as int,items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable as int,items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable
as List<AlertItemDto>,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable as List<NotificationItemDto>,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable
as int,pages: null == pages ? _self.pages : pages // ignore: cast_nullable_to_non_nullable as int,pages: null == pages ? _self.pages : pages // ignore: cast_nullable_to_non_nullable
as int, as int,
)); ));
@@ -289,24 +296,31 @@ as int,
} }
NotificationItemDto _$NotificationItemDtoFromJson(
Map<String, dynamic> json
) {
return _AlertItemDto.fromJson(
json
);
}
/// @nodoc /// @nodoc
mixin _$AlertItemDto { mixin _$NotificationItemDto {
String get id; String get deviceIdentificator; String get deviceName; String get type; AlertGeofenceDto? get geofenceAlert; String? get delegationId; String? get userId; int get createdAt; String get id; String get deviceIdentificator; String get deviceName; String get type; NotificationGeofenceDto? get geofenceAlert; String? get delegationId; String? get userId; int get createdAt;
/// Create a copy of AlertItemDto /// Create a copy of NotificationItemDto
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$AlertItemDtoCopyWith<AlertItemDto> get copyWith => _$AlertItemDtoCopyWithImpl<AlertItemDto>(this as AlertItemDto, _$identity); $NotificationItemDtoCopyWith<NotificationItemDto> get copyWith => _$NotificationItemDtoCopyWithImpl<NotificationItemDto>(this as NotificationItemDto, _$identity);
/// Serializes this AlertItemDto to a JSON map. /// Serializes this NotificationItemDto to a JSON map.
Map<String, dynamic> toJson(); Map<String, dynamic> toJson();
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is AlertItemDto&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.type, type) || other.type == type)&&(identical(other.geofenceAlert, geofenceAlert) || other.geofenceAlert == geofenceAlert)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)); return identical(this, other) || (other.runtimeType == runtimeType&&other is NotificationItemDto&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.type, type) || other.type == type)&&(identical(other.geofenceAlert, geofenceAlert) || other.geofenceAlert == geofenceAlert)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
} }
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@@ -315,33 +329,33 @@ int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,deviceName,ty
@override @override
String toString() { String toString() {
return 'AlertItemDto(id: $id, deviceIdentificator: $deviceIdentificator, deviceName: $deviceName, type: $type, geofenceAlert: $geofenceAlert, delegationId: $delegationId, userId: $userId, createdAt: $createdAt)'; return 'NotificationItemDto(id: $id, deviceIdentificator: $deviceIdentificator, deviceName: $deviceName, type: $type, geofenceAlert: $geofenceAlert, delegationId: $delegationId, userId: $userId, createdAt: $createdAt)';
} }
} }
/// @nodoc /// @nodoc
abstract mixin class $AlertItemDtoCopyWith<$Res> { abstract mixin class $NotificationItemDtoCopyWith<$Res> {
factory $AlertItemDtoCopyWith(AlertItemDto value, $Res Function(AlertItemDto) _then) = _$AlertItemDtoCopyWithImpl; factory $NotificationItemDtoCopyWith(NotificationItemDto value, $Res Function(NotificationItemDto) _then) = _$NotificationItemDtoCopyWithImpl;
@useResult @useResult
$Res call({ $Res call({
String id, String deviceIdentificator, String deviceName, String type, AlertGeofenceDto? geofenceAlert, String? delegationId, String? userId, int createdAt String id, String deviceIdentificator, String deviceName, String type, NotificationGeofenceDto? geofenceAlert, String? delegationId, String? userId, int createdAt
}); });
$AlertGeofenceDtoCopyWith<$Res>? get geofenceAlert; $NotificationGeofenceDtoCopyWith<$Res>? get geofenceAlert;
} }
/// @nodoc /// @nodoc
class _$AlertItemDtoCopyWithImpl<$Res> class _$NotificationItemDtoCopyWithImpl<$Res>
implements $AlertItemDtoCopyWith<$Res> { implements $NotificationItemDtoCopyWith<$Res> {
_$AlertItemDtoCopyWithImpl(this._self, this._then); _$NotificationItemDtoCopyWithImpl(this._self, this._then);
final AlertItemDto _self; final NotificationItemDto _self;
final $Res Function(AlertItemDto) _then; final $Res Function(NotificationItemDto) _then;
/// Create a copy of AlertItemDto /// Create a copy of NotificationItemDto
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceIdentificator = null,Object? deviceName = null,Object? type = null,Object? geofenceAlert = freezed,Object? delegationId = freezed,Object? userId = freezed,Object? createdAt = null,}) { @pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceIdentificator = null,Object? deviceName = null,Object? type = null,Object? geofenceAlert = freezed,Object? delegationId = freezed,Object? userId = freezed,Object? createdAt = null,}) {
return _then(_self.copyWith( return _then(_self.copyWith(
@@ -350,30 +364,30 @@ as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentif
as String,deviceName: null == deviceName ? _self.deviceName : deviceName // ignore: cast_nullable_to_non_nullable as String,deviceName: null == deviceName ? _self.deviceName : deviceName // ignore: cast_nullable_to_non_nullable
as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String,geofenceAlert: freezed == geofenceAlert ? _self.geofenceAlert : geofenceAlert // ignore: cast_nullable_to_non_nullable as String,geofenceAlert: freezed == geofenceAlert ? _self.geofenceAlert : geofenceAlert // ignore: cast_nullable_to_non_nullable
as AlertGeofenceDto?,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable as NotificationGeofenceDto?,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
as String?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable as String?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
as String?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as String?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int, as int,
)); ));
} }
/// Create a copy of AlertItemDto /// Create a copy of NotificationItemDto
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$AlertGeofenceDtoCopyWith<$Res>? get geofenceAlert { $NotificationGeofenceDtoCopyWith<$Res>? get geofenceAlert {
if (_self.geofenceAlert == null) { if (_self.geofenceAlert == null) {
return null; return null;
} }
return $AlertGeofenceDtoCopyWith<$Res>(_self.geofenceAlert!, (value) { return $NotificationGeofenceDtoCopyWith<$Res>(_self.geofenceAlert!, (value) {
return _then(_self.copyWith(geofenceAlert: value)); return _then(_self.copyWith(geofenceAlert: value));
}); });
} }
} }
/// Adds pattern-matching-related methods to [AlertItemDto]. /// Adds pattern-matching-related methods to [NotificationItemDto].
extension AlertItemDtoPatterns on AlertItemDto { extension NotificationItemDtoPatterns on NotificationItemDto {
/// A variant of `map` that fallback to returning `orElse`. /// A variant of `map` that fallback to returning `orElse`.
/// ///
/// It is equivalent to doing: /// It is equivalent to doing:
@@ -450,7 +464,7 @@ return $default(_that);case _:
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String deviceName, String type, AlertGeofenceDto? geofenceAlert, String? delegationId, String? userId, int createdAt)? $default,{required TResult orElse(),}) {final _that = this; @optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String deviceName, String type, NotificationGeofenceDto? geofenceAlert, String? delegationId, String? userId, int createdAt)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) { switch (_that) {
case _AlertItemDto() when $default != null: case _AlertItemDto() when $default != null:
return $default(_that.id,_that.deviceIdentificator,_that.deviceName,_that.type,_that.geofenceAlert,_that.delegationId,_that.userId,_that.createdAt);case _: return $default(_that.id,_that.deviceIdentificator,_that.deviceName,_that.type,_that.geofenceAlert,_that.delegationId,_that.userId,_that.createdAt);case _:
@@ -471,7 +485,7 @@ return $default(_that.id,_that.deviceIdentificator,_that.deviceName,_that.type,_
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String deviceName, String type, AlertGeofenceDto? geofenceAlert, String? delegationId, String? userId, int createdAt) $default,) {final _that = this; @optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String deviceName, String type, NotificationGeofenceDto? geofenceAlert, String? delegationId, String? userId, int createdAt) $default,) {final _that = this;
switch (_that) { switch (_that) {
case _AlertItemDto(): case _AlertItemDto():
return $default(_that.id,_that.deviceIdentificator,_that.deviceName,_that.type,_that.geofenceAlert,_that.delegationId,_that.userId,_that.createdAt);case _: return $default(_that.id,_that.deviceIdentificator,_that.deviceName,_that.type,_that.geofenceAlert,_that.delegationId,_that.userId,_that.createdAt);case _:
@@ -491,7 +505,7 @@ return $default(_that.id,_that.deviceIdentificator,_that.deviceName,_that.type,_
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceIdentificator, String deviceName, String type, AlertGeofenceDto? geofenceAlert, String? delegationId, String? userId, int createdAt)? $default,) {final _that = this; @optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceIdentificator, String deviceName, String type, NotificationGeofenceDto? geofenceAlert, String? delegationId, String? userId, int createdAt)? $default,) {final _that = this;
switch (_that) { switch (_that) {
case _AlertItemDto() when $default != null: case _AlertItemDto() when $default != null:
return $default(_that.id,_that.deviceIdentificator,_that.deviceName,_that.type,_that.geofenceAlert,_that.delegationId,_that.userId,_that.createdAt);case _: return $default(_that.id,_that.deviceIdentificator,_that.deviceName,_that.type,_that.geofenceAlert,_that.delegationId,_that.userId,_that.createdAt);case _:
@@ -505,7 +519,7 @@ return $default(_that.id,_that.deviceIdentificator,_that.deviceName,_that.type,_
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _AlertItemDto implements AlertItemDto { class _AlertItemDto implements NotificationItemDto {
const _AlertItemDto({required this.id, this.deviceIdentificator = '', this.deviceName = '', this.type = '', this.geofenceAlert, this.delegationId, this.userId, this.createdAt = 0}); const _AlertItemDto({required this.id, this.deviceIdentificator = '', this.deviceName = '', this.type = '', this.geofenceAlert, this.delegationId, this.userId, this.createdAt = 0});
factory _AlertItemDto.fromJson(Map<String, dynamic> json) => _$AlertItemDtoFromJson(json); factory _AlertItemDto.fromJson(Map<String, dynamic> json) => _$AlertItemDtoFromJson(json);
@@ -513,12 +527,12 @@ class _AlertItemDto implements AlertItemDto {
@override@JsonKey() final String deviceIdentificator; @override@JsonKey() final String deviceIdentificator;
@override@JsonKey() final String deviceName; @override@JsonKey() final String deviceName;
@override@JsonKey() final String type; @override@JsonKey() final String type;
@override final AlertGeofenceDto? geofenceAlert; @override final NotificationGeofenceDto? geofenceAlert;
@override final String? delegationId; @override final String? delegationId;
@override final String? userId; @override final String? userId;
@override@JsonKey() final int createdAt; @override@JsonKey() final int createdAt;
/// Create a copy of AlertItemDto /// Create a copy of NotificationItemDto
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false) @override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@@ -540,22 +554,22 @@ int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,deviceName,ty
@override @override
String toString() { String toString() {
return 'AlertItemDto(id: $id, deviceIdentificator: $deviceIdentificator, deviceName: $deviceName, type: $type, geofenceAlert: $geofenceAlert, delegationId: $delegationId, userId: $userId, createdAt: $createdAt)'; return 'NotificationItemDto(id: $id, deviceIdentificator: $deviceIdentificator, deviceName: $deviceName, type: $type, geofenceAlert: $geofenceAlert, delegationId: $delegationId, userId: $userId, createdAt: $createdAt)';
} }
} }
/// @nodoc /// @nodoc
abstract mixin class _$AlertItemDtoCopyWith<$Res> implements $AlertItemDtoCopyWith<$Res> { abstract mixin class _$AlertItemDtoCopyWith<$Res> implements $NotificationItemDtoCopyWith<$Res> {
factory _$AlertItemDtoCopyWith(_AlertItemDto value, $Res Function(_AlertItemDto) _then) = __$AlertItemDtoCopyWithImpl; factory _$AlertItemDtoCopyWith(_AlertItemDto value, $Res Function(_AlertItemDto) _then) = __$AlertItemDtoCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $Res call({
String id, String deviceIdentificator, String deviceName, String type, AlertGeofenceDto? geofenceAlert, String? delegationId, String? userId, int createdAt String id, String deviceIdentificator, String deviceName, String type, NotificationGeofenceDto? geofenceAlert, String? delegationId, String? userId, int createdAt
}); });
@override $AlertGeofenceDtoCopyWith<$Res>? get geofenceAlert; @override $NotificationGeofenceDtoCopyWith<$Res>? get geofenceAlert;
} }
/// @nodoc /// @nodoc
@@ -566,7 +580,7 @@ class __$AlertItemDtoCopyWithImpl<$Res>
final _AlertItemDto _self; final _AlertItemDto _self;
final $Res Function(_AlertItemDto) _then; final $Res Function(_AlertItemDto) _then;
/// Create a copy of AlertItemDto /// Create a copy of NotificationItemDto
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceIdentificator = null,Object? deviceName = null,Object? type = null,Object? geofenceAlert = freezed,Object? delegationId = freezed,Object? userId = freezed,Object? createdAt = null,}) { @override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceIdentificator = null,Object? deviceName = null,Object? type = null,Object? geofenceAlert = freezed,Object? delegationId = freezed,Object? userId = freezed,Object? createdAt = null,}) {
return _then(_AlertItemDto( return _then(_AlertItemDto(
@@ -575,46 +589,53 @@ as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentif
as String,deviceName: null == deviceName ? _self.deviceName : deviceName // ignore: cast_nullable_to_non_nullable as String,deviceName: null == deviceName ? _self.deviceName : deviceName // ignore: cast_nullable_to_non_nullable
as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String,geofenceAlert: freezed == geofenceAlert ? _self.geofenceAlert : geofenceAlert // ignore: cast_nullable_to_non_nullable as String,geofenceAlert: freezed == geofenceAlert ? _self.geofenceAlert : geofenceAlert // ignore: cast_nullable_to_non_nullable
as AlertGeofenceDto?,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable as NotificationGeofenceDto?,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
as String?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable as String?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
as String?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable as String?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int, as int,
)); ));
} }
/// Create a copy of AlertItemDto /// Create a copy of NotificationItemDto
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$AlertGeofenceDtoCopyWith<$Res>? get geofenceAlert { $NotificationGeofenceDtoCopyWith<$Res>? get geofenceAlert {
if (_self.geofenceAlert == null) { if (_self.geofenceAlert == null) {
return null; return null;
} }
return $AlertGeofenceDtoCopyWith<$Res>(_self.geofenceAlert!, (value) { return $NotificationGeofenceDtoCopyWith<$Res>(_self.geofenceAlert!, (value) {
return _then(_self.copyWith(geofenceAlert: value)); return _then(_self.copyWith(geofenceAlert: value));
}); });
} }
} }
NotificationGeofenceDto _$NotificationGeofenceDtoFromJson(
Map<String, dynamic> json
) {
return _AlertGeofenceDto.fromJson(
json
);
}
/// @nodoc /// @nodoc
mixin _$AlertGeofenceDto { mixin _$NotificationGeofenceDto {
String get id; String get name; String get id; String get name;
/// Create a copy of AlertGeofenceDto /// Create a copy of NotificationGeofenceDto
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$AlertGeofenceDtoCopyWith<AlertGeofenceDto> get copyWith => _$AlertGeofenceDtoCopyWithImpl<AlertGeofenceDto>(this as AlertGeofenceDto, _$identity); $NotificationGeofenceDtoCopyWith<NotificationGeofenceDto> get copyWith => _$NotificationGeofenceDtoCopyWithImpl<NotificationGeofenceDto>(this as NotificationGeofenceDto, _$identity);
/// Serializes this AlertGeofenceDto to a JSON map. /// Serializes this NotificationGeofenceDto to a JSON map.
Map<String, dynamic> toJson(); Map<String, dynamic> toJson();
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is AlertGeofenceDto&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)); return identical(this, other) || (other.runtimeType == runtimeType&&other is NotificationGeofenceDto&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name));
} }
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@@ -623,15 +644,15 @@ int get hashCode => Object.hash(runtimeType,id,name);
@override @override
String toString() { String toString() {
return 'AlertGeofenceDto(id: $id, name: $name)'; return 'NotificationGeofenceDto(id: $id, name: $name)';
} }
} }
/// @nodoc /// @nodoc
abstract mixin class $AlertGeofenceDtoCopyWith<$Res> { abstract mixin class $NotificationGeofenceDtoCopyWith<$Res> {
factory $AlertGeofenceDtoCopyWith(AlertGeofenceDto value, $Res Function(AlertGeofenceDto) _then) = _$AlertGeofenceDtoCopyWithImpl; factory $NotificationGeofenceDtoCopyWith(NotificationGeofenceDto value, $Res Function(NotificationGeofenceDto) _then) = _$NotificationGeofenceDtoCopyWithImpl;
@useResult @useResult
$Res call({ $Res call({
String id, String name String id, String name
@@ -642,14 +663,14 @@ $Res call({
} }
/// @nodoc /// @nodoc
class _$AlertGeofenceDtoCopyWithImpl<$Res> class _$NotificationGeofenceDtoCopyWithImpl<$Res>
implements $AlertGeofenceDtoCopyWith<$Res> { implements $NotificationGeofenceDtoCopyWith<$Res> {
_$AlertGeofenceDtoCopyWithImpl(this._self, this._then); _$NotificationGeofenceDtoCopyWithImpl(this._self, this._then);
final AlertGeofenceDto _self; final NotificationGeofenceDto _self;
final $Res Function(AlertGeofenceDto) _then; final $Res Function(NotificationGeofenceDto) _then;
/// Create a copy of AlertGeofenceDto /// Create a copy of NotificationGeofenceDto
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? name = null,}) { @pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? name = null,}) {
return _then(_self.copyWith( return _then(_self.copyWith(
@@ -662,8 +683,8 @@ as String,
} }
/// Adds pattern-matching-related methods to [AlertGeofenceDto]. /// Adds pattern-matching-related methods to [NotificationGeofenceDto].
extension AlertGeofenceDtoPatterns on AlertGeofenceDto { extension NotificationGeofenceDtoPatterns on NotificationGeofenceDto {
/// A variant of `map` that fallback to returning `orElse`. /// A variant of `map` that fallback to returning `orElse`.
/// ///
/// It is equivalent to doing: /// It is equivalent to doing:
@@ -795,14 +816,14 @@ return $default(_that.id,_that.name);case _:
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _AlertGeofenceDto implements AlertGeofenceDto { class _AlertGeofenceDto implements NotificationGeofenceDto {
const _AlertGeofenceDto({required this.id, required this.name}); const _AlertGeofenceDto({required this.id, required this.name});
factory _AlertGeofenceDto.fromJson(Map<String, dynamic> json) => _$AlertGeofenceDtoFromJson(json); factory _AlertGeofenceDto.fromJson(Map<String, dynamic> json) => _$AlertGeofenceDtoFromJson(json);
@override final String id; @override final String id;
@override final String name; @override final String name;
/// Create a copy of AlertGeofenceDto /// Create a copy of NotificationGeofenceDto
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false) @override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@@ -824,14 +845,14 @@ int get hashCode => Object.hash(runtimeType,id,name);
@override @override
String toString() { String toString() {
return 'AlertGeofenceDto(id: $id, name: $name)'; return 'NotificationGeofenceDto(id: $id, name: $name)';
} }
} }
/// @nodoc /// @nodoc
abstract mixin class _$AlertGeofenceDtoCopyWith<$Res> implements $AlertGeofenceDtoCopyWith<$Res> { abstract mixin class _$AlertGeofenceDtoCopyWith<$Res> implements $NotificationGeofenceDtoCopyWith<$Res> {
factory _$AlertGeofenceDtoCopyWith(_AlertGeofenceDto value, $Res Function(_AlertGeofenceDto) _then) = __$AlertGeofenceDtoCopyWithImpl; factory _$AlertGeofenceDtoCopyWith(_AlertGeofenceDto value, $Res Function(_AlertGeofenceDto) _then) = __$AlertGeofenceDtoCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $Res call({
@@ -850,7 +871,7 @@ class __$AlertGeofenceDtoCopyWithImpl<$Res>
final _AlertGeofenceDto _self; final _AlertGeofenceDto _self;
final $Res Function(_AlertGeofenceDto) _then; final $Res Function(_AlertGeofenceDto) _then;
/// Create a copy of AlertGeofenceDto /// Create a copy of NotificationGeofenceDto
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? name = null,}) { @override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? name = null,}) {
return _then(_AlertGeofenceDto( return _then(_AlertGeofenceDto(

View File

@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND // GENERATED CODE - DO NOT MODIFY BY HAND
part of 'alerts_response_dto.dart'; part of 'notifications_response_dto.dart';
// ************************************************************************** // **************************************************************************
// JsonSerializableGenerator // JsonSerializableGenerator
@@ -11,7 +11,9 @@ _AlertsResponseDto _$AlertsResponseDtoFromJson(Map<String, dynamic> json) =>
total: (json['total'] as num?)?.toInt() ?? 0, total: (json['total'] as num?)?.toInt() ?? 0,
items: items:
(json['items'] as List<dynamic>?) (json['items'] as List<dynamic>?)
?.map((e) => AlertItemDto.fromJson(e as Map<String, dynamic>)) ?.map(
(e) => NotificationItemDto.fromJson(e as Map<String, dynamic>),
)
.toList() ?? .toList() ??
const [], const [],
page: (json['page'] as num?)?.toInt() ?? 1, page: (json['page'] as num?)?.toInt() ?? 1,
@@ -34,7 +36,7 @@ _AlertItemDto _$AlertItemDtoFromJson(Map<String, dynamic> json) =>
type: json['type'] as String? ?? '', type: json['type'] as String? ?? '',
geofenceAlert: json['geofenceAlert'] == null geofenceAlert: json['geofenceAlert'] == null
? null ? null
: AlertGeofenceDto.fromJson( : NotificationGeofenceDto.fromJson(
json['geofenceAlert'] as Map<String, dynamic>, json['geofenceAlert'] as Map<String, dynamic>,
), ),
delegationId: json['delegationId'] as String?, delegationId: json['delegationId'] as String?,

View File

@@ -1,30 +0,0 @@
import 'package:dio/dio.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import '../../domain/entities/alert_entity.dart';
import '../../domain/repositories/alerts_repository.dart';
import '../datasource/alerts_remote_datasource.dart';
class AlertsRepositoryImpl implements AlertsRepository {
AlertsRepositoryImpl(this._datasource);
final AlertsRemoteDatasource _datasource;
@override
Future<(List<AlertEntity>, int totalPages)> getAlerts({
required int page,
int pageSize = 20,
String? type,
}) async {
try {
return await _datasource.getAlerts(
page: page,
pageSize: pageSize,
type: type,
);
} on DioException catch (error) {
if (error.response?.statusCode == 404) return (<AlertEntity>[], 1);
throw mapDioError(error, defaultMessage: 'Error getting alerts');
}
}
}

View File

@@ -0,0 +1,30 @@
import 'package:dio/dio.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import '../../domain/entities/notification_entity.dart';
import '../../domain/repositories/notifications_repository.dart';
import '../datasource/notifications_remote_datasource.dart';
class NotificationsRepositoryImpl implements NotificationsRepository {
NotificationsRepositoryImpl(this._datasource);
final NotificationsRemoteDatasource _datasource;
@override
Future<(List<NotificationEntity>, int totalPages)> getNotifications({
required int page,
int pageSize = 20,
String? type,
}) async {
try {
return await _datasource.getNotifications(
page: page,
pageSize: pageSize,
type: type,
);
} on DioException catch (error) {
if (error.response?.statusCode == 404) return (<NotificationEntity>[], 1);
throw mapDioError(error, defaultMessage: 'Error getting alerts');
}
}
}

View File

@@ -1,10 +1,10 @@
import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:freezed_annotation/freezed_annotation.dart';
part 'alert_entity.freezed.dart'; part 'notification_entity.freezed.dart';
@freezed @freezed
abstract class AlertEntity with _$AlertEntity { abstract class NotificationEntity with _$NotificationEntity {
const factory AlertEntity({ const factory NotificationEntity({
required String id, required String id,
required String deviceIdentificator, required String deviceIdentificator,
required String deviceName, required String deviceName,

View File

@@ -3,7 +3,7 @@
// ignore_for_file: type=lint // ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'alert_entity.dart'; part of 'notification_entity.dart';
// ************************************************************************** // **************************************************************************
// FreezedGenerator // FreezedGenerator
@@ -12,20 +12,20 @@ part of 'alert_entity.dart';
// dart format off // dart format off
T _$identity<T>(T value) => value; T _$identity<T>(T value) => value;
/// @nodoc /// @nodoc
mixin _$AlertEntity { mixin _$NotificationEntity {
String get id; String get deviceIdentificator; String get deviceName; String get type; GeofenceAlertEntity? get geofenceAlert; String? get delegationId; String? get userId; int get createdAt; String get id; String get deviceIdentificator; String get deviceName; String get type; GeofenceAlertEntity? get geofenceAlert; String? get delegationId; String? get userId; int get createdAt;
/// Create a copy of AlertEntity /// Create a copy of NotificationEntity
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$AlertEntityCopyWith<AlertEntity> get copyWith => _$AlertEntityCopyWithImpl<AlertEntity>(this as AlertEntity, _$identity); $NotificationEntityCopyWith<NotificationEntity> get copyWith => _$NotificationEntityCopyWithImpl<NotificationEntity>(this as NotificationEntity, _$identity);
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is AlertEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.type, type) || other.type == type)&&(identical(other.geofenceAlert, geofenceAlert) || other.geofenceAlert == geofenceAlert)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)); return identical(this, other) || (other.runtimeType == runtimeType&&other is NotificationEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.type, type) || other.type == type)&&(identical(other.geofenceAlert, geofenceAlert) || other.geofenceAlert == geofenceAlert)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
} }
@@ -34,15 +34,15 @@ int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,deviceName,ty
@override @override
String toString() { String toString() {
return 'AlertEntity(id: $id, deviceIdentificator: $deviceIdentificator, deviceName: $deviceName, type: $type, geofenceAlert: $geofenceAlert, delegationId: $delegationId, userId: $userId, createdAt: $createdAt)'; return 'NotificationEntity(id: $id, deviceIdentificator: $deviceIdentificator, deviceName: $deviceName, type: $type, geofenceAlert: $geofenceAlert, delegationId: $delegationId, userId: $userId, createdAt: $createdAt)';
} }
} }
/// @nodoc /// @nodoc
abstract mixin class $AlertEntityCopyWith<$Res> { abstract mixin class $NotificationEntityCopyWith<$Res> {
factory $AlertEntityCopyWith(AlertEntity value, $Res Function(AlertEntity) _then) = _$AlertEntityCopyWithImpl; factory $NotificationEntityCopyWith(NotificationEntity value, $Res Function(NotificationEntity) _then) = _$NotificationEntityCopyWithImpl;
@useResult @useResult
$Res call({ $Res call({
String id, String deviceIdentificator, String deviceName, String type, GeofenceAlertEntity? geofenceAlert, String? delegationId, String? userId, int createdAt String id, String deviceIdentificator, String deviceName, String type, GeofenceAlertEntity? geofenceAlert, String? delegationId, String? userId, int createdAt
@@ -53,14 +53,14 @@ $GeofenceAlertEntityCopyWith<$Res>? get geofenceAlert;
} }
/// @nodoc /// @nodoc
class _$AlertEntityCopyWithImpl<$Res> class _$NotificationEntityCopyWithImpl<$Res>
implements $AlertEntityCopyWith<$Res> { implements $NotificationEntityCopyWith<$Res> {
_$AlertEntityCopyWithImpl(this._self, this._then); _$NotificationEntityCopyWithImpl(this._self, this._then);
final AlertEntity _self; final NotificationEntity _self;
final $Res Function(AlertEntity) _then; final $Res Function(NotificationEntity) _then;
/// Create a copy of AlertEntity /// Create a copy of NotificationEntity
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceIdentificator = null,Object? deviceName = null,Object? type = null,Object? geofenceAlert = freezed,Object? delegationId = freezed,Object? userId = freezed,Object? createdAt = null,}) { @pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceIdentificator = null,Object? deviceName = null,Object? type = null,Object? geofenceAlert = freezed,Object? delegationId = freezed,Object? userId = freezed,Object? createdAt = null,}) {
return _then(_self.copyWith( return _then(_self.copyWith(
@@ -75,7 +75,7 @@ as String?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore:
as int, as int,
)); ));
} }
/// Create a copy of AlertEntity /// Create a copy of NotificationEntity
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@@ -91,8 +91,8 @@ $GeofenceAlertEntityCopyWith<$Res>? get geofenceAlert {
} }
/// Adds pattern-matching-related methods to [AlertEntity]. /// Adds pattern-matching-related methods to [NotificationEntity].
extension AlertEntityPatterns on AlertEntity { extension NotificationEntityPatterns on NotificationEntity {
/// A variant of `map` that fallback to returning `orElse`. /// A variant of `map` that fallback to returning `orElse`.
/// ///
/// It is equivalent to doing: /// It is equivalent to doing:
@@ -224,7 +224,7 @@ return $default(_that.id,_that.deviceIdentificator,_that.deviceName,_that.type,_
/// @nodoc /// @nodoc
class _AlertEntity implements AlertEntity { class _AlertEntity implements NotificationEntity {
const _AlertEntity({required this.id, required this.deviceIdentificator, required this.deviceName, required this.type, this.geofenceAlert, this.delegationId, this.userId, required this.createdAt}); const _AlertEntity({required this.id, required this.deviceIdentificator, required this.deviceName, required this.type, this.geofenceAlert, this.delegationId, this.userId, required this.createdAt});
@@ -237,7 +237,7 @@ class _AlertEntity implements AlertEntity {
@override final String? userId; @override final String? userId;
@override final int createdAt; @override final int createdAt;
/// Create a copy of AlertEntity /// Create a copy of NotificationEntity
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false) @override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
@@ -256,14 +256,14 @@ int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,deviceName,ty
@override @override
String toString() { String toString() {
return 'AlertEntity(id: $id, deviceIdentificator: $deviceIdentificator, deviceName: $deviceName, type: $type, geofenceAlert: $geofenceAlert, delegationId: $delegationId, userId: $userId, createdAt: $createdAt)'; return 'NotificationEntity(id: $id, deviceIdentificator: $deviceIdentificator, deviceName: $deviceName, type: $type, geofenceAlert: $geofenceAlert, delegationId: $delegationId, userId: $userId, createdAt: $createdAt)';
} }
} }
/// @nodoc /// @nodoc
abstract mixin class _$AlertEntityCopyWith<$Res> implements $AlertEntityCopyWith<$Res> { abstract mixin class _$AlertEntityCopyWith<$Res> implements $NotificationEntityCopyWith<$Res> {
factory _$AlertEntityCopyWith(_AlertEntity value, $Res Function(_AlertEntity) _then) = __$AlertEntityCopyWithImpl; factory _$AlertEntityCopyWith(_AlertEntity value, $Res Function(_AlertEntity) _then) = __$AlertEntityCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $Res call({
@@ -282,7 +282,7 @@ class __$AlertEntityCopyWithImpl<$Res>
final _AlertEntity _self; final _AlertEntity _self;
final $Res Function(_AlertEntity) _then; final $Res Function(_AlertEntity) _then;
/// Create a copy of AlertEntity /// Create a copy of NotificationEntity
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceIdentificator = null,Object? deviceName = null,Object? type = null,Object? geofenceAlert = freezed,Object? delegationId = freezed,Object? userId = freezed,Object? createdAt = null,}) { @override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceIdentificator = null,Object? deviceName = null,Object? type = null,Object? geofenceAlert = freezed,Object? delegationId = freezed,Object? userId = freezed,Object? createdAt = null,}) {
return _then(_AlertEntity( return _then(_AlertEntity(
@@ -298,7 +298,7 @@ as int,
)); ));
} }
/// Create a copy of AlertEntity /// Create a copy of NotificationEntity
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')

View File

@@ -1,9 +0,0 @@
import '../entities/alert_entity.dart';
abstract class AlertsRepository {
Future<(List<AlertEntity>, int totalPages)> getAlerts({
required int page,
int pageSize,
String? type,
});
}

View File

@@ -0,0 +1,9 @@
import '../entities/notification_entity.dart';
abstract class NotificationsRepository {
Future<(List<NotificationEntity>, int totalPages)> getNotifications({
required int page,
int pageSize,
String? type,
});
}

View File

@@ -1,16 +0,0 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:get_it/get_it.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import '../data/datasource/alerts_remote_datasource.dart';
import '../data/datasource/alerts_remote_datasource_impl.dart';
import '../data/repositories/alerts_repository_impl.dart';
import '../domain/repositories/alerts_repository.dart';
final alertsRemoteDatasourceProvider = Provider<AlertsRemoteDatasource>(
(_) => AlertsRemoteDatasourceImpl(GetIt.I<SaveFamilyRepository>()),
);
final alertsRepositoryProvider = Provider<AlertsRepository>(
(ref) => AlertsRepositoryImpl(ref.read(alertsRemoteDatasourceProvider)),
);

View File

@@ -0,0 +1,16 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:get_it/get_it.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import '../data/datasource/notifications_remote_datasource.dart';
import '../data/datasource/notifications_remote_datasource_impl.dart';
import '../data/repositories/notifications_repository_impl.dart';
import '../domain/repositories/notifications_repository.dart';
final notificationsRemoteDatasourceProvider = Provider<NotificationsRemoteDatasource>(
(_) => NotificationsRemoteDatasourceImpl(GetIt.I<SaveFamilyRepository>()),
);
final notificationsRepositoryProvider = Provider<NotificationsRepository>(
(ref) => NotificationsRepositoryImpl(ref.read(notificationsRemoteDatasourceProvider)),
);

View File

@@ -1,4 +1,4 @@
import 'package:settings/src/core/domain/entities/alert_entity.dart'; import 'package:settings/src/core/domain/entities/notification_entity.dart';
import 'package:settings/src/features/notifications/presentation/providers/notifications_feed_provider.dart'; import 'package:settings/src/features/notifications/presentation/providers/notifications_feed_provider.dart';
import 'package:settings/src/features/notifications/presentation/providers/notifications_filter_provider.dart'; import 'package:settings/src/features/notifications/presentation/providers/notifications_filter_provider.dart';
import 'package:settings/src/features/notifications/presentation/widgets/notification_card.dart'; import 'package:settings/src/features/notifications/presentation/widgets/notification_card.dart';
@@ -231,7 +231,7 @@ class _FilteredNotificationsScreen extends ConsumerWidget {
} }
class _NotificationsList extends ConsumerStatefulWidget { class _NotificationsList extends ConsumerStatefulWidget {
final List<AlertEntity> notifications; final List<NotificationEntity> notifications;
final bool isLoadingMore; final bool isLoadingMore;
const _NotificationsList({ const _NotificationsList({

View File

@@ -1,7 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:settings/src/core/domain/entities/alert_entity.dart'; import 'package:settings/src/core/domain/entities/notification_entity.dart';
import 'package:settings/src/core/providers/alerts_repository_provider.dart'; import 'package:settings/src/core/providers/notifications_repository_provider.dart';
import 'package:settings/src/features/notifications/presentation/providers/notifications_filter_provider.dart'; import 'package:settings/src/features/notifications/presentation/providers/notifications_filter_provider.dart';
import 'package:legacy_device_state/legacy_device_state.dart'; import 'package:legacy_device_state/legacy_device_state.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -19,13 +19,13 @@ class NotificationsFeedState {
this.isLoadingMore = false, this.isLoadingMore = false,
}); });
final List<AlertEntity> notifications; final List<NotificationEntity> notifications;
final int currentPage; final int currentPage;
final bool hasMore; final bool hasMore;
final bool isLoadingMore; final bool isLoadingMore;
NotificationsFeedState copyWith({ NotificationsFeedState copyWith({
List<AlertEntity>? notifications, List<NotificationEntity>? notifications,
int? currentPage, int? currentPage,
bool? hasMore, bool? hasMore,
bool? isLoadingMore, bool? isLoadingMore,
@@ -53,8 +53,8 @@ class NotificationsFeed extends _$NotificationsFeed {
ref.onDispose(() => _subscription?.cancel()); ref.onDispose(() => _subscription?.cancel());
final (notifications, totalPages) = await ref final (notifications, totalPages) = await ref
.read(alertsRepositoryProvider) .read(notificationsRepositoryProvider)
.getAlerts(page: 1, pageSize: _pageSize, type: filter); .getNotifications(page: 1, pageSize: _pageSize, type: filter);
return NotificationsFeedState( return NotificationsFeedState(
notifications: notifications, notifications: notifications,
@@ -72,7 +72,7 @@ class NotificationsFeed extends _$NotificationsFeed {
final filter = ref.read(notificationsFilterProvider); final filter = ref.read(notificationsFilterProvider);
if (filter != null && filter != event.type) return; if (filter != null && filter != event.type) return;
final newNotification = AlertEntity( final newNotification = NotificationEntity(
id: '', id: '',
deviceIdentificator: event.deviceIdentificator, deviceIdentificator: event.deviceIdentificator,
deviceName: '', deviceName: '',
@@ -98,8 +98,8 @@ class NotificationsFeed extends _$NotificationsFeed {
final filter = ref.read(notificationsFilterProvider); final filter = ref.read(notificationsFilterProvider);
final nextPage = current.currentPage + 1; final nextPage = current.currentPage + 1;
final (notifications, totalPages) = await ref final (notifications, totalPages) = await ref
.read(alertsRepositoryProvider) .read(notificationsRepositoryProvider)
.getAlerts(page: nextPage, pageSize: _pageSize, type: filter); .getNotifications(page: nextPage, pageSize: _pageSize, type: filter);
state = AsyncData( state = AsyncData(
current.copyWith( current.copyWith(

View File

@@ -33,7 +33,7 @@ final class NotificationsFeedProvider
NotificationsFeed create() => NotificationsFeed(); NotificationsFeed create() => NotificationsFeed();
} }
String _$notificationsFeedHash() => r'bb7878198548338c17db4b9ac51e3f88a24115d6'; String _$notificationsFeedHash() => r'907cd9e444a625ff38206809797a006321e1ed99';
abstract class _$NotificationsFeed abstract class _$NotificationsFeed
extends $AsyncNotifier<NotificationsFeedState> { extends $AsyncNotifier<NotificationsFeedState> {

View File

@@ -4,10 +4,10 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_localizations/sf_localizations.dart'; import 'package:sf_localizations/sf_localizations.dart';
import 'package:utils/utils.dart'; import 'package:utils/utils.dart';
import '../../../../core/domain/entities/alert_entity.dart'; import '../../../../core/domain/entities/notification_entity.dart';
class NotificationCard extends ConsumerWidget { class NotificationCard extends ConsumerWidget {
final AlertEntity notification; final NotificationEntity notification;
const NotificationCard({super.key, required this.notification}); const NotificationCard({super.key, required this.notification});

View File

@@ -1,8 +1,8 @@
import 'dart:async'; import 'dart:async';
import 'package:settings/src/core/domain/entities/alert_entity.dart'; import 'package:settings/src/core/domain/entities/notification_entity.dart';
import 'package:settings/src/core/domain/repositories/alerts_repository.dart'; import 'package:settings/src/core/domain/repositories/notifications_repository.dart';
import 'package:settings/src/core/providers/alerts_repository_provider.dart'; import 'package:settings/src/core/providers/notifications_repository_provider.dart';
import 'package:settings/src/features/notifications/presentation/providers/notifications_feed_provider.dart'; import 'package:settings/src/features/notifications/presentation/providers/notifications_feed_provider.dart';
import 'package:settings/src/features/notifications/presentation/providers/notifications_filter_provider.dart'; import 'package:settings/src/features/notifications/presentation/providers/notifications_filter_provider.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -12,7 +12,7 @@ import 'package:mocktail/mocktail.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart'; import 'package:sf_infrastructure/sf_infrastructure.dart';
import 'package:sf_shared/testing.dart'; import 'package:sf_shared/testing.dart';
class MockAlertsRepository extends Mock implements AlertsRepository {} class MockAlertsRepository extends Mock implements NotificationsRepository {}
class FakeWebSocketService implements WebSocketService { class FakeWebSocketService implements WebSocketService {
final _controller = StreamController<WebSocketEvent>.broadcast(); final _controller = StreamController<WebSocketEvent>.broadcast();
@@ -26,14 +26,14 @@ class FakeWebSocketService implements WebSocketService {
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
} }
final _alert1 = AlertEntity( final _alert1 = NotificationEntity(
id: '1', id: '1',
deviceIdentificator: 'd1', deviceIdentificator: 'd1',
deviceName: 'Watch', deviceName: 'Watch',
type: 'sos', type: 'sos',
createdAt: 1, createdAt: 1,
); );
final _alert2 = AlertEntity( final _alert2 = NotificationEntity(
id: '2', id: '2',
deviceIdentificator: 'd1', deviceIdentificator: 'd1',
deviceName: 'Watch', deviceName: 'Watch',
@@ -43,12 +43,12 @@ final _alert2 = AlertEntity(
void main() { void main() {
ProviderContainer buildContainer({ ProviderContainer buildContainer({
required AlertsRepository repo, required NotificationsRepository repo,
required FakeWebSocketService ws, required FakeWebSocketService ws,
}) { }) {
return makeContainer( return makeContainer(
overrides: [ overrides: [
alertsRepositoryProvider.overrideWithValue(repo), notificationsRepositoryProvider.overrideWithValue(repo),
webSocketServiceProvider.overrideWithValue(ws), webSocketServiceProvider.overrideWithValue(ws),
], ],
); );
@@ -59,7 +59,7 @@ void main() {
final repo = MockAlertsRepository(); final repo = MockAlertsRepository();
final ws = FakeWebSocketService(); final ws = FakeWebSocketService();
when( when(
() => repo.getAlerts( () => repo.getNotifications(
page: any(named: 'page'), page: any(named: 'page'),
pageSize: any(named: 'pageSize'), pageSize: any(named: 'pageSize'),
type: any(named: 'type'), type: any(named: 'type'),
@@ -76,7 +76,7 @@ void main() {
expect(state.notifications, [_alert1, _alert2]); expect(state.notifications, [_alert1, _alert2]);
expect(state.currentPage, 1); expect(state.currentPage, 1);
expect(state.hasMore, isTrue); expect(state.hasMore, isTrue);
verify(() => repo.getAlerts(page: 1, pageSize: 20, type: null)) verify(() => repo.getNotifications(page: 1, pageSize: 20, type: null))
.called(1); .called(1);
}); });
@@ -84,7 +84,7 @@ void main() {
final repo = MockAlertsRepository(); final repo = MockAlertsRepository();
final ws = FakeWebSocketService(); final ws = FakeWebSocketService();
when( when(
() => repo.getAlerts( () => repo.getNotifications(
page: any(named: 'page'), page: any(named: 'page'),
pageSize: any(named: 'pageSize'), pageSize: any(named: 'pageSize'),
type: any(named: 'type'), type: any(named: 'type'),
@@ -100,7 +100,7 @@ void main() {
container.read(notificationsFilterProvider.notifier).select('sos'); container.read(notificationsFilterProvider.notifier).select('sos');
await container.read(notificationsFeedProvider.future); await container.read(notificationsFeedProvider.future);
verify(() => repo.getAlerts(page: 1, pageSize: 20, type: 'sos')) verify(() => repo.getNotifications(page: 1, pageSize: 20, type: 'sos'))
.called(1); .called(1);
}); });
}); });
@@ -110,14 +110,14 @@ void main() {
final repo = MockAlertsRepository(); final repo = MockAlertsRepository();
final ws = FakeWebSocketService(); final ws = FakeWebSocketService();
when( when(
() => repo.getAlerts( () => repo.getNotifications(
page: 1, page: 1,
pageSize: any(named: 'pageSize'), pageSize: any(named: 'pageSize'),
type: any(named: 'type'), type: any(named: 'type'),
), ),
).thenAnswer((_) async => ([_alert1], 2)); ).thenAnswer((_) async => ([_alert1], 2));
when( when(
() => repo.getAlerts( () => repo.getNotifications(
page: 2, page: 2,
pageSize: any(named: 'pageSize'), pageSize: any(named: 'pageSize'),
type: any(named: 'type'), type: any(named: 'type'),
@@ -141,7 +141,7 @@ void main() {
final repo = MockAlertsRepository(); final repo = MockAlertsRepository();
final ws = FakeWebSocketService(); final ws = FakeWebSocketService();
when( when(
() => repo.getAlerts( () => repo.getNotifications(
page: any(named: 'page'), page: any(named: 'page'),
pageSize: any(named: 'pageSize'), pageSize: any(named: 'pageSize'),
type: any(named: 'type'), type: any(named: 'type'),
@@ -155,9 +155,9 @@ void main() {
await container.read(notificationsFeedProvider.future); await container.read(notificationsFeedProvider.future);
await container.read(notificationsFeedProvider.notifier).loadMore(); await container.read(notificationsFeedProvider.notifier).loadMore();
verify(() => repo.getAlerts(page: 1, pageSize: 20, type: null)) verify(() => repo.getNotifications(page: 1, pageSize: 20, type: null))
.called(1); .called(1);
verifyNever(() => repo.getAlerts(page: 2, pageSize: 20, type: null)); verifyNever(() => repo.getNotifications(page: 2, pageSize: 20, type: null));
}); });
}); });
@@ -166,7 +166,7 @@ void main() {
final repo = MockAlertsRepository(); final repo = MockAlertsRepository();
final ws = FakeWebSocketService(); final ws = FakeWebSocketService();
when( when(
() => repo.getAlerts( () => repo.getNotifications(
page: any(named: 'page'), page: any(named: 'page'),
pageSize: any(named: 'pageSize'), pageSize: any(named: 'pageSize'),
type: any(named: 'type'), type: any(named: 'type'),
@@ -195,7 +195,7 @@ void main() {
final repo = MockAlertsRepository(); final repo = MockAlertsRepository();
final ws = FakeWebSocketService(); final ws = FakeWebSocketService();
when( when(
() => repo.getAlerts( () => repo.getNotifications(
page: any(named: 'page'), page: any(named: 'page'),
pageSize: any(named: 'pageSize'), pageSize: any(named: 'pageSize'),
type: any(named: 'type'), type: any(named: 'type'),