linked devices state and models fix

This commit is contained in:
2026-03-11 11:56:39 +01:00
parent b4bb90d357
commit 53cadd8499
59 changed files with 489 additions and 1526 deletions

View File

@@ -5,7 +5,10 @@ export 'src/widgets/layouts/page_layout.dart';
export 'src/components/section_button.dart';
export 'src/components/menu_button.dart';
export 'src/data/models/device_response_model.dart';
export 'src/providers/send_command_use_case_provider.dart';
export 'src/domain/send_command_use_case.dart';
export 'src/data/models/get_devices_response_model.dart';
export 'src/data/models/send_command_request_model.dart';
export 'src/utils/dio_error_mapper.dart';
export 'src/utils/dio_error_mapper.dart';
export 'src/domain/repositories/command_repository.dart';
export 'src/providers/commands_repository_provider.dart';
export 'src/domain/repositories/devices_repository.dart';
export 'src/providers/devices_repository_provider.dart';

View File

@@ -0,0 +1,5 @@
import 'package:sf_shared/sf_shared.dart';
abstract class DevicesRemoteDatasource {
Future<List<DeviceEntity>> getDevices();
}

View File

@@ -0,0 +1,27 @@
import 'package:legacy_shared/legacy_shared.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import 'package:sf_shared/sf_shared.dart';
import 'devices_remote_datasource.dart';
class DevicesRemoteDatasourceImpl implements DevicesRemoteDatasource {
DevicesRemoteDatasourceImpl(this._repository);
final QuestiaRepository _repository;
@override
Future<List<DeviceEntity>> getDevices() async {
final response = await safeCall(
() => _repository.get<Map<String, dynamic>>('/devices'),
'Error getting devices',
);
final data = response.data;
if (data == null || data.isEmpty) {
throw Exception('Empty response from /devices');
}
final model = GetDevicesResponseModel.fromJson(data);
return model.toEntity();
}
}

View File

@@ -0,0 +1,67 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:sf_shared/sf_shared.dart';
part 'get_devices_response_model.freezed.dart';
part 'get_devices_response_model.g.dart';
@freezed
abstract class GetDevicesResponseModel with _$GetDevicesResponseModel {
const factory GetDevicesResponseModel({
required List<GetDevicesItemResponseModel> items,
}) = _GetDevicesResponseModel;
factory GetDevicesResponseModel.fromJson(Map<String, dynamic> json) =>
_$GetDevicesResponseModelFromJson(json);
}
@freezed
abstract class GetDevicesItemResponseModel with _$GetDevicesItemResponseModel {
const factory GetDevicesItemResponseModel({
required String id,
required String identificator,
int? battery,
String? userId,
required Map<String, dynamic> flags,
String? carrierGenre,
int? carrierBirthday,
int? carrierWeight,
int? carrierStepLength,
required String carrierName,
String? phone,
required Map<String, dynamic> settings,
required String connectionServer,
required String protocol,
required String type,
required int createdAt,
}) = _GetDevicesItemResponseModel;
factory GetDevicesItemResponseModel.fromJson(Map<String, dynamic> json) =>
_$GetDevicesItemResponseModelFromJson(json);
}
extension GetDevicesResponseModelMapper on GetDevicesResponseModel {
List<DeviceEntity> toEntity() {
return items
.map(
(item) => DeviceEntity(
id: item.id,
identificator: item.identificator,
battery: item.battery,
userId: item.userId,
flags: item.flags,
carrierGenre: item.carrierGenre,
carrierBirthday: item.carrierBirthday.toString(),
carrierWeight: item.carrierWeight,
carrierStepLength: item.carrierStepLength,
carrierName: item.carrierName,
phone: item.phone,
settings: item.settings,
connectionServer: item.connectionServer,
protocol: item.protocol,
type: item.type,
createdAt: item.createdAt.toString(),
),
)
.toList();
}
}

View File

