From 68318e6b9009f98dd8cb177fc89540c188344d0f Mon Sep 17 00:00:00 2001 From: Udhay-Adithya Date: Mon, 23 Jun 2025 22:33:22 +0530 Subject: [PATCH] feat: add preRequestScript and postRequestScript to HistoryRequestModel --- lib/models/history_request_model.dart | 2 + lib/models/history_request_model.freezed.dart | 65 +++++++++++++++---- lib/models/history_request_model.g.dart | 4 ++ lib/providers/collection_providers.dart | 2 + 4 files changed, 61 insertions(+), 12 deletions(-) diff --git a/lib/models/history_request_model.dart b/lib/models/history_request_model.dart index a895e945..bdedc721 100644 --- a/lib/models/history_request_model.dart +++ b/lib/models/history_request_model.dart @@ -16,6 +16,8 @@ class HistoryRequestModel with _$HistoryRequestModel { required HistoryMetaModel metaData, required HttpRequestModel httpRequestModel, required HttpResponseModel httpResponseModel, + required String preRequestScript, + required String postRequestScript, }) = _HistoryRequestModel; factory HistoryRequestModel.fromJson(Map json) => diff --git a/lib/models/history_request_model.freezed.dart b/lib/models/history_request_model.freezed.dart index bb7e9492..70ccfde2 100644 --- a/lib/models/history_request_model.freezed.dart +++ b/lib/models/history_request_model.freezed.dart @@ -24,6 +24,8 @@ mixin _$HistoryRequestModel { HistoryMetaModel get metaData => throw _privateConstructorUsedError; HttpRequestModel get httpRequestModel => throw _privateConstructorUsedError; HttpResponseModel get httpResponseModel => throw _privateConstructorUsedError; + String get preRequestScript => throw _privateConstructorUsedError; + String get postRequestScript => throw _privateConstructorUsedError; /// Serializes this HistoryRequestModel to a JSON map. Map toJson() => throw _privateConstructorUsedError; @@ -45,7 +47,9 @@ abstract class $HistoryRequestModelCopyWith<$Res> { {String historyId, HistoryMetaModel metaData, HttpRequestModel httpRequestModel, - HttpResponseModel httpResponseModel}); + HttpResponseModel httpResponseModel, + String preRequestScript, + String postRequestScript}); $HistoryMetaModelCopyWith<$Res> get metaData; $HttpRequestModelCopyWith<$Res> get httpRequestModel; @@ -71,6 +75,8 @@ class _$HistoryRequestModelCopyWithImpl<$Res, $Val extends HistoryRequestModel> Object? metaData = null, Object? httpRequestModel = null, Object? httpResponseModel = null, + Object? preRequestScript = null, + Object? postRequestScript = null, }) { return _then(_value.copyWith( historyId: null == historyId @@ -89,6 +95,14 @@ class _$HistoryRequestModelCopyWithImpl<$Res, $Val extends HistoryRequestModel> ? _value.httpResponseModel : httpResponseModel // ignore: cast_nullable_to_non_nullable as HttpResponseModel, + preRequestScript: null == preRequestScript + ? _value.preRequestScript + : preRequestScript // ignore: cast_nullable_to_non_nullable + as String, + postRequestScript: null == postRequestScript + ? _value.postRequestScript + : postRequestScript // ignore: cast_nullable_to_non_nullable + as String, ) as $Val); } @@ -135,7 +149,9 @@ abstract class _$$HistoryRequestModelImplCopyWith<$Res> {String historyId, HistoryMetaModel metaData, HttpRequestModel httpRequestModel, - HttpResponseModel httpResponseModel}); + HttpResponseModel httpResponseModel, + String preRequestScript, + String postRequestScript}); @override $HistoryMetaModelCopyWith<$Res> get metaData; @@ -162,6 +178,8 @@ class __$$HistoryRequestModelImplCopyWithImpl<$Res> Object? metaData = null, Object? httpRequestModel = null, Object? httpResponseModel = null, + Object? preRequestScript = null, + Object? postRequestScript = null, }) { return _then(_$HistoryRequestModelImpl( historyId: null == historyId @@ -180,6 +198,14 @@ class __$$HistoryRequestModelImplCopyWithImpl<$Res> ? _value.httpResponseModel : httpResponseModel // ignore: cast_nullable_to_non_nullable as HttpResponseModel, + preRequestScript: null == preRequestScript + ? _value.preRequestScript + : preRequestScript // ignore: cast_nullable_to_non_nullable + as String, + postRequestScript: null == postRequestScript + ? _value.postRequestScript + : postRequestScript // ignore: cast_nullable_to_non_nullable + as String, )); } } @@ -192,7 +218,9 @@ class _$HistoryRequestModelImpl implements _HistoryRequestModel { {required this.historyId, required this.metaData, required this.httpRequestModel, - required this.httpResponseModel}); + required this.httpResponseModel, + required this.preRequestScript, + required this.postRequestScript}); factory _$HistoryRequestModelImpl.fromJson(Map json) => _$$HistoryRequestModelImplFromJson(json); @@ -205,10 +233,14 @@ class _$HistoryRequestModelImpl implements _HistoryRequestModel { final HttpRequestModel httpRequestModel; @override final HttpResponseModel httpResponseModel; + @override + final String preRequestScript; + @override + final String postRequestScript; @override String toString() { - return 'HistoryRequestModel(historyId: $historyId, metaData: $metaData, httpRequestModel: $httpRequestModel, httpResponseModel: $httpResponseModel)'; + return 'HistoryRequestModel(historyId: $historyId, metaData: $metaData, httpRequestModel: $httpRequestModel, httpResponseModel: $httpResponseModel, preRequestScript: $preRequestScript, postRequestScript: $postRequestScript)'; } @override @@ -223,13 +255,17 @@ class _$HistoryRequestModelImpl implements _HistoryRequestModel { (identical(other.httpRequestModel, httpRequestModel) || other.httpRequestModel == httpRequestModel) && (identical(other.httpResponseModel, httpResponseModel) || - other.httpResponseModel == httpResponseModel)); + other.httpResponseModel == httpResponseModel) && + (identical(other.preRequestScript, preRequestScript) || + other.preRequestScript == preRequestScript) && + (identical(other.postRequestScript, postRequestScript) || + other.postRequestScript == postRequestScript)); } @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash( - runtimeType, historyId, metaData, httpRequestModel, httpResponseModel); + int get hashCode => Object.hash(runtimeType, historyId, metaData, + httpRequestModel, httpResponseModel, preRequestScript, postRequestScript); /// Create a copy of HistoryRequestModel /// with the given fields replaced by the non-null parameter values. @@ -250,11 +286,12 @@ class _$HistoryRequestModelImpl implements _HistoryRequestModel { abstract class _HistoryRequestModel implements HistoryRequestModel { const factory _HistoryRequestModel( - {required final String historyId, - required final HistoryMetaModel metaData, - required final HttpRequestModel httpRequestModel, - required final HttpResponseModel httpResponseModel}) = - _$HistoryRequestModelImpl; + {required final String historyId, + required final HistoryMetaModel metaData, + required final HttpRequestModel httpRequestModel, + required final HttpResponseModel httpResponseModel, + required final String preRequestScript, + required final String postRequestScript}) = _$HistoryRequestModelImpl; factory _HistoryRequestModel.fromJson(Map json) = _$HistoryRequestModelImpl.fromJson; @@ -267,6 +304,10 @@ abstract class _HistoryRequestModel implements HistoryRequestModel { HttpRequestModel get httpRequestModel; @override HttpResponseModel get httpResponseModel; + @override + String get preRequestScript; + @override + String get postRequestScript; /// Create a copy of HistoryRequestModel /// with the given fields replaced by the non-null parameter values. diff --git a/lib/models/history_request_model.g.dart b/lib/models/history_request_model.g.dart index 830d7a4c..6632e2e2 100644 --- a/lib/models/history_request_model.g.dart +++ b/lib/models/history_request_model.g.dart @@ -15,6 +15,8 @@ _$HistoryRequestModelImpl _$$HistoryRequestModelImplFromJson(Map json) => Map.from(json['httpRequestModel'] as Map)), httpResponseModel: HttpResponseModel.fromJson( Map.from(json['httpResponseModel'] as Map)), + preRequestScript: json['preRequestScript'] as String, + postRequestScript: json['postRequestScript'] as String, ); Map _$$HistoryRequestModelImplToJson( @@ -24,4 +26,6 @@ Map _$$HistoryRequestModelImplToJson( 'metaData': instance.metaData.toJson(), 'httpRequestModel': instance.httpRequestModel.toJson(), 'httpResponseModel': instance.httpResponseModel.toJson(), + 'preRequestScript': instance.preRequestScript, + 'postRequestScript': instance.postRequestScript, }; diff --git a/lib/providers/collection_providers.dart b/lib/providers/collection_providers.dart index 0dd50592..1ff9f60a 100644 --- a/lib/providers/collection_providers.dart +++ b/lib/providers/collection_providers.dart @@ -352,6 +352,8 @@ class CollectionStateNotifier ), httpRequestModel: substitutedHttpRequestModel, httpResponseModel: httpResponseModel, + preRequestScript: requestModel.preRequestScript, + postRequestScript: requestModel.postRequestScript, ); if (requestModel.postRequestScript.isNotEmpty) { newRequestModel = await handlePostResponseScript(