Update request model

This commit is contained in:
Ankit Mahato
2025-06-29 01:21:52 +05:30
parent adf843e8bb
commit 7096c2f301
4 changed files with 34 additions and 40 deletions

View File

@@ -22,10 +22,8 @@ class RequestModel with _$RequestModel {
HttpResponseModel? httpResponseModel, HttpResponseModel? httpResponseModel,
@JsonKey(includeToJson: false) @Default(false) bool isWorking, @JsonKey(includeToJson: false) @Default(false) bool isWorking,
@JsonKey(includeToJson: false) DateTime? sendingTime, @JsonKey(includeToJson: false) DateTime? sendingTime,
@Default("// Use Javacript to modify this request dynamically") String? preRequestScript,
String preRequestScript, String? postRequestScript,
@Default("// Use Javacript to modify this request dynamically")
String postRequestScript,
}) = _RequestModel; }) = _RequestModel;
factory RequestModel.fromJson(Map<String, Object?> json) => factory RequestModel.fromJson(Map<String, Object?> json) =>

View File

@@ -35,8 +35,8 @@ mixin _$RequestModel {
bool get isWorking => throw _privateConstructorUsedError; bool get isWorking => throw _privateConstructorUsedError;
@JsonKey(includeToJson: false) @JsonKey(includeToJson: false)
DateTime? get sendingTime => throw _privateConstructorUsedError; DateTime? get sendingTime => throw _privateConstructorUsedError;
String get preRequestScript => throw _privateConstructorUsedError; String? get preRequestScript => throw _privateConstructorUsedError;
String get postRequestScript => throw _privateConstructorUsedError; String? get postRequestScript => throw _privateConstructorUsedError;
/// Serializes this RequestModel to a JSON map. /// Serializes this RequestModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError; Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@@ -66,8 +66,8 @@ abstract class $RequestModelCopyWith<$Res> {
HttpResponseModel? httpResponseModel, HttpResponseModel? httpResponseModel,
@JsonKey(includeToJson: false) bool isWorking, @JsonKey(includeToJson: false) bool isWorking,
@JsonKey(includeToJson: false) DateTime? sendingTime, @JsonKey(includeToJson: false) DateTime? sendingTime,
String preRequestScript, String? preRequestScript,
String postRequestScript}); String? postRequestScript});
$HttpRequestModelCopyWith<$Res>? get httpRequestModel; $HttpRequestModelCopyWith<$Res>? get httpRequestModel;
$HttpResponseModelCopyWith<$Res>? get httpResponseModel; $HttpResponseModelCopyWith<$Res>? get httpResponseModel;
@@ -99,8 +99,8 @@ class _$RequestModelCopyWithImpl<$Res, $Val extends RequestModel>
Object? httpResponseModel = freezed, Object? httpResponseModel = freezed,
Object? isWorking = null, Object? isWorking = null,
Object? sendingTime = freezed, Object? sendingTime = freezed,
Object? preRequestScript = null, Object? preRequestScript = freezed,
Object? postRequestScript = null, Object? postRequestScript = freezed,
}) { }) {
return _then(_value.copyWith( return _then(_value.copyWith(
id: null == id id: null == id
@@ -147,14 +147,14 @@ class _$RequestModelCopyWithImpl<$Res, $Val extends RequestModel>
? _value.sendingTime ? _value.sendingTime
: sendingTime // ignore: cast_nullable_to_non_nullable : sendingTime // ignore: cast_nullable_to_non_nullable
as DateTime?, as DateTime?,
preRequestScript: null == preRequestScript preRequestScript: freezed == preRequestScript
? _value.preRequestScript ? _value.preRequestScript
: preRequestScript // ignore: cast_nullable_to_non_nullable : preRequestScript // ignore: cast_nullable_to_non_nullable
as String, as String?,
postRequestScript: null == postRequestScript postRequestScript: freezed == postRequestScript
? _value.postRequestScript ? _value.postRequestScript
: postRequestScript // ignore: cast_nullable_to_non_nullable : postRequestScript // ignore: cast_nullable_to_non_nullable
as String, as String?,
) as $Val); ) as $Val);
} }
@@ -207,8 +207,8 @@ abstract class _$$RequestModelImplCopyWith<$Res>
HttpResponseModel? httpResponseModel, HttpResponseModel? httpResponseModel,
@JsonKey(includeToJson: false) bool isWorking, @JsonKey(includeToJson: false) bool isWorking,
@JsonKey(includeToJson: false) DateTime? sendingTime, @JsonKey(includeToJson: false) DateTime? sendingTime,
String preRequestScript, String? preRequestScript,
String postRequestScript}); String? postRequestScript});
@override @override
$HttpRequestModelCopyWith<$Res>? get httpRequestModel; $HttpRequestModelCopyWith<$Res>? get httpRequestModel;
@@ -240,8 +240,8 @@ class __$$RequestModelImplCopyWithImpl<$Res>
Object? httpResponseModel = freezed, Object? httpResponseModel = freezed,
Object? isWorking = null, Object? isWorking = null,
Object? sendingTime = freezed, Object? sendingTime = freezed,
Object? preRequestScript = null, Object? preRequestScript = freezed,
Object? postRequestScript = null, Object? postRequestScript = freezed,
}) { }) {
return _then(_$RequestModelImpl( return _then(_$RequestModelImpl(
id: null == id id: null == id
@@ -287,14 +287,14 @@ class __$$RequestModelImplCopyWithImpl<$Res>
? _value.sendingTime ? _value.sendingTime
: sendingTime // ignore: cast_nullable_to_non_nullable : sendingTime // ignore: cast_nullable_to_non_nullable
as DateTime?, as DateTime?,
preRequestScript: null == preRequestScript preRequestScript: freezed == preRequestScript
? _value.preRequestScript ? _value.preRequestScript
: preRequestScript // ignore: cast_nullable_to_non_nullable : preRequestScript // ignore: cast_nullable_to_non_nullable
as String, as String?,
postRequestScript: null == postRequestScript postRequestScript: freezed == postRequestScript
? _value.postRequestScript ? _value.postRequestScript
: postRequestScript // ignore: cast_nullable_to_non_nullable : postRequestScript // ignore: cast_nullable_to_non_nullable
as String, as String?,
)); ));
} }
} }
@@ -315,10 +315,8 @@ class _$RequestModelImpl implements _RequestModel {
this.httpResponseModel, this.httpResponseModel,
@JsonKey(includeToJson: false) this.isWorking = false, @JsonKey(includeToJson: false) this.isWorking = false,
@JsonKey(includeToJson: false) this.sendingTime, @JsonKey(includeToJson: false) this.sendingTime,
this.preRequestScript = this.preRequestScript,
"// Use Javacript to modify this request dynamically", this.postRequestScript});
this.postRequestScript =
"// Use Javacript to modify this request dynamically"});
factory _$RequestModelImpl.fromJson(Map<String, dynamic> json) => factory _$RequestModelImpl.fromJson(Map<String, dynamic> json) =>
_$$RequestModelImplFromJson(json); _$$RequestModelImplFromJson(json);
@@ -352,11 +350,9 @@ class _$RequestModelImpl implements _RequestModel {
@JsonKey(includeToJson: false) @JsonKey(includeToJson: false)
final DateTime? sendingTime; final DateTime? sendingTime;
@override @override
@JsonKey() final String? preRequestScript;
final String preRequestScript;
@override @override
@JsonKey() final String? postRequestScript;
final String postRequestScript;
@override @override
String toString() { String toString() {
@@ -439,8 +435,8 @@ abstract class _RequestModel implements RequestModel {
final HttpResponseModel? httpResponseModel, final HttpResponseModel? httpResponseModel,
@JsonKey(includeToJson: false) final bool isWorking, @JsonKey(includeToJson: false) final bool isWorking,
@JsonKey(includeToJson: false) final DateTime? sendingTime, @JsonKey(includeToJson: false) final DateTime? sendingTime,
final String preRequestScript, final String? preRequestScript,
final String postRequestScript}) = _$RequestModelImpl; final String? postRequestScript}) = _$RequestModelImpl;
factory _RequestModel.fromJson(Map<String, dynamic> json) = factory _RequestModel.fromJson(Map<String, dynamic> json) =
_$RequestModelImpl.fromJson; _$RequestModelImpl.fromJson;
@@ -471,9 +467,9 @@ abstract class _RequestModel implements RequestModel {
@JsonKey(includeToJson: false) @JsonKey(includeToJson: false)
DateTime? get sendingTime; DateTime? get sendingTime;
@override @override
String get preRequestScript; String? get preRequestScript;
@override @override
String get postRequestScript; String? get postRequestScript;
/// Create a copy of RequestModel /// Create a copy of RequestModel
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.

View File

@@ -27,10 +27,8 @@ _$RequestModelImpl _$$RequestModelImplFromJson(Map json) => _$RequestModelImpl(
sendingTime: json['sendingTime'] == null sendingTime: json['sendingTime'] == null
? null ? null
: DateTime.parse(json['sendingTime'] as String), : DateTime.parse(json['sendingTime'] as String),
preRequestScript: json['preRequestScript'] as String? ?? preRequestScript: json['preRequestScript'] as String?,
"// Use Javacript to modify this request dynamically", postRequestScript: json['postRequestScript'] as String?,
postRequestScript: json['postRequestScript'] as String? ??
"// Use Javacript to modify this request dynamically",
); );
Map<String, dynamic> _$$RequestModelImplToJson(_$RequestModelImpl instance) => Map<String, dynamic> _$$RequestModelImplToJson(_$RequestModelImpl instance) =>

View File

@@ -281,7 +281,8 @@ class CollectionStateNotifier
return; return;
} }
if (requestModel != null && requestModel.preRequestScript.isNotEmpty) { if (requestModel != null &&
!requestModel.preRequestScript.isNullOrEmpty()) {
requestModel = await handlePreRequestScript( requestModel = await handlePreRequestScript(
requestModel, requestModel,
originalEnvironmentModel, originalEnvironmentModel,
@@ -355,7 +356,8 @@ class CollectionStateNotifier
preRequestScript: requestModel.preRequestScript, preRequestScript: requestModel.preRequestScript,
postRequestScript: requestModel.postRequestScript, postRequestScript: requestModel.postRequestScript,
); );
if (requestModel.postRequestScript.isNotEmpty) {
if (!requestModel.postRequestScript.isNullOrEmpty()) {
newRequestModel = await handlePostResponseScript( newRequestModel = await handlePostResponseScript(
newRequestModel, newRequestModel,
originalEnvironmentModel, originalEnvironmentModel,