refactor: move authModel to HttpRequestModel

This commit is contained in:
Udhay-Adithya
2025-07-03 12:12:18 +05:30
parent 4284f47fe6
commit 6c5862cd85
11 changed files with 71 additions and 60 deletions

View File

@@ -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;