mirror of
https://github.com/foss42/apidash.git
synced 2025-06-04 09:16:02 +08:00
Update HttpRequestModel
This commit is contained in:
@ -7,7 +7,6 @@ import '../utils/utils.dart'
|
||||
import '../consts.dart';
|
||||
|
||||
part 'http_request_model.freezed.dart';
|
||||
|
||||
part 'http_request_model.g.dart';
|
||||
|
||||
@freezed
|
||||
@ -27,6 +26,7 @@ class HttpRequestModel with _$HttpRequestModel {
|
||||
List<bool>? isParamEnabledList,
|
||||
@Default(ContentType.json) ContentType bodyContentType,
|
||||
String? body,
|
||||
String? query,
|
||||
List<FormDataModel>? formData,
|
||||
}) = _HttpRequestModel;
|
||||
|
||||
@ -61,6 +61,7 @@ class HttpRequestModel with _$HttpRequestModel {
|
||||
kMethodsWithBody.contains(method) &&
|
||||
hasFormDataContentType &&
|
||||
formDataMapList.isNotEmpty;
|
||||
bool get hasQuery => query?.isNotEmpty ?? false;
|
||||
List<FormDataModel> get formDataList => formData ?? <FormDataModel>[];
|
||||
List<Map<String, String>> get formDataMapList =>
|
||||
rowsToFormDataMapList(formDataList) ?? [];
|
||||
|
@ -28,6 +28,7 @@ mixin _$HttpRequestModel {
|
||||
List<bool>? get isParamEnabledList => throw _privateConstructorUsedError;
|
||||
ContentType get bodyContentType => throw _privateConstructorUsedError;
|
||||
String? get body => throw _privateConstructorUsedError;
|
||||
String? get query => throw _privateConstructorUsedError;
|
||||
List<FormDataModel>? get formData => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this HttpRequestModel to a JSON map.
|
||||
@ -55,6 +56,7 @@ abstract class $HttpRequestModelCopyWith<$Res> {
|
||||
List<bool>? isParamEnabledList,
|
||||
ContentType bodyContentType,
|
||||
String? body,
|
||||
String? query,
|
||||
List<FormDataModel>? formData});
|
||||
}
|
||||
|
||||
@ -81,6 +83,7 @@ class _$HttpRequestModelCopyWithImpl<$Res, $Val extends HttpRequestModel>
|
||||
Object? isParamEnabledList = freezed,
|
||||
Object? bodyContentType = null,
|
||||
Object? body = freezed,
|
||||
Object? query = freezed,
|
||||
Object? formData = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
@ -116,6 +119,10 @@ class _$HttpRequestModelCopyWithImpl<$Res, $Val extends HttpRequestModel>
|
||||
? _value.body
|
||||
: body // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
query: freezed == query
|
||||
? _value.query
|
||||
: query // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
formData: freezed == formData
|
||||
? _value.formData
|
||||
: formData // ignore: cast_nullable_to_non_nullable
|
||||
@ -141,6 +148,7 @@ abstract class _$$HttpRequestModelImplCopyWith<$Res>
|
||||
List<bool>? isParamEnabledList,
|
||||
ContentType bodyContentType,
|
||||
String? body,
|
||||
String? query,
|
||||
List<FormDataModel>? formData});
|
||||
}
|
||||
|
||||
@ -165,6 +173,7 @@ class __$$HttpRequestModelImplCopyWithImpl<$Res>
|
||||
Object? isParamEnabledList = freezed,
|
||||
Object? bodyContentType = null,
|
||||
Object? body = freezed,
|
||||
Object? query = freezed,
|
||||
Object? formData = freezed,
|
||||
}) {
|
||||
return _then(_$HttpRequestModelImpl(
|
||||
@ -200,6 +209,10 @@ class __$$HttpRequestModelImplCopyWithImpl<$Res>
|
||||
? _value.body
|
||||
: body // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
query: freezed == query
|
||||
? _value.query
|
||||
: query // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
formData: freezed == formData
|
||||
? _value._formData
|
||||
: formData // ignore: cast_nullable_to_non_nullable
|
||||
@ -221,6 +234,7 @@ class _$HttpRequestModelImpl extends _HttpRequestModel {
|
||||
final List<bool>? isParamEnabledList,
|
||||
this.bodyContentType = ContentType.json,
|
||||
this.body,
|
||||
this.query,
|
||||
final List<FormDataModel>? formData})
|
||||
: _headers = headers,
|
||||
_params = params,
|
||||
@ -285,6 +299,8 @@ class _$HttpRequestModelImpl extends _HttpRequestModel {
|
||||
final ContentType bodyContentType;
|
||||
@override
|
||||
final String? body;
|
||||
@override
|
||||
final String? query;
|
||||
final List<FormDataModel>? _formData;
|
||||
@override
|
||||
List<FormDataModel>? get formData {
|
||||
@ -297,7 +313,7 @@ class _$HttpRequestModelImpl extends _HttpRequestModel {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'HttpRequestModel(method: $method, url: $url, headers: $headers, params: $params, isHeaderEnabledList: $isHeaderEnabledList, isParamEnabledList: $isParamEnabledList, bodyContentType: $bodyContentType, body: $body, formData: $formData)';
|
||||
return 'HttpRequestModel(method: $method, url: $url, headers: $headers, params: $params, isHeaderEnabledList: $isHeaderEnabledList, isParamEnabledList: $isParamEnabledList, bodyContentType: $bodyContentType, body: $body, query: $query, formData: $formData)';
|
||||
}
|
||||
|
||||
@override
|
||||
@ -316,6 +332,7 @@ class _$HttpRequestModelImpl extends _HttpRequestModel {
|
||||
(identical(other.bodyContentType, bodyContentType) ||
|
||||
other.bodyContentType == bodyContentType) &&
|
||||
(identical(other.body, body) || other.body == body) &&
|
||||
(identical(other.query, query) || other.query == query) &&
|
||||
const DeepCollectionEquality().equals(other._formData, _formData));
|
||||
}
|
||||
|
||||
@ -331,6 +348,7 @@ class _$HttpRequestModelImpl extends _HttpRequestModel {
|
||||
const DeepCollectionEquality().hash(_isParamEnabledList),
|
||||
bodyContentType,
|
||||
body,
|
||||
query,
|
||||
const DeepCollectionEquality().hash(_formData));
|
||||
|
||||
/// Create a copy of HttpRequestModel
|
||||
@ -360,6 +378,7 @@ abstract class _HttpRequestModel extends HttpRequestModel {
|
||||
final List<bool>? isParamEnabledList,
|
||||
final ContentType bodyContentType,
|
||||
final String? body,
|
||||
final String? query,
|
||||
final List<FormDataModel>? formData}) = _$HttpRequestModelImpl;
|
||||
const _HttpRequestModel._() : super._();
|
||||
|
||||
@ -383,6 +402,8 @@ abstract class _HttpRequestModel extends HttpRequestModel {
|
||||
@override
|
||||
String? get body;
|
||||
@override
|
||||
String? get query;
|
||||
@override
|
||||
List<FormDataModel>? get formData;
|
||||
|
||||
/// Create a copy of HttpRequestModel
|
||||
|
@ -29,6 +29,7 @@ _$HttpRequestModelImpl _$$HttpRequestModelImplFromJson(Map json) =>
|
||||
$enumDecodeNullable(_$ContentTypeEnumMap, json['bodyContentType']) ??
|
||||
ContentType.json,
|
||||
body: json['body'] as String?,
|
||||
query: json['query'] as String?,
|
||||
formData: (json['formData'] as List<dynamic>?)
|
||||
?.map((e) =>
|
||||
FormDataModel.fromJson(Map<String, Object?>.from(e as Map)))
|
||||
@ -46,6 +47,7 @@ Map<String, dynamic> _$$HttpRequestModelImplToJson(
|
||||
'isParamEnabledList': instance.isParamEnabledList,
|
||||
'bodyContentType': _$ContentTypeEnumMap[instance.bodyContentType]!,
|
||||
'body': instance.body,
|
||||
'query': instance.query,
|
||||
'formData': instance.formData?.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user