mirror of
https://github.com/foss42/apidash.git
synced 2025-12-01 18:28:25 +08:00
refactor: move authModel to HttpRequestModel
This commit is contained in:
@@ -5,6 +5,7 @@ import '../extensions/extensions.dart';
|
||||
import '../utils/utils.dart'
|
||||
show rowsToFormDataMapList, rowsToMap, getEnabledRows;
|
||||
import '../consts.dart';
|
||||
import 'auth/api_auth_model.dart';
|
||||
|
||||
part 'http_request_model.freezed.dart';
|
||||
part 'http_request_model.g.dart';
|
||||
@@ -19,6 +20,7 @@ class HttpRequestModel with _$HttpRequestModel {
|
||||
@Default("") String url,
|
||||
List<NameValueModel>? headers,
|
||||
List<NameValueModel>? params,
|
||||
@Default(AuthModel(type: APIAuthType.none)) AuthModel? authModel,
|
||||
List<bool>? isHeaderEnabledList,
|
||||
List<bool>? isParamEnabledList,
|
||||
@Default(ContentType.json) ContentType bodyContentType,
|
||||
|
||||
@@ -25,6 +25,7 @@ mixin _$HttpRequestModel {
|
||||
String get url => throw _privateConstructorUsedError;
|
||||
List<NameValueModel>? get headers => throw _privateConstructorUsedError;
|
||||
List<NameValueModel>? get params => throw _privateConstructorUsedError;
|
||||
AuthModel? get authModel => throw _privateConstructorUsedError;
|
||||
List<bool>? get isHeaderEnabledList => throw _privateConstructorUsedError;
|
||||
List<bool>? get isParamEnabledList => throw _privateConstructorUsedError;
|
||||
ContentType get bodyContentType => throw _privateConstructorUsedError;
|
||||
@@ -54,6 +55,7 @@ abstract class $HttpRequestModelCopyWith<$Res> {
|
||||
String url,
|
||||
List<NameValueModel>? headers,
|
||||
List<NameValueModel>? params,
|
||||
AuthModel? authModel,
|
||||
List<bool>? isHeaderEnabledList,
|
||||
List<bool>? isParamEnabledList,
|
||||
ContentType bodyContentType,
|
||||
@@ -61,6 +63,8 @@ abstract class $HttpRequestModelCopyWith<$Res> {
|
||||
String? query,
|
||||
List<FormDataModel>? formData,
|
||||
});
|
||||
|
||||
$AuthModelCopyWith<$Res>? get authModel;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -82,6 +86,7 @@ class _$HttpRequestModelCopyWithImpl<$Res, $Val extends HttpRequestModel>
|
||||
Object? url = null,
|
||||
Object? headers = freezed,
|
||||
Object? params = freezed,
|
||||
Object? authModel = freezed,
|
||||
Object? isHeaderEnabledList = freezed,
|
||||
Object? isParamEnabledList = freezed,
|
||||
Object? bodyContentType = null,
|
||||
@@ -107,6 +112,10 @@ class _$HttpRequestModelCopyWithImpl<$Res, $Val extends HttpRequestModel>
|
||||
? _value.params
|
||||
: params // ignore: cast_nullable_to_non_nullable
|
||||
as List<NameValueModel>?,
|
||||
authModel: freezed == authModel
|
||||
? _value.authModel
|
||||
: authModel // ignore: cast_nullable_to_non_nullable
|
||||
as AuthModel?,
|
||||
isHeaderEnabledList: freezed == isHeaderEnabledList
|
||||
? _value.isHeaderEnabledList
|
||||
: isHeaderEnabledList // ignore: cast_nullable_to_non_nullable
|
||||
@@ -135,6 +144,20 @@ class _$HttpRequestModelCopyWithImpl<$Res, $Val extends HttpRequestModel>
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of HttpRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$AuthModelCopyWith<$Res>? get authModel {
|
||||
if (_value.authModel == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $AuthModelCopyWith<$Res>(_value.authModel!, (value) {
|
||||
return _then(_value.copyWith(authModel: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -151,6 +174,7 @@ abstract class _$$HttpRequestModelImplCopyWith<$Res>
|
||||
String url,
|
||||
List<NameValueModel>? headers,
|
||||
List<NameValueModel>? params,
|
||||
AuthModel? authModel,
|
||||
List<bool>? isHeaderEnabledList,
|
||||
List<bool>? isParamEnabledList,
|
||||
ContentType bodyContentType,
|
||||
@@ -158,6 +182,9 @@ abstract class _$$HttpRequestModelImplCopyWith<$Res>
|
||||
String? query,
|
||||
List<FormDataModel>? formData,
|
||||
});
|
||||
|
||||
@override
|
||||
$AuthModelCopyWith<$Res>? get authModel;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -178,6 +205,7 @@ class __$$HttpRequestModelImplCopyWithImpl<$Res>
|
||||
Object? url = null,
|
||||
Object? headers = freezed,
|
||||
Object? params = freezed,
|
||||
Object? authModel = freezed,
|
||||
Object? isHeaderEnabledList = freezed,
|
||||
Object? isParamEnabledList = freezed,
|
||||
Object? bodyContentType = null,
|
||||
@@ -203,6 +231,10 @@ class __$$HttpRequestModelImplCopyWithImpl<$Res>
|
||||
? _value._params
|
||||
: params // ignore: cast_nullable_to_non_nullable
|
||||
as List<NameValueModel>?,
|
||||
authModel: freezed == authModel
|
||||
? _value.authModel
|
||||
: authModel // ignore: cast_nullable_to_non_nullable
|
||||
as AuthModel?,
|
||||
isHeaderEnabledList: freezed == isHeaderEnabledList
|
||||
? _value._isHeaderEnabledList
|
||||
: isHeaderEnabledList // ignore: cast_nullable_to_non_nullable
|
||||
@@ -241,6 +273,7 @@ class _$HttpRequestModelImpl extends _HttpRequestModel {
|
||||
this.url = "",
|
||||
final List<NameValueModel>? headers,
|
||||
final List<NameValueModel>? params,
|
||||
this.authModel = const AuthModel(type: APIAuthType.none),
|
||||
final List<bool>? isHeaderEnabledList,
|
||||
final List<bool>? isParamEnabledList,
|
||||
this.bodyContentType = ContentType.json,
|
||||
@@ -283,6 +316,9 @@ class _$HttpRequestModelImpl extends _HttpRequestModel {
|
||||
return EqualUnmodifiableListView(value);
|
||||
}
|
||||
|
||||
@override
|
||||
@JsonKey()
|
||||
final AuthModel? authModel;
|
||||
final List<bool>? _isHeaderEnabledList;
|
||||
@override
|
||||
List<bool>? get isHeaderEnabledList {
|
||||
@@ -324,7 +360,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, query: $query, formData: $formData)';
|
||||
return 'HttpRequestModel(method: $method, url: $url, headers: $headers, params: $params, authModel: $authModel, isHeaderEnabledList: $isHeaderEnabledList, isParamEnabledList: $isParamEnabledList, bodyContentType: $bodyContentType, body: $body, query: $query, formData: $formData)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -336,6 +372,8 @@ class _$HttpRequestModelImpl extends _HttpRequestModel {
|
||||
(identical(other.url, url) || other.url == url) &&
|
||||
const DeepCollectionEquality().equals(other._headers, _headers) &&
|
||||
const DeepCollectionEquality().equals(other._params, _params) &&
|
||||
(identical(other.authModel, authModel) ||
|
||||
other.authModel == authModel) &&
|
||||
const DeepCollectionEquality().equals(
|
||||
other._isHeaderEnabledList,
|
||||
_isHeaderEnabledList,
|
||||
@@ -359,6 +397,7 @@ class _$HttpRequestModelImpl extends _HttpRequestModel {
|
||||
url,
|
||||
const DeepCollectionEquality().hash(_headers),
|
||||
const DeepCollectionEquality().hash(_params),
|
||||
authModel,
|
||||
const DeepCollectionEquality().hash(_isHeaderEnabledList),
|
||||
const DeepCollectionEquality().hash(_isParamEnabledList),
|
||||
bodyContentType,
|
||||
@@ -390,6 +429,7 @@ abstract class _HttpRequestModel extends HttpRequestModel {
|
||||
final String url,
|
||||
final List<NameValueModel>? headers,
|
||||
final List<NameValueModel>? params,
|
||||
final AuthModel? authModel,
|
||||
final List<bool>? isHeaderEnabledList,
|
||||
final List<bool>? isParamEnabledList,
|
||||
final ContentType bodyContentType,
|
||||
@@ -411,6 +451,8 @@ abstract class _HttpRequestModel extends HttpRequestModel {
|
||||
@override
|
||||
List<NameValueModel>? get params;
|
||||
@override
|
||||
AuthModel? get authModel;
|
||||
@override
|
||||
List<bool>? get isHeaderEnabledList;
|
||||
@override
|
||||
List<bool>? get isParamEnabledList;
|
||||
|
||||
@@ -18,6 +18,9 @@ _$HttpRequestModelImpl _$$HttpRequestModelImplFromJson(
|
||||
params: (json['params'] as List<dynamic>?)
|
||||
?.map((e) => NameValueModel.fromJson(Map<String, Object?>.from(e as Map)))
|
||||
.toList(),
|
||||
authModel: json['authModel'] == null
|
||||
? const AuthModel(type: APIAuthType.none)
|
||||
: AuthModel.fromJson(Map<String, dynamic>.from(json['authModel'] as Map)),
|
||||
isHeaderEnabledList: (json['isHeaderEnabledList'] as List<dynamic>?)
|
||||
?.map((e) => e as bool)
|
||||
.toList(),
|
||||
@@ -41,6 +44,7 @@ Map<String, dynamic> _$$HttpRequestModelImplToJson(
|
||||
'url': instance.url,
|
||||
'headers': instance.headers?.map((e) => e.toJson()).toList(),
|
||||
'params': instance.params?.map((e) => e.toJson()).toList(),
|
||||
'authModel': instance.authModel?.toJson(),
|
||||
'isHeaderEnabledList': instance.isHeaderEnabledList,
|
||||
'isParamEnabledList': instance.isParamEnabledList,
|
||||
'bodyContentType': _$ContentTypeEnumMap[instance.bodyContentType]!,
|
||||
|
||||
Reference in New Issue
Block a user