mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 02:39:19 +08:00
Update request model
This commit is contained in:
@@ -22,10 +22,8 @@ class RequestModel with _$RequestModel {
|
||||
HttpResponseModel? httpResponseModel,
|
||||
@JsonKey(includeToJson: false) @Default(false) bool isWorking,
|
||||
@JsonKey(includeToJson: false) DateTime? sendingTime,
|
||||
@Default("// Use Javacript to modify this request dynamically")
|
||||
String preRequestScript,
|
||||
@Default("// Use Javacript to modify this request dynamically")
|
||||
String postRequestScript,
|
||||
String? preRequestScript,
|
||||
String? postRequestScript,
|
||||
}) = _RequestModel;
|
||||
|
||||
factory RequestModel.fromJson(Map<String, Object?> json) =>
|
||||
|
||||
@@ -35,8 +35,8 @@ mixin _$RequestModel {
|
||||
bool get isWorking => throw _privateConstructorUsedError;
|
||||
@JsonKey(includeToJson: false)
|
||||
DateTime? get sendingTime => throw _privateConstructorUsedError;
|
||||
String get preRequestScript => throw _privateConstructorUsedError;
|
||||
String get postRequestScript => throw _privateConstructorUsedError;
|
||||
String? get preRequestScript => throw _privateConstructorUsedError;
|
||||
String? get postRequestScript => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this RequestModel to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@@ -66,8 +66,8 @@ abstract class $RequestModelCopyWith<$Res> {
|
||||
HttpResponseModel? httpResponseModel,
|
||||
@JsonKey(includeToJson: false) bool isWorking,
|
||||
@JsonKey(includeToJson: false) DateTime? sendingTime,
|
||||
String preRequestScript,
|
||||
String postRequestScript});
|
||||
String? preRequestScript,
|
||||
String? postRequestScript});
|
||||
|
||||
$HttpRequestModelCopyWith<$Res>? get httpRequestModel;
|
||||
$HttpResponseModelCopyWith<$Res>? get httpResponseModel;
|
||||
@@ -99,8 +99,8 @@ class _$RequestModelCopyWithImpl<$Res, $Val extends RequestModel>
|
||||
Object? httpResponseModel = freezed,
|
||||
Object? isWorking = null,
|
||||
Object? sendingTime = freezed,
|
||||
Object? preRequestScript = null,
|
||||
Object? postRequestScript = null,
|
||||
Object? preRequestScript = freezed,
|
||||
Object? postRequestScript = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
id: null == id
|
||||
@@ -147,14 +147,14 @@ class _$RequestModelCopyWithImpl<$Res, $Val extends RequestModel>
|
||||
? _value.sendingTime
|
||||
: sendingTime // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,
|
||||
preRequestScript: null == preRequestScript
|
||||
preRequestScript: freezed == preRequestScript
|
||||
? _value.preRequestScript
|
||||
: preRequestScript // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
postRequestScript: null == postRequestScript
|
||||
as String?,
|
||||
postRequestScript: freezed == postRequestScript
|
||||
? _value.postRequestScript
|
||||
: postRequestScript // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as String?,
|
||||
) as $Val);
|
||||
}
|
||||
|
||||
@@ -207,8 +207,8 @@ abstract class _$$RequestModelImplCopyWith<$Res>
|
||||
HttpResponseModel? httpResponseModel,
|
||||
@JsonKey(includeToJson: false) bool isWorking,
|
||||
@JsonKey(includeToJson: false) DateTime? sendingTime,
|
||||
String preRequestScript,
|
||||
String postRequestScript});
|
||||
String? preRequestScript,
|
||||
String? postRequestScript});
|
||||
|
||||
@override
|
||||
$HttpRequestModelCopyWith<$Res>? get httpRequestModel;
|
||||
@@ -240,8 +240,8 @@ class __$$RequestModelImplCopyWithImpl<$Res>
|
||||
Object? httpResponseModel = freezed,
|
||||
Object? isWorking = null,
|
||||
Object? sendingTime = freezed,
|
||||
Object? preRequestScript = null,
|
||||
Object? postRequestScript = null,
|
||||
Object? preRequestScript = freezed,
|
||||
Object? postRequestScript = freezed,
|
||||
}) {
|
||||
return _then(_$RequestModelImpl(
|
||||
id: null == id
|
||||
@@ -287,14 +287,14 @@ class __$$RequestModelImplCopyWithImpl<$Res>
|
||||
? _value.sendingTime
|
||||
: sendingTime // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,
|
||||
preRequestScript: null == preRequestScript
|
||||
preRequestScript: freezed == preRequestScript
|
||||
? _value.preRequestScript
|
||||
: preRequestScript // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
postRequestScript: null == postRequestScript
|
||||
as String?,
|
||||
postRequestScript: freezed == postRequestScript
|
||||
? _value.postRequestScript
|
||||
: postRequestScript // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -315,10 +315,8 @@ class _$RequestModelImpl implements _RequestModel {
|
||||
this.httpResponseModel,
|
||||
@JsonKey(includeToJson: false) this.isWorking = false,
|
||||
@JsonKey(includeToJson: false) this.sendingTime,
|
||||
this.preRequestScript =
|
||||
"// Use Javacript to modify this request dynamically",
|
||||
this.postRequestScript =
|
||||
"// Use Javacript to modify this request dynamically"});
|
||||
this.preRequestScript,
|
||||
this.postRequestScript});
|
||||
|
||||
factory _$RequestModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$RequestModelImplFromJson(json);
|
||||
@@ -352,11 +350,9 @@ class _$RequestModelImpl implements _RequestModel {
|
||||
@JsonKey(includeToJson: false)
|
||||
final DateTime? sendingTime;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String preRequestScript;
|
||||
final String? preRequestScript;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String postRequestScript;
|
||||
final String? postRequestScript;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@@ -439,8 +435,8 @@ abstract class _RequestModel implements RequestModel {
|
||||
final HttpResponseModel? httpResponseModel,
|
||||
@JsonKey(includeToJson: false) final bool isWorking,
|
||||
@JsonKey(includeToJson: false) final DateTime? sendingTime,
|
||||
final String preRequestScript,
|
||||
final String postRequestScript}) = _$RequestModelImpl;
|
||||
final String? preRequestScript,
|
||||
final String? postRequestScript}) = _$RequestModelImpl;
|
||||
|
||||
factory _RequestModel.fromJson(Map<String, dynamic> json) =
|
||||
_$RequestModelImpl.fromJson;
|
||||
@@ -471,9 +467,9 @@ abstract class _RequestModel implements RequestModel {
|
||||
@JsonKey(includeToJson: false)
|
||||
DateTime? get sendingTime;
|
||||
@override
|
||||
String get preRequestScript;
|
||||
String? get preRequestScript;
|
||||
@override
|
||||
String get postRequestScript;
|
||||
String? get postRequestScript;
|
||||
|
||||
/// Create a copy of RequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
|
||||
@@ -27,10 +27,8 @@ _$RequestModelImpl _$$RequestModelImplFromJson(Map json) => _$RequestModelImpl(
|
||||
sendingTime: json['sendingTime'] == null
|
||||
? null
|
||||
: DateTime.parse(json['sendingTime'] as String),
|
||||
preRequestScript: json['preRequestScript'] as String? ??
|
||||
"// Use Javacript to modify this request dynamically",
|
||||
postRequestScript: json['postRequestScript'] as String? ??
|
||||
"// Use Javacript to modify this request dynamically",
|
||||
preRequestScript: json['preRequestScript'] as String?,
|
||||
postRequestScript: json['postRequestScript'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$RequestModelImplToJson(_$RequestModelImpl instance) =>
|
||||
|
||||
@@ -281,7 +281,8 @@ class CollectionStateNotifier
|
||||
return;
|
||||
}
|
||||
|
||||
if (requestModel != null && requestModel.preRequestScript.isNotEmpty) {
|
||||
if (requestModel != null &&
|
||||
!requestModel.preRequestScript.isNullOrEmpty()) {
|
||||
requestModel = await handlePreRequestScript(
|
||||
requestModel,
|
||||
originalEnvironmentModel,
|
||||
@@ -355,7 +356,8 @@ class CollectionStateNotifier
|
||||
preRequestScript: requestModel.preRequestScript,
|
||||
postRequestScript: requestModel.postRequestScript,
|
||||
);
|
||||
if (requestModel.postRequestScript.isNotEmpty) {
|
||||
|
||||
if (!requestModel.postRequestScript.isNullOrEmpty()) {
|
||||
newRequestModel = await handlePostResponseScript(
|
||||
newRequestModel,
|
||||
originalEnvironmentModel,
|
||||
|
||||
Reference in New Issue
Block a user