@@ -0,0 +1,603 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// 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
part of 'get_devices_response_model.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$GetDevicesResponseModel {
List<GetDevicesItemResponseModel> get items;
/// Create a copy of GetDevicesResponseModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$GetDevicesResponseModelCopyWith<GetDevicesResponseModel> get copyWith => _$GetDevicesResponseModelCopyWithImpl<GetDevicesResponseModel>(this as GetDevicesResponseModel, _$identity);
/// Serializes this GetDevicesResponseModel to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetDevicesResponseModel&&const DeepCollectionEquality().equals(other.items, items));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(items));
@override
String toString() {
return 'GetDevicesResponseModel(items: $items)';
}
}
/// @nodoc
abstract mixin class $GetDevicesResponseModelCopyWith<$Res> {
factory $GetDevicesResponseModelCopyWith(GetDevicesResponseModel value, $Res Function(GetDevicesResponseModel) _then) = _$GetDevicesResponseModelCopyWithImpl;
@useResult
$Res call({
List<GetDevicesItemResponseModel> items
});
}
/// @nodoc
class _$GetDevicesResponseModelCopyWithImpl<$Res>
implements $GetDevicesResponseModelCopyWith<$Res> {
_$GetDevicesResponseModelCopyWithImpl(this._self, this._then);
final GetDevicesResponseModel _self;
final $Res Function(GetDevicesResponseModel) _then;
/// Create a copy of GetDevicesResponseModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? items = null,}) {
return _then(_self.copyWith(
items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable
as List<GetDevicesItemResponseModel>,
));
}
}
/// Adds pattern-matching-related methods to [GetDevicesResponseModel].
extension GetDevicesResponseModelPatterns on GetDevicesResponseModel {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _GetDevicesResponseModel value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _GetDevicesResponseModel() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _GetDevicesResponseModel value) $default,){
final _that = this;
switch (_that) {
case _GetDevicesResponseModel():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _GetDevicesResponseModel value)? $default,){
final _that = this;
switch (_that) {
case _GetDevicesResponseModel() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<GetDevicesItemResponseModel> items)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _GetDevicesResponseModel() when $default != null:
return $default(_that.items);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<GetDevicesItemResponseModel> items) $default,) {final _that = this;
switch (_that) {
case _GetDevicesResponseModel():
return $default(_that.items);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<GetDevicesItemResponseModel> items)? $default,) {final _that = this;
switch (_that) {
case _GetDevicesResponseModel() when $default != null:
return $default(_that.items);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _GetDevicesResponseModel implements GetDevicesResponseModel {
const _GetDevicesResponseModel({required final List<GetDevicesItemResponseModel> items}): _items = items;
factory _GetDevicesResponseModel.fromJson(Map<String, dynamic> json) => _$GetDevicesResponseModelFromJson(json);
final List<GetDevicesItemResponseModel> _items;
@override List<GetDevicesItemResponseModel> get items {
if (_items is EqualUnmodifiableListView) return _items;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_items);
}
/// Create a copy of GetDevicesResponseModel
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$GetDevicesResponseModelCopyWith<_GetDevicesResponseModel> get copyWith => __$GetDevicesResponseModelCopyWithImpl<_GetDevicesResponseModel>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$GetDevicesResponseModelToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetDevicesResponseModel&&const DeepCollectionEquality().equals(other._items, _items));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_items));
@override
String toString() {
return 'GetDevicesResponseModel(items: $items)';
}
}
/// @nodoc
abstract mixin class _$GetDevicesResponseModelCopyWith<$Res> implements $GetDevicesResponseModelCopyWith<$Res> {
factory _$GetDevicesResponseModelCopyWith(_GetDevicesResponseModel value, $Res Function(_GetDevicesResponseModel) _then) = __$GetDevicesResponseModelCopyWithImpl;
@override @useResult
$Res call({
List<GetDevicesItemResponseModel> items
});
}
/// @nodoc
class __$GetDevicesResponseModelCopyWithImpl<$Res>
implements _$GetDevicesResponseModelCopyWith<$Res> {
__$GetDevicesResponseModelCopyWithImpl(this._self, this._then);
final _GetDevicesResponseModel _self;
final $Res Function(_GetDevicesResponseModel) _then;
/// Create a copy of GetDevicesResponseModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? items = null,}) {
return _then(_GetDevicesResponseModel(
items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable
as List<GetDevicesItemResponseModel>,
));
}
}
/// @nodoc
mixin _$GetDevicesItemResponseModel {
String get id; String get identificator; int? get battery; String? get userId; Map<String, dynamic> get flags; String? get carrierGenre; int? get carrierBirthday; int? get carrierWeight; int? get carrierStepLength; String get carrierName; String? get phone; Map<String, dynamic> get settings; String get connectionServer; String get protocol; String get type; int get createdAt;
/// Create a copy of GetDevicesItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$GetDevicesItemResponseModelCopyWith<GetDevicesItemResponseModel> get copyWith => _$GetDevicesItemResponseModelCopyWithImpl<GetDevicesItemResponseModel>(this as GetDevicesItemResponseModel, _$identity);
/// Serializes this GetDevicesItemResponseModel to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetDevicesItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.battery, battery) || other.battery == battery)&&(identical(other.userId, userId) || other.userId == userId)&&const DeepCollectionEquality().equals(other.flags, flags)&&(identical(other.carrierGenre, carrierGenre) || other.carrierGenre == carrierGenre)&&(identical(other.carrierBirthday, carrierBirthday) || other.carrierBirthday == carrierBirthday)&&(identical(other.carrierWeight, carrierWeight) || other.carrierWeight == carrierWeight)&&(identical(other.carrierStepLength, carrierStepLength) || other.carrierStepLength == carrierStepLength)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName)&&(identical(other.phone, phone) || other.phone == phone)&&const DeepCollectionEquality().equals(other.settings, settings)&&(identical(other.connectionServer, connectionServer) || other.connectionServer == connectionServer)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.type, type) || other.type == type)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,id,identificator,battery,userId,const DeepCollectionEquality().hash(flags),carrierGenre,carrierBirthday,carrierWeight,carrierStepLength,carrierName,phone,const DeepCollectionEquality().hash(settings),connectionServer,protocol,type,createdAt);
@override
String toString() {
return 'GetDevicesItemResponseModel(id: $id, identificator: $identificator, battery: $battery, userId: $userId, flags: $flags, carrierGenre: $carrierGenre, carrierBirthday: $carrierBirthday, carrierWeight: $carrierWeight, carrierStepLength: $carrierStepLength, carrierName: $carrierName, phone: $phone, settings: $settings, connectionServer: $connectionServer, protocol: $protocol, type: $type, createdAt: $createdAt)';
}
}
/// @nodoc
abstract mixin class $GetDevicesItemResponseModelCopyWith<$Res> {
factory $GetDevicesItemResponseModelCopyWith(GetDevicesItemResponseModel value, $Res Function(GetDevicesItemResponseModel) _then) = _$GetDevicesItemResponseModelCopyWithImpl;
@useResult
$Res call({
String id, String identificator, int? battery, String? userId, Map<String, dynamic> flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, Map<String, dynamic> settings, String connectionServer, String protocol, String type, int createdAt
});
}
/// @nodoc
class _$GetDevicesItemResponseModelCopyWithImpl<$Res>
implements $GetDevicesItemResponseModelCopyWith<$Res> {
_$GetDevicesItemResponseModelCopyWithImpl(this._self, this._then);
final GetDevicesItemResponseModel _self;
final $Res Function(GetDevicesItemResponseModel) _then;
/// Create a copy of GetDevicesItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? identificator = null,Object? battery = freezed,Object? userId = freezed,Object? flags = null,Object? carrierGenre = freezed,Object? carrierBirthday = freezed,Object? carrierWeight = freezed,Object? carrierStepLength = freezed,Object? carrierName = null,Object? phone = freezed,Object? settings = null,Object? connectionServer = null,Object? protocol = null,Object? type = null,Object? createdAt = null,}) {
return _then(_self.copyWith(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
as String,battery: freezed == battery ? _self.battery : battery // ignore: cast_nullable_to_non_nullable
as int?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
as String?,flags: null == flags ? _self.flags : flags // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,carrierGenre: freezed == carrierGenre ? _self.carrierGenre : carrierGenre // ignore: cast_nullable_to_non_nullable
as String?,carrierBirthday: freezed == carrierBirthday ? _self.carrierBirthday : carrierBirthday // ignore: cast_nullable_to_non_nullable
as int?,carrierWeight: freezed == carrierWeight ? _self.carrierWeight : carrierWeight // ignore: cast_nullable_to_non_nullable
as int?,carrierStepLength: freezed == carrierStepLength ? _self.carrierStepLength : carrierStepLength // ignore: cast_nullable_to_non_nullable
as int?,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
as String,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
as String?,settings: null == settings ? _self.settings : settings // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,connectionServer: null == connectionServer ? _self.connectionServer : connectionServer // ignore: cast_nullable_to_non_nullable
as String,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable
as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// Adds pattern-matching-related methods to [GetDevicesItemResponseModel].
extension GetDevicesItemResponseModelPatterns on GetDevicesItemResponseModel {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _GetDevicesItemResponseModel value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _GetDevicesItemResponseModel() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _GetDevicesItemResponseModel value) $default,){
final _that = this;
switch (_that) {
case _GetDevicesItemResponseModel():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _GetDevicesItemResponseModel value)? $default,){
final _that = this;
switch (_that) {
case _GetDevicesItemResponseModel() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String identificator, int? battery, String? userId, Map<String, dynamic> flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, Map<String, dynamic> settings, String connectionServer, String protocol, String type, int createdAt)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _GetDevicesItemResponseModel() when $default != null:
return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.flags,_that.carrierGenre,_that.carrierBirthday,_that.carrierWeight,_that.carrierStepLength,_that.carrierName,_that.phone,_that.settings,_that.connectionServer,_that.protocol,_that.type,_that.createdAt);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String identificator, int? battery, String? userId, Map<String, dynamic> flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, Map<String, dynamic> settings, String connectionServer, String protocol, String type, int createdAt) $default,) {final _that = this;
switch (_that) {
case _GetDevicesItemResponseModel():
return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.flags,_that.carrierGenre,_that.carrierBirthday,_that.carrierWeight,_that.carrierStepLength,_that.carrierName,_that.phone,_that.settings,_that.connectionServer,_that.protocol,_that.type,_that.createdAt);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String identificator, int? battery, String? userId, Map<String, dynamic> flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, Map<String, dynamic> settings, String connectionServer, String protocol, String type, int createdAt)? $default,) {final _that = this;
switch (_that) {
case _GetDevicesItemResponseModel() when $default != null:
return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.flags,_that.carrierGenre,_that.carrierBirthday,_that.carrierWeight,_that.carrierStepLength,_that.carrierName,_that.phone,_that.settings,_that.connectionServer,_that.protocol,_that.type,_that.createdAt);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _GetDevicesItemResponseModel implements GetDevicesItemResponseModel {
const _GetDevicesItemResponseModel({required this.id, required this.identificator, this.battery, this.userId, required final Map<String, dynamic> flags, this.carrierGenre, this.carrierBirthday, this.carrierWeight, this.carrierStepLength, required this.carrierName, this.phone, required final Map<String, dynamic> settings, required this.connectionServer, required this.protocol, required this.type, required this.createdAt}): _flags = flags,_settings = settings;
factory _GetDevicesItemResponseModel.fromJson(Map<String, dynamic> json) => _$GetDevicesItemResponseModelFromJson(json);
@override final String id;
@override final String identificator;
@override final int? battery;
@override final String? userId;
final Map<String, dynamic> _flags;
@override Map<String, dynamic> get flags {
if (_flags is EqualUnmodifiableMapView) return _flags;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(_flags);
}
@override final String? carrierGenre;
@override final int? carrierBirthday;
@override final int? carrierWeight;
@override final int? carrierStepLength;
@override final String carrierName;
@override final String? phone;
final Map<String, dynamic> _settings;
@override Map<String, dynamic> get settings {
if (_settings is EqualUnmodifiableMapView) return _settings;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(_settings);
}
@override final String connectionServer;
@override final String protocol;
@override final String type;
@override final int createdAt;
/// Create a copy of GetDevicesItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$GetDevicesItemResponseModelCopyWith<_GetDevicesItemResponseModel> get copyWith => __$GetDevicesItemResponseModelCopyWithImpl<_GetDevicesItemResponseModel>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$GetDevicesItemResponseModelToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetDevicesItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.battery, battery) || other.battery == battery)&&(identical(other.userId, userId) || other.userId == userId)&&const DeepCollectionEquality().equals(other._flags, _flags)&&(identical(other.carrierGenre, carrierGenre) || other.carrierGenre == carrierGenre)&&(identical(other.carrierBirthday, carrierBirthday) || other.carrierBirthday == carrierBirthday)&&(identical(other.carrierWeight, carrierWeight) || other.carrierWeight == carrierWeight)&&(identical(other.carrierStepLength, carrierStepLength) || other.carrierStepLength == carrierStepLength)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName)&&(identical(other.phone, phone) || other.phone == phone)&&const DeepCollectionEquality().equals(other._settings, _settings)&&(identical(other.connectionServer, connectionServer) || other.connectionServer == connectionServer)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.type, type) || other.type == type)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,id,identificator,battery,userId,const DeepCollectionEquality().hash(_flags),carrierGenre,carrierBirthday,carrierWeight,carrierStepLength,carrierName,phone,const DeepCollectionEquality().hash(_settings),connectionServer,protocol,type,createdAt);
@override
String toString() {
return 'GetDevicesItemResponseModel(id: $id, identificator: $identificator, battery: $battery, userId: $userId, flags: $flags, carrierGenre: $carrierGenre, carrierBirthday: $carrierBirthday, carrierWeight: $carrierWeight, carrierStepLength: $carrierStepLength, carrierName: $carrierName, phone: $phone, settings: $settings, connectionServer: $connectionServer, protocol: $protocol, type: $type, createdAt: $createdAt)';
}
}
/// @nodoc
abstract mixin class _$GetDevicesItemResponseModelCopyWith<$Res> implements $GetDevicesItemResponseModelCopyWith<$Res> {
factory _$GetDevicesItemResponseModelCopyWith(_GetDevicesItemResponseModel value, $Res Function(_GetDevicesItemResponseModel) _then) = __$GetDevicesItemResponseModelCopyWithImpl;
@override @useResult
$Res call({
String id, String identificator, int? battery, String? userId, Map<String, dynamic> flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, Map<String, dynamic> settings, String connectionServer, String protocol, String type, int createdAt
});
}
/// @nodoc
class __$GetDevicesItemResponseModelCopyWithImpl<$Res>
implements _$GetDevicesItemResponseModelCopyWith<$Res> {
__$GetDevicesItemResponseModelCopyWithImpl(this._self, this._then);
final _GetDevicesItemResponseModel _self;
final $Res Function(_GetDevicesItemResponseModel) _then;
/// Create a copy of GetDevicesItemResponseModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? identificator = null,Object? battery = freezed,Object? userId = freezed,Object? flags = null,Object? carrierGenre = freezed,Object? carrierBirthday = freezed,Object? carrierWeight = freezed,Object? carrierStepLength = freezed,Object? carrierName = null,Object? phone = freezed,Object? settings = null,Object? connectionServer = null,Object? protocol = null,Object? type = null,Object? createdAt = null,}) {
return _then(_GetDevicesItemResponseModel(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable
as String,battery: freezed == battery ? _self.battery : battery // ignore: cast_nullable_to_non_nullable
as int?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
as String?,flags: null == flags ? _self._flags : flags // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,carrierGenre: freezed == carrierGenre ? _self.carrierGenre : carrierGenre // ignore: cast_nullable_to_non_nullable
as String?,carrierBirthday: freezed == carrierBirthday ? _self.carrierBirthday : carrierBirthday // ignore: cast_nullable_to_non_nullable
as int?,carrierWeight: freezed == carrierWeight ? _self.carrierWeight : carrierWeight // ignore: cast_nullable_to_non_nullable
as int?,carrierStepLength: freezed == carrierStepLength ? _self.carrierStepLength : carrierStepLength // ignore: cast_nullable_to_non_nullable
as int?,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable
as String,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
as String?,settings: null == settings ? _self._settings : settings // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>,connectionServer: null == connectionServer ? _self.connectionServer : connectionServer // ignore: cast_nullable_to_non_nullable
as String,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable
as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
// dart format on

View File

@@ -0,0 +1,63 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'get_devices_response_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_GetDevicesResponseModel _$GetDevicesResponseModelFromJson(
Map<String, dynamic> json,
) => _GetDevicesResponseModel(
items: (json['items'] as List<dynamic>)
.map(
(e) => GetDevicesItemResponseModel.fromJson(e as Map<String, dynamic>),
)
.toList(),
);
Map<String, dynamic> _$GetDevicesResponseModelToJson(
_GetDevicesResponseModel instance,
) => <String, dynamic>{'items': instance.items};
_GetDevicesItemResponseModel _$GetDevicesItemResponseModelFromJson(
Map<String, dynamic> json,
) => _GetDevicesItemResponseModel(
id: json['id'] as String,
identificator: json['identificator'] as String,
battery: (json['battery'] as num?)?.toInt(),
userId: json['userId'] as String?,
flags: json['flags'] as Map<String, dynamic>,
carrierGenre: json['carrierGenre'] as String?,
carrierBirthday: (json['carrierBirthday'] as num?)?.toInt(),
carrierWeight: (json['carrierWeight'] as num?)?.toInt(),
carrierStepLength: (json['carrierStepLength'] as num?)?.toInt(),
carrierName: json['carrierName'] as String,
phone: json['phone'] as String?,
settings: json['settings'] as Map<String, dynamic>,
connectionServer: json['connectionServer'] as String,
protocol: json['protocol'] as String,
type: json['type'] as String,
createdAt: (json['createdAt'] as num).toInt(),
);
Map<String, dynamic> _$GetDevicesItemResponseModelToJson(
_GetDevicesItemResponseModel instance,
) => <String, dynamic>{
'id': instance.id,
'identificator': instance.identificator,
'battery': instance.battery,
'userId': instance.userId,
'flags': instance.flags,
'carrierGenre': instance.carrierGenre,
'carrierBirthday': instance.carrierBirthday,
'carrierWeight': instance.carrierWeight,
'carrierStepLength': instance.carrierStepLength,
'carrierName': instance.carrierName,
'phone': instance.phone,
'settings': instance.settings,
'connectionServer': instance.connectionServer,
'protocol': instance.protocol,
'type': instance.type,
'createdAt': instance.createdAt,
};

View File

@@ -0,0 +1,15 @@
import 'package:sf_shared/sf_shared.dart';
import '../../domain/repositories/devices_repository.dart';
import '../datasources/devices_remote_datasource.dart';
class DevicesRepositoryImpl implements SharedDevicesRepository {
const DevicesRepositoryImpl(this._remote);
final DevicesRemoteDatasource _remote;
@override
Future<List<DeviceEntity>> getDevices() async {
return _remote.getDevices();
}
}

View File

@@ -0,0 +1,5 @@
import 'package:sf_shared/sf_shared.dart';
abstract class SharedDevicesRepository {
Future<List<DeviceEntity>> getDevices();
}

View File

@@ -1,5 +0,0 @@
import 'package:legacy_shared/src/data/models/send_command_request_model.dart';
abstract class SendCommandUseCase {
Future<void> send({required SendCommandRequestModel request});
}

View File

@@ -1,16 +0,0 @@
import 'package:legacy_shared/legacy_shared.dart';
import '../data/models/send_command_request_model.dart';
import 'repositories/command_repository.dart';
import 'send_command_use_case.dart';
class SendCommandUseCaseImpl implements SendCommandUseCase {
SendCommandUseCaseImpl(this._repository);
final CommandsRepository _repository;
@override
Future<void> send({required SendCommandRequestModel request}) async {
return _repository.send(request: request);
}
}

View File

@@ -0,0 +1,10 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import '../data/datasources/devices_remote_datasource.dart';
import '../data/datasources/devices_remote_datasource_impl.dart';
final devicesRemoteDatasourceProvider = Provider<DevicesRemoteDatasource>((ref) {
final questiaRepository = getIt<QuestiaRepository>();
return DevicesRemoteDatasourceImpl(questiaRepository);
});

View File

@@ -0,0 +1,10 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../legacy_shared.dart';
import '../data/repositories/devices_repository_impl.dart';
import 'devices_remote_datasource_repository_provider.dart';
final sharedDevicesRepositoryProvider = Provider<SharedDevicesRepository>((ref) {
final remote = ref.read(devicesRemoteDatasourceProvider);
return DevicesRepositoryImpl(remote);
});

View File

@@ -1,10 +0,0 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:legacy_shared/src/providers/commands_repository_provider.dart';
import '../domain/send_command_use_case.dart';
import '../domain/send_command_use_case_impl.dart';
final sendCommandUseCaseProvider = Provider.autoDispose<SendCommandUseCase>((ref) {
final commandRepository = ref.read(commandsRepositoryProvider);
return SendCommandUseCaseImpl(commandRepository);
});