added new response model for tenders

This commit is contained in:
llsajjad
2025-09-07 10:07:53 +03:30
parent ab3d7c7b03
commit cd827ecbe4
12 changed files with 389 additions and 37 deletions
@@ -0,0 +1,16 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import '../tender_approvals_data/tender_approvals_data.dart';
part 'tender_approvals_data_wrapper.freezed.dart';
part 'tender_approvals_data_wrapper.g.dart';
@freezed
abstract class TenderApprovalsDataWrapper with _$TenderApprovalsDataWrapper {
const factory TenderApprovalsDataWrapper({
required List<TenderApprovalsData>? tenders,
}) = _TenderApprovalsDataWrapper;
factory TenderApprovalsDataWrapper.fromJson(Map<String, Object?> json) =>
_$TenderApprovalsDataWrapperFromJson(json);
}
@@ -0,0 +1,285 @@
// 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 'tender_approvals_data_wrapper.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$TenderApprovalsDataWrapper {
List<TenderApprovalsData>? get tenders;
/// Create a copy of TenderApprovalsDataWrapper
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$TenderApprovalsDataWrapperCopyWith<TenderApprovalsDataWrapper> get copyWith => _$TenderApprovalsDataWrapperCopyWithImpl<TenderApprovalsDataWrapper>(this as TenderApprovalsDataWrapper, _$identity);
/// Serializes this TenderApprovalsDataWrapper to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is TenderApprovalsDataWrapper&&const DeepCollectionEquality().equals(other.tenders, tenders));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(tenders));
@override
String toString() {
return 'TenderApprovalsDataWrapper(tenders: $tenders)';
}
}
/// @nodoc
abstract mixin class $TenderApprovalsDataWrapperCopyWith<$Res> {
factory $TenderApprovalsDataWrapperCopyWith(TenderApprovalsDataWrapper value, $Res Function(TenderApprovalsDataWrapper) _then) = _$TenderApprovalsDataWrapperCopyWithImpl;
@useResult
$Res call({
List<TenderApprovalsData>? tenders
});
}
/// @nodoc
class _$TenderApprovalsDataWrapperCopyWithImpl<$Res>
implements $TenderApprovalsDataWrapperCopyWith<$Res> {
_$TenderApprovalsDataWrapperCopyWithImpl(this._self, this._then);
final TenderApprovalsDataWrapper _self;
final $Res Function(TenderApprovalsDataWrapper) _then;
/// Create a copy of TenderApprovalsDataWrapper
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? tenders = freezed,}) {
return _then(_self.copyWith(
tenders: freezed == tenders ? _self.tenders : tenders // ignore: cast_nullable_to_non_nullable
as List<TenderApprovalsData>?,
));
}
}
/// Adds pattern-matching-related methods to [TenderApprovalsDataWrapper].
extension TenderApprovalsDataWrapperPatterns on TenderApprovalsDataWrapper {
/// 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( _TenderApprovalsDataWrapper value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _TenderApprovalsDataWrapper() 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( _TenderApprovalsDataWrapper value) $default,){
final _that = this;
switch (_that) {
case _TenderApprovalsDataWrapper():
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( _TenderApprovalsDataWrapper value)? $default,){
final _that = this;
switch (_that) {
case _TenderApprovalsDataWrapper() 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<TenderApprovalsData>? tenders)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _TenderApprovalsDataWrapper() when $default != null:
return $default(_that.tenders);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<TenderApprovalsData>? tenders) $default,) {final _that = this;
switch (_that) {
case _TenderApprovalsDataWrapper():
return $default(_that.tenders);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<TenderApprovalsData>? tenders)? $default,) {final _that = this;
switch (_that) {
case _TenderApprovalsDataWrapper() when $default != null:
return $default(_that.tenders);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _TenderApprovalsDataWrapper implements TenderApprovalsDataWrapper {
const _TenderApprovalsDataWrapper({required final List<TenderApprovalsData>? tenders}): _tenders = tenders;
factory _TenderApprovalsDataWrapper.fromJson(Map<String, dynamic> json) => _$TenderApprovalsDataWrapperFromJson(json);
final List<TenderApprovalsData>? _tenders;
@override List<TenderApprovalsData>? get tenders {
final value = _tenders;
if (value == null) return null;
if (_tenders is EqualUnmodifiableListView) return _tenders;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(value);
}
/// Create a copy of TenderApprovalsDataWrapper
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$TenderApprovalsDataWrapperCopyWith<_TenderApprovalsDataWrapper> get copyWith => __$TenderApprovalsDataWrapperCopyWithImpl<_TenderApprovalsDataWrapper>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$TenderApprovalsDataWrapperToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _TenderApprovalsDataWrapper&&const DeepCollectionEquality().equals(other._tenders, _tenders));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_tenders));
@override
String toString() {
return 'TenderApprovalsDataWrapper(tenders: $tenders)';
}
}
/// @nodoc
abstract mixin class _$TenderApprovalsDataWrapperCopyWith<$Res> implements $TenderApprovalsDataWrapperCopyWith<$Res> {
factory _$TenderApprovalsDataWrapperCopyWith(_TenderApprovalsDataWrapper value, $Res Function(_TenderApprovalsDataWrapper) _then) = __$TenderApprovalsDataWrapperCopyWithImpl;
@override @useResult
$Res call({
List<TenderApprovalsData>? tenders
});
}
/// @nodoc
class __$TenderApprovalsDataWrapperCopyWithImpl<$Res>
implements _$TenderApprovalsDataWrapperCopyWith<$Res> {
__$TenderApprovalsDataWrapperCopyWithImpl(this._self, this._then);
final _TenderApprovalsDataWrapper _self;
final $Res Function(_TenderApprovalsDataWrapper) _then;
/// Create a copy of TenderApprovalsDataWrapper
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? tenders = freezed,}) {
return _then(_TenderApprovalsDataWrapper(
tenders: freezed == tenders ? _self._tenders : tenders // ignore: cast_nullable_to_non_nullable
as List<TenderApprovalsData>?,
));
}
}
// dart format on
@@ -0,0 +1,20 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'tender_approvals_data_wrapper.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_TenderApprovalsDataWrapper _$TenderApprovalsDataWrapperFromJson(
Map<String, dynamic> json,
) => _TenderApprovalsDataWrapper(
tenders:
(json['tenders'] as List<dynamic>?)
?.map((e) => TenderApprovalsData.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$TenderApprovalsDataWrapperToJson(
_TenderApprovalsDataWrapper instance,
) => <String, dynamic>{'tenders': instance.tenders};
@@ -1,4 +1,5 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:tm_app/data/services/model/tender_approvals_data_warpper/tender_approvals_data_wrapper.dart';
import '../error/error_model.dart';
import '../tender_approvals_data/tender_approvals_data.dart';
@@ -11,7 +12,7 @@ abstract class TenderApprovalsResponse with _$TenderApprovalsResponse {
const factory TenderApprovalsResponse({
required bool? success,
required ErrorModel? error,
required List<TenderApprovalsData>? data,
required TenderApprovalsDataWrapper? data,
}) = _TenderApprovalsResponse;
factory TenderApprovalsResponse.fromJson(Map<String, Object?> json) =>
@@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$TenderApprovalsResponse {
bool? get success; ErrorModel? get error; List<TenderApprovalsData>? get data;
bool? get success; ErrorModel? get error; TenderApprovalsDataWrapper? get data;
/// Create a copy of TenderApprovalsResponse
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -28,12 +28,12 @@ $TenderApprovalsResponseCopyWith<TenderApprovalsResponse> get copyWith => _$Tend
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is TenderApprovalsResponse&&(identical(other.success, success) || other.success == success)&&(identical(other.error, error) || other.error == error)&&const DeepCollectionEquality().equals(other.data, data));
return identical(this, other) || (other.runtimeType == runtimeType&&other is TenderApprovalsResponse&&(identical(other.success, success) || other.success == success)&&(identical(other.error, error) || other.error == error)&&(identical(other.data, data) || other.data == data));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,success,error,const DeepCollectionEquality().hash(data));
int get hashCode => Object.hash(runtimeType,success,error,data);
@override
String toString() {
@@ -48,11 +48,11 @@ abstract mixin class $TenderApprovalsResponseCopyWith<$Res> {
factory $TenderApprovalsResponseCopyWith(TenderApprovalsResponse value, $Res Function(TenderApprovalsResponse) _then) = _$TenderApprovalsResponseCopyWithImpl;
@useResult
$Res call({
bool? success, ErrorModel? error, List<TenderApprovalsData>? data
bool? success, ErrorModel? error, TenderApprovalsDataWrapper? data
});
$ErrorModelCopyWith<$Res>? get error;
$ErrorModelCopyWith<$Res>? get error;$TenderApprovalsDataWrapperCopyWith<$Res>? get data;
}
/// @nodoc
@@ -70,7 +70,7 @@ class _$TenderApprovalsResponseCopyWithImpl<$Res>
success: freezed == success ? _self.success : success // ignore: cast_nullable_to_non_nullable
as bool?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
as ErrorModel?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable
as List<TenderApprovalsData>?,
as TenderApprovalsDataWrapper?,
));
}
/// Create a copy of TenderApprovalsResponse
@@ -85,6 +85,18 @@ $ErrorModelCopyWith<$Res>? get error {
return $ErrorModelCopyWith<$Res>(_self.error!, (value) {
return _then(_self.copyWith(error: value));
});
}/// Create a copy of TenderApprovalsResponse
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$TenderApprovalsDataWrapperCopyWith<$Res>? get data {
if (_self.data == null) {
return null;
}
return $TenderApprovalsDataWrapperCopyWith<$Res>(_self.data!, (value) {
return _then(_self.copyWith(data: value));
});
}
}
@@ -167,7 +179,7 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool? success, ErrorModel? error, List<TenderApprovalsData>? data)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool? success, ErrorModel? error, TenderApprovalsDataWrapper? data)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _TenderApprovalsResponse() when $default != null:
return $default(_that.success,_that.error,_that.data);case _:
@@ -188,7 +200,7 @@ return $default(_that.success,_that.error,_that.data);case _:
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool? success, ErrorModel? error, List<TenderApprovalsData>? data) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool? success, ErrorModel? error, TenderApprovalsDataWrapper? data) $default,) {final _that = this;
switch (_that) {
case _TenderApprovalsResponse():
return $default(_that.success,_that.error,_that.data);case _:
@@ -208,7 +220,7 @@ return $default(_that.success,_that.error,_that.data);case _:
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool? success, ErrorModel? error, List<TenderApprovalsData>? data)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool? success, ErrorModel? error, TenderApprovalsDataWrapper? data)? $default,) {final _that = this;
switch (_that) {
case _TenderApprovalsResponse() when $default != null:
return $default(_that.success,_that.error,_that.data);case _:
@@ -223,20 +235,12 @@ return $default(_that.success,_that.error,_that.data);case _:
@JsonSerializable()
class _TenderApprovalsResponse implements TenderApprovalsResponse {
const _TenderApprovalsResponse({required this.success, required this.error, required final List<TenderApprovalsData>? data}): _data = data;
const _TenderApprovalsResponse({required this.success, required this.error, required this.data});
factory _TenderApprovalsResponse.fromJson(Map<String, dynamic> json) => _$TenderApprovalsResponseFromJson(json);
@override final bool? success;
@override final ErrorModel? error;
final List<TenderApprovalsData>? _data;
@override List<TenderApprovalsData>? get data {
final value = _data;
if (value == null) return null;
if (_data is EqualUnmodifiableListView) return _data;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(value);
}
@override final TenderApprovalsDataWrapper? data;
/// Create a copy of TenderApprovalsResponse
/// with the given fields replaced by the non-null parameter values.
@@ -251,12 +255,12 @@ Map<String, dynamic> toJson() {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _TenderApprovalsResponse&&(identical(other.success, success) || other.success == success)&&(identical(other.error, error) || other.error == error)&&const DeepCollectionEquality().equals(other._data, _data));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _TenderApprovalsResponse&&(identical(other.success, success) || other.success == success)&&(identical(other.error, error) || other.error == error)&&(identical(other.data, data) || other.data == data));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,success,error,const DeepCollectionEquality().hash(_data));
int get hashCode => Object.hash(runtimeType,success,error,data);
@override
String toString() {
@@ -271,11 +275,11 @@ abstract mixin class _$TenderApprovalsResponseCopyWith<$Res> implements $TenderA
factory _$TenderApprovalsResponseCopyWith(_TenderApprovalsResponse value, $Res Function(_TenderApprovalsResponse) _then) = __$TenderApprovalsResponseCopyWithImpl;
@override @useResult
$Res call({
bool? success, ErrorModel? error, List<TenderApprovalsData>? data
bool? success, ErrorModel? error, TenderApprovalsDataWrapper? data
});
@override $ErrorModelCopyWith<$Res>? get error;
@override $ErrorModelCopyWith<$Res>? get error;@override $TenderApprovalsDataWrapperCopyWith<$Res>? get data;
}
/// @nodoc
@@ -292,8 +296,8 @@ class __$TenderApprovalsResponseCopyWithImpl<$Res>
return _then(_TenderApprovalsResponse(
success: freezed == success ? _self.success : success // ignore: cast_nullable_to_non_nullable
as bool?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
as ErrorModel?,data: freezed == data ? _self._data : data // ignore: cast_nullable_to_non_nullable
as List<TenderApprovalsData>?,
as ErrorModel?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable
as TenderApprovalsDataWrapper?,
));
}
@@ -309,6 +313,18 @@ $ErrorModelCopyWith<$Res>? get error {
return $ErrorModelCopyWith<$Res>(_self.error!, (value) {
return _then(_self.copyWith(error: value));
});
}/// Create a copy of TenderApprovalsResponse
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$TenderApprovalsDataWrapperCopyWith<$Res>? get data {
if (_self.data == null) {
return null;
}
return $TenderApprovalsDataWrapperCopyWith<$Res>(_self.data!, (value) {
return _then(_self.copyWith(data: value));
});
}
}
@@ -15,9 +15,11 @@ _TenderApprovalsResponse _$TenderApprovalsResponseFromJson(
? null
: ErrorModel.fromJson(json['error'] as Map<String, dynamic>),
data:
(json['data'] as List<dynamic>?)
?.map((e) => TenderApprovalsData.fromJson(e as Map<String, dynamic>))
.toList(),
json['data'] == null
? null
: TenderApprovalsDataWrapper.fromJson(
json['data'] as Map<String, dynamic>,
),
);
Map<String, dynamic> _$TenderApprovalsResponseToJson(