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
@@ -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(