mirror of
https://github.com/foss42/apidash.git
synced 2025-12-03 03:17:00 +08:00
refactor: move auth models to better_networking package
This commit is contained in:
@@ -9,6 +9,8 @@ enum APIType {
|
||||
final String abbr;
|
||||
}
|
||||
|
||||
enum APIAuthType { none, basic, apiKey, bearer, jwt, digest, oauth1, oauth2}
|
||||
|
||||
enum HTTPVerb {
|
||||
get("GET"),
|
||||
head("HEAD"),
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import '../../consts.dart';
|
||||
import 'auth_api_key_model.dart';
|
||||
import 'auth_basic_model.dart';
|
||||
import 'auth_bearer_model.dart';
|
||||
import 'auth_jwt_model.dart';
|
||||
|
||||
part 'api_auth_model.g.dart';
|
||||
part 'api_auth_model.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class AuthModel with _$AuthModel {
|
||||
@JsonSerializable(
|
||||
explicitToJson: true,
|
||||
anyMap: true,
|
||||
)
|
||||
const factory AuthModel({
|
||||
required APIAuthType type,
|
||||
AuthApiKeyModel? apikey,
|
||||
AuthBearerModel? bearer,
|
||||
AuthBasicAuthModel? basic,
|
||||
AuthJwtModel? jwt,
|
||||
}) = _AuthModel;
|
||||
|
||||
factory AuthModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$AuthModelFromJson(json);
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'api_auth_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
||||
);
|
||||
|
||||
AuthModel _$AuthModelFromJson(Map<String, dynamic> json) {
|
||||
return _AuthModel.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$AuthModel {
|
||||
APIAuthType get type => throw _privateConstructorUsedError;
|
||||
AuthApiKeyModel? get apikey => throw _privateConstructorUsedError;
|
||||
AuthBearerModel? get bearer => throw _privateConstructorUsedError;
|
||||
AuthBasicAuthModel? get basic => throw _privateConstructorUsedError;
|
||||
AuthJwtModel? get jwt => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this AuthModel to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of AuthModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$AuthModelCopyWith<AuthModel> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $AuthModelCopyWith<$Res> {
|
||||
factory $AuthModelCopyWith(AuthModel value, $Res Function(AuthModel) then) =
|
||||
_$AuthModelCopyWithImpl<$Res, AuthModel>;
|
||||
@useResult
|
||||
$Res call({
|
||||
APIAuthType type,
|
||||
AuthApiKeyModel? apikey,
|
||||
AuthBearerModel? bearer,
|
||||
AuthBasicAuthModel? basic,
|
||||
AuthJwtModel? jwt,
|
||||
});
|
||||
|
||||
$AuthApiKeyModelCopyWith<$Res>? get apikey;
|
||||
$AuthBearerModelCopyWith<$Res>? get bearer;
|
||||
$AuthBasicAuthModelCopyWith<$Res>? get basic;
|
||||
$AuthJwtModelCopyWith<$Res>? get jwt;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$AuthModelCopyWithImpl<$Res, $Val extends AuthModel>
|
||||
implements $AuthModelCopyWith<$Res> {
|
||||
_$AuthModelCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of AuthModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? type = null,
|
||||
Object? apikey = freezed,
|
||||
Object? bearer = freezed,
|
||||
Object? basic = freezed,
|
||||
Object? jwt = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
type: null == type
|
||||
? _value.type
|
||||
: type // ignore: cast_nullable_to_non_nullable
|
||||
as APIAuthType,
|
||||
apikey: freezed == apikey
|
||||
? _value.apikey
|
||||
: apikey // ignore: cast_nullable_to_non_nullable
|
||||
as AuthApiKeyModel?,
|
||||
bearer: freezed == bearer
|
||||
? _value.bearer
|
||||
: bearer // ignore: cast_nullable_to_non_nullable
|
||||
as AuthBearerModel?,
|
||||
basic: freezed == basic
|
||||
? _value.basic
|
||||
: basic // ignore: cast_nullable_to_non_nullable
|
||||
as AuthBasicAuthModel?,
|
||||
jwt: freezed == jwt
|
||||
? _value.jwt
|
||||
: jwt // ignore: cast_nullable_to_non_nullable
|
||||
as AuthJwtModel?,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of AuthModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$AuthApiKeyModelCopyWith<$Res>? get apikey {
|
||||
if (_value.apikey == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $AuthApiKeyModelCopyWith<$Res>(_value.apikey!, (value) {
|
||||
return _then(_value.copyWith(apikey: value) as $Val);
|
||||
});
|
||||
}
|
||||
|
||||
/// Create a copy of AuthModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$AuthBearerModelCopyWith<$Res>? get bearer {
|
||||
if (_value.bearer == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $AuthBearerModelCopyWith<$Res>(_value.bearer!, (value) {
|
||||
return _then(_value.copyWith(bearer: value) as $Val);
|
||||
});
|
||||
}
|
||||
|
||||
/// Create a copy of AuthModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$AuthBasicAuthModelCopyWith<$Res>? get basic {
|
||||
if (_value.basic == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $AuthBasicAuthModelCopyWith<$Res>(_value.basic!, (value) {
|
||||
return _then(_value.copyWith(basic: value) as $Val);
|
||||
});
|
||||
}
|
||||
|
||||
/// Create a copy of AuthModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$AuthJwtModelCopyWith<$Res>? get jwt {
|
||||
if (_value.jwt == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $AuthJwtModelCopyWith<$Res>(_value.jwt!, (value) {
|
||||
return _then(_value.copyWith(jwt: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AuthModelImplCopyWith<$Res>
|
||||
implements $AuthModelCopyWith<$Res> {
|
||||
factory _$$AuthModelImplCopyWith(
|
||||
_$AuthModelImpl value,
|
||||
$Res Function(_$AuthModelImpl) then,
|
||||
) = __$$AuthModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
APIAuthType type,
|
||||
AuthApiKeyModel? apikey,
|
||||
AuthBearerModel? bearer,
|
||||
AuthBasicAuthModel? basic,
|
||||
AuthJwtModel? jwt,
|
||||
});
|
||||
|
||||
@override
|
||||
$AuthApiKeyModelCopyWith<$Res>? get apikey;
|
||||
@override
|
||||
$AuthBearerModelCopyWith<$Res>? get bearer;
|
||||
@override
|
||||
$AuthBasicAuthModelCopyWith<$Res>? get basic;
|
||||
@override
|
||||
$AuthJwtModelCopyWith<$Res>? get jwt;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AuthModelImplCopyWithImpl<$Res>
|
||||
extends _$AuthModelCopyWithImpl<$Res, _$AuthModelImpl>
|
||||
implements _$$AuthModelImplCopyWith<$Res> {
|
||||
__$$AuthModelImplCopyWithImpl(
|
||||
_$AuthModelImpl _value,
|
||||
$Res Function(_$AuthModelImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of AuthModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? type = null,
|
||||
Object? apikey = freezed,
|
||||
Object? bearer = freezed,
|
||||
Object? basic = freezed,
|
||||
Object? jwt = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_$AuthModelImpl(
|
||||
type: null == type
|
||||
? _value.type
|
||||
: type // ignore: cast_nullable_to_non_nullable
|
||||
as APIAuthType,
|
||||
apikey: freezed == apikey
|
||||
? _value.apikey
|
||||
: apikey // ignore: cast_nullable_to_non_nullable
|
||||
as AuthApiKeyModel?,
|
||||
bearer: freezed == bearer
|
||||
? _value.bearer
|
||||
: bearer // ignore: cast_nullable_to_non_nullable
|
||||
as AuthBearerModel?,
|
||||
basic: freezed == basic
|
||||
? _value.basic
|
||||
: basic // ignore: cast_nullable_to_non_nullable
|
||||
as AuthBasicAuthModel?,
|
||||
jwt: freezed == jwt
|
||||
? _value.jwt
|
||||
: jwt // ignore: cast_nullable_to_non_nullable
|
||||
as AuthJwtModel?,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
@JsonSerializable(explicitToJson: true, anyMap: true)
|
||||
class _$AuthModelImpl implements _AuthModel {
|
||||
const _$AuthModelImpl({
|
||||
required this.type,
|
||||
this.apikey,
|
||||
this.bearer,
|
||||
this.basic,
|
||||
this.jwt,
|
||||
});
|
||||
|
||||
factory _$AuthModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$AuthModelImplFromJson(json);
|
||||
|
||||
@override
|
||||
final APIAuthType type;
|
||||
@override
|
||||
final AuthApiKeyModel? apikey;
|
||||
@override
|
||||
final AuthBearerModel? bearer;
|
||||
@override
|
||||
final AuthBasicAuthModel? basic;
|
||||
@override
|
||||
final AuthJwtModel? jwt;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AuthModel(type: $type, apikey: $apikey, bearer: $bearer, basic: $basic, jwt: $jwt)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AuthModelImpl &&
|
||||
(identical(other.type, type) || other.type == type) &&
|
||||
(identical(other.apikey, apikey) || other.apikey == apikey) &&
|
||||
(identical(other.bearer, bearer) || other.bearer == bearer) &&
|
||||
(identical(other.basic, basic) || other.basic == basic) &&
|
||||
(identical(other.jwt, jwt) || other.jwt == jwt));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, type, apikey, bearer, basic, jwt);
|
||||
|
||||
/// Create a copy of AuthModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AuthModelImplCopyWith<_$AuthModelImpl> get copyWith =>
|
||||
__$$AuthModelImplCopyWithImpl<_$AuthModelImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$AuthModelImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _AuthModel implements AuthModel {
|
||||
const factory _AuthModel({
|
||||
required final APIAuthType type,
|
||||
final AuthApiKeyModel? apikey,
|
||||
final AuthBearerModel? bearer,
|
||||
final AuthBasicAuthModel? basic,
|
||||
final AuthJwtModel? jwt,
|
||||
}) = _$AuthModelImpl;
|
||||
|
||||
factory _AuthModel.fromJson(Map<String, dynamic> json) =
|
||||
_$AuthModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
APIAuthType get type;
|
||||
@override
|
||||
AuthApiKeyModel? get apikey;
|
||||
@override
|
||||
AuthBearerModel? get bearer;
|
||||
@override
|
||||
AuthBasicAuthModel? get basic;
|
||||
@override
|
||||
AuthJwtModel? get jwt;
|
||||
|
||||
/// Create a copy of AuthModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$AuthModelImplCopyWith<_$AuthModelImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'api_auth_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$AuthModelImpl _$$AuthModelImplFromJson(Map json) => _$AuthModelImpl(
|
||||
type: $enumDecode(_$APIAuthTypeEnumMap, json['type']),
|
||||
apikey: json['apikey'] == null
|
||||
? null
|
||||
: AuthApiKeyModel.fromJson(
|
||||
Map<String, dynamic>.from(json['apikey'] as Map),
|
||||
),
|
||||
bearer: json['bearer'] == null
|
||||
? null
|
||||
: AuthBearerModel.fromJson(
|
||||
Map<String, dynamic>.from(json['bearer'] as Map),
|
||||
),
|
||||
basic: json['basic'] == null
|
||||
? null
|
||||
: AuthBasicAuthModel.fromJson(
|
||||
Map<String, dynamic>.from(json['basic'] as Map),
|
||||
),
|
||||
jwt: json['jwt'] == null
|
||||
? null
|
||||
: AuthJwtModel.fromJson(Map<String, dynamic>.from(json['jwt'] as Map)),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$AuthModelImplToJson(_$AuthModelImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'type': _$APIAuthTypeEnumMap[instance.type]!,
|
||||
'apikey': instance.apikey?.toJson(),
|
||||
'bearer': instance.bearer?.toJson(),
|
||||
'basic': instance.basic?.toJson(),
|
||||
'jwt': instance.jwt?.toJson(),
|
||||
};
|
||||
|
||||
const _$APIAuthTypeEnumMap = {
|
||||
APIAuthType.none: 'none',
|
||||
APIAuthType.basic: 'basic',
|
||||
APIAuthType.apiKey: 'apiKey',
|
||||
APIAuthType.bearer: 'bearer',
|
||||
APIAuthType.jwt: 'jwt',
|
||||
APIAuthType.digest: 'digest',
|
||||
APIAuthType.oauth1: 'oauth1',
|
||||
APIAuthType.oauth2: 'oauth2',
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'auth_api_key_model.g.dart';
|
||||
part 'auth_api_key_model.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class AuthApiKeyModel with _$AuthApiKeyModel {
|
||||
const factory AuthApiKeyModel({
|
||||
required String key,
|
||||
@Default('header') String location, // 'header' or 'query'
|
||||
@Default('x-api-key') String name,
|
||||
}) = _AuthApiKeyModel;
|
||||
|
||||
factory AuthApiKeyModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$AuthApiKeyModelFromJson(json);
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'auth_api_key_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
||||
);
|
||||
|
||||
AuthApiKeyModel _$AuthApiKeyModelFromJson(Map<String, dynamic> json) {
|
||||
return _AuthApiKeyModel.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$AuthApiKeyModel {
|
||||
String get key => throw _privateConstructorUsedError;
|
||||
String get location =>
|
||||
throw _privateConstructorUsedError; // 'header' or 'query'
|
||||
String get name => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this AuthApiKeyModel to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of AuthApiKeyModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$AuthApiKeyModelCopyWith<AuthApiKeyModel> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $AuthApiKeyModelCopyWith<$Res> {
|
||||
factory $AuthApiKeyModelCopyWith(
|
||||
AuthApiKeyModel value,
|
||||
$Res Function(AuthApiKeyModel) then,
|
||||
) = _$AuthApiKeyModelCopyWithImpl<$Res, AuthApiKeyModel>;
|
||||
@useResult
|
||||
$Res call({String key, String location, String name});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$AuthApiKeyModelCopyWithImpl<$Res, $Val extends AuthApiKeyModel>
|
||||
implements $AuthApiKeyModelCopyWith<$Res> {
|
||||
_$AuthApiKeyModelCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of AuthApiKeyModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? key = null,
|
||||
Object? location = null,
|
||||
Object? name = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
key: null == key
|
||||
? _value.key
|
||||
: key // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
location: null == location
|
||||
? _value.location
|
||||
: location // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
name: null == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AuthApiKeyModelImplCopyWith<$Res>
|
||||
implements $AuthApiKeyModelCopyWith<$Res> {
|
||||
factory _$$AuthApiKeyModelImplCopyWith(
|
||||
_$AuthApiKeyModelImpl value,
|
||||
$Res Function(_$AuthApiKeyModelImpl) then,
|
||||
) = __$$AuthApiKeyModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({String key, String location, String name});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AuthApiKeyModelImplCopyWithImpl<$Res>
|
||||
extends _$AuthApiKeyModelCopyWithImpl<$Res, _$AuthApiKeyModelImpl>
|
||||
implements _$$AuthApiKeyModelImplCopyWith<$Res> {
|
||||
__$$AuthApiKeyModelImplCopyWithImpl(
|
||||
_$AuthApiKeyModelImpl _value,
|
||||
$Res Function(_$AuthApiKeyModelImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of AuthApiKeyModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? key = null,
|
||||
Object? location = null,
|
||||
Object? name = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$AuthApiKeyModelImpl(
|
||||
key: null == key
|
||||
? _value.key
|
||||
: key // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
location: null == location
|
||||
? _value.location
|
||||
: location // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
name: null == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$AuthApiKeyModelImpl implements _AuthApiKeyModel {
|
||||
const _$AuthApiKeyModelImpl({
|
||||
required this.key,
|
||||
this.location = 'header',
|
||||
this.name = 'x-api-key',
|
||||
});
|
||||
|
||||
factory _$AuthApiKeyModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$AuthApiKeyModelImplFromJson(json);
|
||||
|
||||
@override
|
||||
final String key;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String location;
|
||||
// 'header' or 'query'
|
||||
@override
|
||||
@JsonKey()
|
||||
final String name;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AuthApiKeyModel(key: $key, location: $location, name: $name)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AuthApiKeyModelImpl &&
|
||||
(identical(other.key, key) || other.key == key) &&
|
||||
(identical(other.location, location) ||
|
||||
other.location == location) &&
|
||||
(identical(other.name, name) || other.name == name));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, key, location, name);
|
||||
|
||||
/// Create a copy of AuthApiKeyModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AuthApiKeyModelImplCopyWith<_$AuthApiKeyModelImpl> get copyWith =>
|
||||
__$$AuthApiKeyModelImplCopyWithImpl<_$AuthApiKeyModelImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$AuthApiKeyModelImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _AuthApiKeyModel implements AuthApiKeyModel {
|
||||
const factory _AuthApiKeyModel({
|
||||
required final String key,
|
||||
final String location,
|
||||
final String name,
|
||||
}) = _$AuthApiKeyModelImpl;
|
||||
|
||||
factory _AuthApiKeyModel.fromJson(Map<String, dynamic> json) =
|
||||
_$AuthApiKeyModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
String get key;
|
||||
@override
|
||||
String get location; // 'header' or 'query'
|
||||
@override
|
||||
String get name;
|
||||
|
||||
/// Create a copy of AuthApiKeyModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$AuthApiKeyModelImplCopyWith<_$AuthApiKeyModelImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'auth_api_key_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$AuthApiKeyModelImpl _$$AuthApiKeyModelImplFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _$AuthApiKeyModelImpl(
|
||||
key: json['key'] as String,
|
||||
location: json['location'] as String? ?? 'header',
|
||||
name: json['name'] as String? ?? 'x-api-key',
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$AuthApiKeyModelImplToJson(
|
||||
_$AuthApiKeyModelImpl instance,
|
||||
) => <String, dynamic>{
|
||||
'key': instance.key,
|
||||
'location': instance.location,
|
||||
'name': instance.name,
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'auth_basic_model.g.dart';
|
||||
part 'auth_basic_model.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class AuthBasicAuthModel with _$AuthBasicAuthModel {
|
||||
const factory AuthBasicAuthModel({
|
||||
required String username,
|
||||
required String password,
|
||||
}) = _AuthBasicAuthModel;
|
||||
|
||||
factory AuthBasicAuthModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$AuthBasicAuthModelFromJson(json);
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'auth_basic_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
||||
);
|
||||
|
||||
AuthBasicAuthModel _$AuthBasicAuthModelFromJson(Map<String, dynamic> json) {
|
||||
return _AuthBasicAuthModel.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$AuthBasicAuthModel {
|
||||
String get username => throw _privateConstructorUsedError;
|
||||
String get password => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this AuthBasicAuthModel to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of AuthBasicAuthModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$AuthBasicAuthModelCopyWith<AuthBasicAuthModel> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $AuthBasicAuthModelCopyWith<$Res> {
|
||||
factory $AuthBasicAuthModelCopyWith(
|
||||
AuthBasicAuthModel value,
|
||||
$Res Function(AuthBasicAuthModel) then,
|
||||
) = _$AuthBasicAuthModelCopyWithImpl<$Res, AuthBasicAuthModel>;
|
||||
@useResult
|
||||
$Res call({String username, String password});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$AuthBasicAuthModelCopyWithImpl<$Res, $Val extends AuthBasicAuthModel>
|
||||
implements $AuthBasicAuthModelCopyWith<$Res> {
|
||||
_$AuthBasicAuthModelCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of AuthBasicAuthModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? username = null, Object? password = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
username: null == username
|
||||
? _value.username
|
||||
: username // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
password: null == password
|
||||
? _value.password
|
||||
: password // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AuthBasicAuthModelImplCopyWith<$Res>
|
||||
implements $AuthBasicAuthModelCopyWith<$Res> {
|
||||
factory _$$AuthBasicAuthModelImplCopyWith(
|
||||
_$AuthBasicAuthModelImpl value,
|
||||
$Res Function(_$AuthBasicAuthModelImpl) then,
|
||||
) = __$$AuthBasicAuthModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({String username, String password});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AuthBasicAuthModelImplCopyWithImpl<$Res>
|
||||
extends _$AuthBasicAuthModelCopyWithImpl<$Res, _$AuthBasicAuthModelImpl>
|
||||
implements _$$AuthBasicAuthModelImplCopyWith<$Res> {
|
||||
__$$AuthBasicAuthModelImplCopyWithImpl(
|
||||
_$AuthBasicAuthModelImpl _value,
|
||||
$Res Function(_$AuthBasicAuthModelImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of AuthBasicAuthModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? username = null, Object? password = null}) {
|
||||
return _then(
|
||||
_$AuthBasicAuthModelImpl(
|
||||
username: null == username
|
||||
? _value.username
|
||||
: username // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
password: null == password
|
||||
? _value.password
|
||||
: password // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$AuthBasicAuthModelImpl implements _AuthBasicAuthModel {
|
||||
const _$AuthBasicAuthModelImpl({
|
||||
required this.username,
|
||||
required this.password,
|
||||
});
|
||||
|
||||
factory _$AuthBasicAuthModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$AuthBasicAuthModelImplFromJson(json);
|
||||
|
||||
@override
|
||||
final String username;
|
||||
@override
|
||||
final String password;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AuthBasicAuthModel(username: $username, password: $password)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AuthBasicAuthModelImpl &&
|
||||
(identical(other.username, username) ||
|
||||
other.username == username) &&
|
||||
(identical(other.password, password) ||
|
||||
other.password == password));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, username, password);
|
||||
|
||||
/// Create a copy of AuthBasicAuthModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AuthBasicAuthModelImplCopyWith<_$AuthBasicAuthModelImpl> get copyWith =>
|
||||
__$$AuthBasicAuthModelImplCopyWithImpl<_$AuthBasicAuthModelImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$AuthBasicAuthModelImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _AuthBasicAuthModel implements AuthBasicAuthModel {
|
||||
const factory _AuthBasicAuthModel({
|
||||
required final String username,
|
||||
required final String password,
|
||||
}) = _$AuthBasicAuthModelImpl;
|
||||
|
||||
factory _AuthBasicAuthModel.fromJson(Map<String, dynamic> json) =
|
||||
_$AuthBasicAuthModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
String get username;
|
||||
@override
|
||||
String get password;
|
||||
|
||||
/// Create a copy of AuthBasicAuthModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$AuthBasicAuthModelImplCopyWith<_$AuthBasicAuthModelImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'auth_basic_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$AuthBasicAuthModelImpl _$$AuthBasicAuthModelImplFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _$AuthBasicAuthModelImpl(
|
||||
username: json['username'] as String,
|
||||
password: json['password'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$AuthBasicAuthModelImplToJson(
|
||||
_$AuthBasicAuthModelImpl instance,
|
||||
) => <String, dynamic>{
|
||||
'username': instance.username,
|
||||
'password': instance.password,
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'auth_bearer_model.g.dart';
|
||||
part 'auth_bearer_model.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class AuthBearerModel with _$AuthBearerModel {
|
||||
const factory AuthBearerModel({
|
||||
required String token,
|
||||
}) = _AuthBearerModel;
|
||||
|
||||
factory AuthBearerModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$AuthBearerModelFromJson(json);
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'auth_bearer_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
||||
);
|
||||
|
||||
AuthBearerModel _$AuthBearerModelFromJson(Map<String, dynamic> json) {
|
||||
return _AuthBearerModel.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$AuthBearerModel {
|
||||
String get token => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this AuthBearerModel to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of AuthBearerModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$AuthBearerModelCopyWith<AuthBearerModel> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $AuthBearerModelCopyWith<$Res> {
|
||||
factory $AuthBearerModelCopyWith(
|
||||
AuthBearerModel value,
|
||||
$Res Function(AuthBearerModel) then,
|
||||
) = _$AuthBearerModelCopyWithImpl<$Res, AuthBearerModel>;
|
||||
@useResult
|
||||
$Res call({String token});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$AuthBearerModelCopyWithImpl<$Res, $Val extends AuthBearerModel>
|
||||
implements $AuthBearerModelCopyWith<$Res> {
|
||||
_$AuthBearerModelCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of AuthBearerModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? token = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
token: null == token
|
||||
? _value.token
|
||||
: token // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AuthBearerModelImplCopyWith<$Res>
|
||||
implements $AuthBearerModelCopyWith<$Res> {
|
||||
factory _$$AuthBearerModelImplCopyWith(
|
||||
_$AuthBearerModelImpl value,
|
||||
$Res Function(_$AuthBearerModelImpl) then,
|
||||
) = __$$AuthBearerModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({String token});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AuthBearerModelImplCopyWithImpl<$Res>
|
||||
extends _$AuthBearerModelCopyWithImpl<$Res, _$AuthBearerModelImpl>
|
||||
implements _$$AuthBearerModelImplCopyWith<$Res> {
|
||||
__$$AuthBearerModelImplCopyWithImpl(
|
||||
_$AuthBearerModelImpl _value,
|
||||
$Res Function(_$AuthBearerModelImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of AuthBearerModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? token = null}) {
|
||||
return _then(
|
||||
_$AuthBearerModelImpl(
|
||||
token: null == token
|
||||
? _value.token
|
||||
: token // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$AuthBearerModelImpl implements _AuthBearerModel {
|
||||
const _$AuthBearerModelImpl({required this.token});
|
||||
|
||||
factory _$AuthBearerModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$AuthBearerModelImplFromJson(json);
|
||||
|
||||
@override
|
||||
final String token;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AuthBearerModel(token: $token)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AuthBearerModelImpl &&
|
||||
(identical(other.token, token) || other.token == token));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, token);
|
||||
|
||||
/// Create a copy of AuthBearerModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AuthBearerModelImplCopyWith<_$AuthBearerModelImpl> get copyWith =>
|
||||
__$$AuthBearerModelImplCopyWithImpl<_$AuthBearerModelImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$AuthBearerModelImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _AuthBearerModel implements AuthBearerModel {
|
||||
const factory _AuthBearerModel({required final String token}) =
|
||||
_$AuthBearerModelImpl;
|
||||
|
||||
factory _AuthBearerModel.fromJson(Map<String, dynamic> json) =
|
||||
_$AuthBearerModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
String get token;
|
||||
|
||||
/// Create a copy of AuthBearerModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$AuthBearerModelImplCopyWith<_$AuthBearerModelImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'auth_bearer_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$AuthBearerModelImpl _$$AuthBearerModelImplFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _$AuthBearerModelImpl(token: json['token'] as String);
|
||||
|
||||
Map<String, dynamic> _$$AuthBearerModelImplToJson(
|
||||
_$AuthBearerModelImpl instance,
|
||||
) => <String, dynamic>{'token': instance.token};
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'auth_jwt_model.freezed.dart';
|
||||
part 'auth_jwt_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class AuthJwtModel with _$AuthJwtModel {
|
||||
const factory AuthJwtModel({
|
||||
required String secret,
|
||||
required String payload,
|
||||
required String addTokenTo,
|
||||
required String algorithm,
|
||||
required bool isSecretBase64Encoded,
|
||||
required String headerPrefix,
|
||||
required String queryParamKey,
|
||||
required String header,
|
||||
}) = _AuthJwtModel;
|
||||
|
||||
factory AuthJwtModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$AuthJwtModelFromJson(json);
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'auth_jwt_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
||||
);
|
||||
|
||||
AuthJwtModel _$AuthJwtModelFromJson(Map<String, dynamic> json) {
|
||||
return _AuthJwtModel.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$AuthJwtModel {
|
||||
String get secret => throw _privateConstructorUsedError;
|
||||
String get payload => throw _privateConstructorUsedError;
|
||||
String get addTokenTo => throw _privateConstructorUsedError;
|
||||
String get algorithm => throw _privateConstructorUsedError;
|
||||
bool get isSecretBase64Encoded => throw _privateConstructorUsedError;
|
||||
String get headerPrefix => throw _privateConstructorUsedError;
|
||||
String get queryParamKey => throw _privateConstructorUsedError;
|
||||
String get header => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this AuthJwtModel to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of AuthJwtModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$AuthJwtModelCopyWith<AuthJwtModel> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $AuthJwtModelCopyWith<$Res> {
|
||||
factory $AuthJwtModelCopyWith(
|
||||
AuthJwtModel value,
|
||||
$Res Function(AuthJwtModel) then,
|
||||
) = _$AuthJwtModelCopyWithImpl<$Res, AuthJwtModel>;
|
||||
@useResult
|
||||
$Res call({
|
||||
String secret,
|
||||
String payload,
|
||||
String addTokenTo,
|
||||
String algorithm,
|
||||
bool isSecretBase64Encoded,
|
||||
String headerPrefix,
|
||||
String queryParamKey,
|
||||
String header,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$AuthJwtModelCopyWithImpl<$Res, $Val extends AuthJwtModel>
|
||||
implements $AuthJwtModelCopyWith<$Res> {
|
||||
_$AuthJwtModelCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of AuthJwtModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? secret = null,
|
||||
Object? payload = null,
|
||||
Object? addTokenTo = null,
|
||||
Object? algorithm = null,
|
||||
Object? isSecretBase64Encoded = null,
|
||||
Object? headerPrefix = null,
|
||||
Object? queryParamKey = null,
|
||||
Object? header = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
secret: null == secret
|
||||
? _value.secret
|
||||
: secret // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
payload: null == payload
|
||||
? _value.payload
|
||||
: payload // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
addTokenTo: null == addTokenTo
|
||||
? _value.addTokenTo
|
||||
: addTokenTo // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
algorithm: null == algorithm
|
||||
? _value.algorithm
|
||||
: algorithm // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
isSecretBase64Encoded: null == isSecretBase64Encoded
|
||||
? _value.isSecretBase64Encoded
|
||||
: isSecretBase64Encoded // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
headerPrefix: null == headerPrefix
|
||||
? _value.headerPrefix
|
||||
: headerPrefix // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
queryParamKey: null == queryParamKey
|
||||
? _value.queryParamKey
|
||||
: queryParamKey // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
header: null == header
|
||||
? _value.header
|
||||
: header // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AuthJwtModelImplCopyWith<$Res>
|
||||
implements $AuthJwtModelCopyWith<$Res> {
|
||||
factory _$$AuthJwtModelImplCopyWith(
|
||||
_$AuthJwtModelImpl value,
|
||||
$Res Function(_$AuthJwtModelImpl) then,
|
||||
) = __$$AuthJwtModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
String secret,
|
||||
String payload,
|
||||
String addTokenTo,
|
||||
String algorithm,
|
||||
bool isSecretBase64Encoded,
|
||||
String headerPrefix,
|
||||
String queryParamKey,
|
||||
String header,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AuthJwtModelImplCopyWithImpl<$Res>
|
||||
extends _$AuthJwtModelCopyWithImpl<$Res, _$AuthJwtModelImpl>
|
||||
implements _$$AuthJwtModelImplCopyWith<$Res> {
|
||||
__$$AuthJwtModelImplCopyWithImpl(
|
||||
_$AuthJwtModelImpl _value,
|
||||
$Res Function(_$AuthJwtModelImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of AuthJwtModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? secret = null,
|
||||
Object? payload = null,
|
||||
Object? addTokenTo = null,
|
||||
Object? algorithm = null,
|
||||
Object? isSecretBase64Encoded = null,
|
||||
Object? headerPrefix = null,
|
||||
Object? queryParamKey = null,
|
||||
Object? header = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$AuthJwtModelImpl(
|
||||
secret: null == secret
|
||||
? _value.secret
|
||||
: secret // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
payload: null == payload
|
||||
? _value.payload
|
||||
: payload // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
addTokenTo: null == addTokenTo
|
||||
? _value.addTokenTo
|
||||
: addTokenTo // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
algorithm: null == algorithm
|
||||
? _value.algorithm
|
||||
: algorithm // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
isSecretBase64Encoded: null == isSecretBase64Encoded
|
||||
? _value.isSecretBase64Encoded
|
||||
: isSecretBase64Encoded // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
headerPrefix: null == headerPrefix
|
||||
? _value.headerPrefix
|
||||
: headerPrefix // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
queryParamKey: null == queryParamKey
|
||||
? _value.queryParamKey
|
||||
: queryParamKey // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
header: null == header
|
||||
? _value.header
|
||||
: header // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$AuthJwtModelImpl implements _AuthJwtModel {
|
||||
const _$AuthJwtModelImpl({
|
||||
required this.secret,
|
||||
required this.payload,
|
||||
required this.addTokenTo,
|
||||
required this.algorithm,
|
||||
required this.isSecretBase64Encoded,
|
||||
required this.headerPrefix,
|
||||
required this.queryParamKey,
|
||||
required this.header,
|
||||
});
|
||||
|
||||
factory _$AuthJwtModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$AuthJwtModelImplFromJson(json);
|
||||
|
||||
@override
|
||||
final String secret;
|
||||
@override
|
||||
final String payload;
|
||||
@override
|
||||
final String addTokenTo;
|
||||
@override
|
||||
final String algorithm;
|
||||
@override
|
||||
final bool isSecretBase64Encoded;
|
||||
@override
|
||||
final String headerPrefix;
|
||||
@override
|
||||
final String queryParamKey;
|
||||
@override
|
||||
final String header;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AuthJwtModel(secret: $secret, payload: $payload, addTokenTo: $addTokenTo, algorithm: $algorithm, isSecretBase64Encoded: $isSecretBase64Encoded, headerPrefix: $headerPrefix, queryParamKey: $queryParamKey, header: $header)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AuthJwtModelImpl &&
|
||||
(identical(other.secret, secret) || other.secret == secret) &&
|
||||
(identical(other.payload, payload) || other.payload == payload) &&
|
||||
(identical(other.addTokenTo, addTokenTo) ||
|
||||
other.addTokenTo == addTokenTo) &&
|
||||
(identical(other.algorithm, algorithm) ||
|
||||
other.algorithm == algorithm) &&
|
||||
(identical(other.isSecretBase64Encoded, isSecretBase64Encoded) ||
|
||||
other.isSecretBase64Encoded == isSecretBase64Encoded) &&
|
||||
(identical(other.headerPrefix, headerPrefix) ||
|
||||
other.headerPrefix == headerPrefix) &&
|
||||
(identical(other.queryParamKey, queryParamKey) ||
|
||||
other.queryParamKey == queryParamKey) &&
|
||||
(identical(other.header, header) || other.header == header));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
secret,
|
||||
payload,
|
||||
addTokenTo,
|
||||
algorithm,
|
||||
isSecretBase64Encoded,
|
||||
headerPrefix,
|
||||
queryParamKey,
|
||||
header,
|
||||
);
|
||||
|
||||
/// Create a copy of AuthJwtModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AuthJwtModelImplCopyWith<_$AuthJwtModelImpl> get copyWith =>
|
||||
__$$AuthJwtModelImplCopyWithImpl<_$AuthJwtModelImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$AuthJwtModelImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _AuthJwtModel implements AuthJwtModel {
|
||||
const factory _AuthJwtModel({
|
||||
required final String secret,
|
||||
required final String payload,
|
||||
required final String addTokenTo,
|
||||
required final String algorithm,
|
||||
required final bool isSecretBase64Encoded,
|
||||
required final String headerPrefix,
|
||||
required final String queryParamKey,
|
||||
required final String header,
|
||||
}) = _$AuthJwtModelImpl;
|
||||
|
||||
factory _AuthJwtModel.fromJson(Map<String, dynamic> json) =
|
||||
_$AuthJwtModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
String get secret;
|
||||
@override
|
||||
String get payload;
|
||||
@override
|
||||
String get addTokenTo;
|
||||
@override
|
||||
String get algorithm;
|
||||
@override
|
||||
bool get isSecretBase64Encoded;
|
||||
@override
|
||||
String get headerPrefix;
|
||||
@override
|
||||
String get queryParamKey;
|
||||
@override
|
||||
String get header;
|
||||
|
||||
/// Create a copy of AuthJwtModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$AuthJwtModelImplCopyWith<_$AuthJwtModelImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'auth_jwt_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$AuthJwtModelImpl _$$AuthJwtModelImplFromJson(Map<String, dynamic> json) =>
|
||||
_$AuthJwtModelImpl(
|
||||
secret: json['secret'] as String,
|
||||
payload: json['payload'] as String,
|
||||
addTokenTo: json['addTokenTo'] as String,
|
||||
algorithm: json['algorithm'] as String,
|
||||
isSecretBase64Encoded: json['isSecretBase64Encoded'] as bool,
|
||||
headerPrefix: json['headerPrefix'] as String,
|
||||
queryParamKey: json['queryParamKey'] as String,
|
||||
header: json['header'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$AuthJwtModelImplToJson(_$AuthJwtModelImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'secret': instance.secret,
|
||||
'payload': instance.payload,
|
||||
'addTokenTo': instance.addTokenTo,
|
||||
'algorithm': instance.algorithm,
|
||||
'isSecretBase64Encoded': instance.isSecretBase64Encoded,
|
||||
'headerPrefix': instance.headerPrefix,
|
||||
'queryParamKey': instance.queryParamKey,
|
||||
'header': instance.header,
|
||||
};
|
||||
@@ -61,17 +61,6 @@ abstract class $HttpRequestModelCopyWith<$Res> {
|
||||
String? query,
|
||||
List<FormDataModel>? formData,
|
||||
});
|
||||
$Res call(
|
||||
{HTTPVerb method,
|
||||
String url,
|
||||
List<NameValueModel>? headers,
|
||||
List<NameValueModel>? params,
|
||||
List<bool>? isHeaderEnabledList,
|
||||
List<bool>? isParamEnabledList,
|
||||
ContentType bodyContentType,
|
||||
String? body,
|
||||
String? query,
|
||||
List<FormDataModel>? formData});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -146,49 +135,6 @@ class _$HttpRequestModelCopyWithImpl<$Res, $Val extends HttpRequestModel>
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
return _then(_value.copyWith(
|
||||
method: null == method
|
||||
? _value.method
|
||||
: method // ignore: cast_nullable_to_non_nullable
|
||||
as HTTPVerb,
|
||||
url: null == url
|
||||
? _value.url
|
||||
: url // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
headers: freezed == headers
|
||||
? _value.headers
|
||||
: headers // ignore: cast_nullable_to_non_nullable
|
||||
as List<NameValueModel>?,
|
||||
params: freezed == params
|
||||
? _value.params
|
||||
: params // ignore: cast_nullable_to_non_nullable
|
||||
as List<NameValueModel>?,
|
||||
isHeaderEnabledList: freezed == isHeaderEnabledList
|
||||
? _value.isHeaderEnabledList
|
||||
: isHeaderEnabledList // ignore: cast_nullable_to_non_nullable
|
||||
as List<bool>?,
|
||||
isParamEnabledList: freezed == isParamEnabledList
|
||||
? _value.isParamEnabledList
|
||||
: isParamEnabledList // ignore: cast_nullable_to_non_nullable
|
||||
as List<bool>?,
|
||||
bodyContentType: null == bodyContentType
|
||||
? _value.bodyContentType
|
||||
: bodyContentType // ignore: cast_nullable_to_non_nullable
|
||||
as ContentType,
|
||||
body: freezed == body
|
||||
? _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
|
||||
as List<FormDataModel>?,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -212,17 +158,6 @@ abstract class _$$HttpRequestModelImplCopyWith<$Res>
|
||||
String? query,
|
||||
List<FormDataModel>? formData,
|
||||
});
|
||||
$Res call(
|
||||
{HTTPVerb method,
|
||||
String url,
|
||||
List<NameValueModel>? headers,
|
||||
List<NameValueModel>? params,
|
||||
List<bool>? isHeaderEnabledList,
|
||||
List<bool>? isParamEnabledList,
|
||||
ContentType bodyContentType,
|
||||
String? body,
|
||||
String? query,
|
||||
List<FormDataModel>? formData});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -294,48 +229,6 @@ class __$$HttpRequestModelImplCopyWithImpl<$Res>
|
||||
as List<FormDataModel>?,
|
||||
),
|
||||
);
|
||||
return _then(_$HttpRequestModelImpl(
|
||||
method: null == method
|
||||
? _value.method
|
||||
: method // ignore: cast_nullable_to_non_nullable
|
||||
as HTTPVerb,
|
||||
url: null == url
|
||||
? _value.url
|
||||
: url // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
headers: freezed == headers
|
||||
? _value._headers
|
||||
: headers // ignore: cast_nullable_to_non_nullable
|
||||
as List<NameValueModel>?,
|
||||
params: freezed == params
|
||||
? _value._params
|
||||
: params // ignore: cast_nullable_to_non_nullable
|
||||
as List<NameValueModel>?,
|
||||
isHeaderEnabledList: freezed == isHeaderEnabledList
|
||||
? _value._isHeaderEnabledList
|
||||
: isHeaderEnabledList // ignore: cast_nullable_to_non_nullable
|
||||
as List<bool>?,
|
||||
isParamEnabledList: freezed == isParamEnabledList
|
||||
? _value._isParamEnabledList
|
||||
: isParamEnabledList // ignore: cast_nullable_to_non_nullable
|
||||
as List<bool>?,
|
||||
bodyContentType: null == bodyContentType
|
||||
? _value.bodyContentType
|
||||
: bodyContentType // ignore: cast_nullable_to_non_nullable
|
||||
as ContentType,
|
||||
body: freezed == body
|
||||
? _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
|
||||
as List<FormDataModel>?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,23 +253,6 @@ class _$HttpRequestModelImpl extends _HttpRequestModel {
|
||||
_isParamEnabledList = isParamEnabledList,
|
||||
_formData = formData,
|
||||
super._();
|
||||
const _$HttpRequestModelImpl(
|
||||
{this.method = HTTPVerb.get,
|
||||
this.url = "",
|
||||
final List<NameValueModel>? headers,
|
||||
final List<NameValueModel>? params,
|
||||
final List<bool>? isHeaderEnabledList,
|
||||
final List<bool>? isParamEnabledList,
|
||||
this.bodyContentType = ContentType.json,
|
||||
this.body,
|
||||
this.query,
|
||||
final List<FormDataModel>? formData})
|
||||
: _headers = headers,
|
||||
_params = params,
|
||||
_isHeaderEnabledList = isHeaderEnabledList,
|
||||
_isParamEnabledList = isParamEnabledList,
|
||||
_formData = formData,
|
||||
super._();
|
||||
|
||||
factory _$HttpRequestModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$HttpRequestModelImplFromJson(json);
|
||||
@@ -449,7 +325,6 @@ 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, isHeaderEnabledList: $isHeaderEnabledList, isParamEnabledList: $isParamEnabledList, bodyContentType: $bodyContentType, body: $body, query: $query, formData: $formData)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -469,10 +344,6 @@ class _$HttpRequestModelImpl extends _HttpRequestModel {
|
||||
other._isParamEnabledList,
|
||||
_isParamEnabledList,
|
||||
) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._isHeaderEnabledList, _isHeaderEnabledList) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._isParamEnabledList, _isParamEnabledList) &&
|
||||
(identical(other.bodyContentType, bodyContentType) ||
|
||||
other.bodyContentType == bodyContentType) &&
|
||||
(identical(other.body, body) || other.body == body) &&
|
||||
@@ -495,17 +366,6 @@ class _$HttpRequestModelImpl extends _HttpRequestModel {
|
||||
query,
|
||||
const DeepCollectionEquality().hash(_formData),
|
||||
);
|
||||
runtimeType,
|
||||
method,
|
||||
url,
|
||||
const DeepCollectionEquality().hash(_headers),
|
||||
const DeepCollectionEquality().hash(_params),
|
||||
const DeepCollectionEquality().hash(_isHeaderEnabledList),
|
||||
const DeepCollectionEquality().hash(_isParamEnabledList),
|
||||
bodyContentType,
|
||||
body,
|
||||
query,
|
||||
const DeepCollectionEquality().hash(_formData));
|
||||
|
||||
/// Create a copy of HttpRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -537,17 +397,6 @@ abstract class _HttpRequestModel extends HttpRequestModel {
|
||||
final String? query,
|
||||
final List<FormDataModel>? formData,
|
||||
}) = _$HttpRequestModelImpl;
|
||||
const factory _HttpRequestModel(
|
||||
{final HTTPVerb method,
|
||||
final String url,
|
||||
final List<NameValueModel>? headers,
|
||||
final List<NameValueModel>? params,
|
||||
final List<bool>? isHeaderEnabledList,
|
||||
final List<bool>? isParamEnabledList,
|
||||
final ContentType bodyContentType,
|
||||
final String? body,
|
||||
final String? query,
|
||||
final List<FormDataModel>? formData}) = _$HttpRequestModelImpl;
|
||||
const _HttpRequestModel._() : super._();
|
||||
|
||||
factory _HttpRequestModel.fromJson(Map<String, dynamic> json) =
|
||||
|
||||
@@ -1,2 +1,7 @@
|
||||
export 'http_request_model.dart';
|
||||
export 'http_response_model.dart';
|
||||
export 'auth/api_auth_model.dart';
|
||||
export 'auth/auth_api_key_model.dart';
|
||||
export 'auth/auth_basic_model.dart';
|
||||
export 'auth/auth_bearer_model.dart';
|
||||
export 'auth/auth_jwt_model.dart';
|
||||
|
||||
@@ -7,7 +7,6 @@ import '../consts.dart';
|
||||
import '../extensions/extensions.dart';
|
||||
import '../models/models.dart';
|
||||
import '../utils/utils.dart';
|
||||
import '../utils/handle_auth.dart';
|
||||
import 'http_client_manager.dart';
|
||||
|
||||
typedef HttpResponse = http.Response;
|
||||
@@ -28,11 +27,7 @@ Future<(HttpResponse?, Duration?, String?)> sendHttpRequest(
|
||||
final client = httpClientManager.createClient(requestId, noSSL: noSSL);
|
||||
|
||||
// Handle authentication
|
||||
<<<<<<< HEAD:packages/better_networking/lib/services/http_service.dart
|
||||
final authenticatedRequestModel = handleAuth(requestModel, authModel);
|
||||
=======
|
||||
final authenticatedRequestModel = handleAuth(requestModel, authData);
|
||||
>>>>>>> f24eb4e6 (feat: remove AuthModel from HttpRequestModel and integrate into HistoryRequestModel and RequestModel):packages/apidash_core/lib/services/http_service.dart
|
||||
|
||||
(Uri?, String?) uriRec = getValidRequestUri(
|
||||
authenticatedRequestModel.url,
|
||||
|
||||
94
packages/better_networking/lib/utils/auth_utils.dart
Normal file
94
packages/better_networking/lib/utils/auth_utils.dart
Normal file
@@ -0,0 +1,94 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
import 'package:better_networking/models/auth/auth_jwt_model.dart';
|
||||
import 'package:crypto/crypto.dart';
|
||||
|
||||
String generateJWT(AuthJwtModel jwtAuth) {
|
||||
try {
|
||||
Map<String, dynamic> header;
|
||||
if (jwtAuth.header.isNotEmpty) {
|
||||
try {
|
||||
header = json.decode(jwtAuth.header) as Map<String, dynamic>;
|
||||
} catch (e) {
|
||||
header = {};
|
||||
}
|
||||
} else {
|
||||
header = {};
|
||||
}
|
||||
header['typ'] = header['typ'] ?? 'JWT';
|
||||
header['alg'] = jwtAuth.algorithm;
|
||||
Map<String, dynamic> payload;
|
||||
if (jwtAuth.payload.isNotEmpty) {
|
||||
try {
|
||||
payload = json.decode(jwtAuth.payload) as Map<String, dynamic>;
|
||||
} catch (e) {
|
||||
payload = {};
|
||||
}
|
||||
} else {
|
||||
payload = {};
|
||||
}
|
||||
if (!payload.containsKey('iat')) {
|
||||
payload['iat'] = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
}
|
||||
|
||||
// Encode header and payload
|
||||
final encodedHeader = _base64UrlEncode(utf8.encode(json.encode(header)));
|
||||
final encodedPayload = _base64UrlEncode(utf8.encode(json.encode(payload)));
|
||||
|
||||
// Create signature
|
||||
final signature = _createSignature(
|
||||
'$encodedHeader.$encodedPayload',
|
||||
jwtAuth.secret,
|
||||
jwtAuth.algorithm,
|
||||
jwtAuth.isSecretBase64Encoded,
|
||||
);
|
||||
|
||||
return '$encodedHeader.$encodedPayload.$signature';
|
||||
} catch (e) {
|
||||
throw Exception('Failed to generate JWT: $e');
|
||||
}
|
||||
}
|
||||
|
||||
String _createSignature(
|
||||
String data, String secret, String algorithm, bool isSecretBase64Encoded) {
|
||||
try {
|
||||
Uint8List secretBytes;
|
||||
if (isSecretBase64Encoded) {
|
||||
secretBytes = base64.decode(secret);
|
||||
} else {
|
||||
secretBytes = utf8.encode(secret);
|
||||
}
|
||||
|
||||
final dataBytes = utf8.encode(data);
|
||||
|
||||
switch (algorithm) {
|
||||
case 'HS256':
|
||||
final hmac = Hmac(sha256, secretBytes);
|
||||
final digest = hmac.convert(dataBytes);
|
||||
return _base64UrlEncode(digest.bytes);
|
||||
|
||||
case 'HS384':
|
||||
final hmac = Hmac(sha384, secretBytes);
|
||||
final digest = hmac.convert(dataBytes);
|
||||
return _base64UrlEncode(digest.bytes);
|
||||
|
||||
case 'HS512':
|
||||
final hmac = Hmac(sha512, secretBytes);
|
||||
final digest = hmac.convert(dataBytes);
|
||||
return _base64UrlEncode(digest.bytes);
|
||||
|
||||
default:
|
||||
// Default to HS256
|
||||
final hmac = Hmac(sha256, secretBytes);
|
||||
final digest = hmac.convert(dataBytes);
|
||||
return _base64UrlEncode(digest.bytes);
|
||||
}
|
||||
} catch (e) {
|
||||
// Return placeholder signature if creation fails
|
||||
return _base64UrlEncode(utf8.encode('signature_generation_failed'));
|
||||
}
|
||||
}
|
||||
|
||||
String _base64UrlEncode(List<int> bytes) {
|
||||
return base64Url.encode(bytes).replaceAll('=', '');
|
||||
}
|
||||
101
packages/better_networking/lib/utils/handle_auth.dart
Normal file
101
packages/better_networking/lib/utils/handle_auth.dart
Normal file
@@ -0,0 +1,101 @@
|
||||
import 'dart:convert';
|
||||
import 'package:better_networking/utils/auth_utils.dart';
|
||||
import 'package:better_networking/better_networking.dart';
|
||||
|
||||
import '../models/auth/api_auth_model.dart';
|
||||
|
||||
HttpRequestModel handleAuth(HttpRequestModel httpRequestModel,AuthModel? authData) {
|
||||
if (authData == null || authData.type == APIAuthType.none) {
|
||||
return httpRequestModel;
|
||||
}
|
||||
|
||||
List<NameValueModel> updatedHeaders =
|
||||
List.from(httpRequestModel.headers ?? []);
|
||||
List<NameValueModel> updatedParams = List.from(httpRequestModel.params ?? []);
|
||||
List<bool> updatedHeaderEnabledList =
|
||||
List.from(httpRequestModel.isHeaderEnabledList ?? []);
|
||||
List<bool> updatedParamEnabledList =
|
||||
List.from(httpRequestModel.isParamEnabledList ?? []);
|
||||
|
||||
switch (authData.type) {
|
||||
case APIAuthType.basic:
|
||||
if (authData.basic != null) {
|
||||
final basicAuth = authData.basic!;
|
||||
final encoded = base64Encode(
|
||||
utf8.encode('${basicAuth.username}:${basicAuth.password}'));
|
||||
updatedHeaders.add(
|
||||
NameValueModel(name: 'Authorization', value: 'Basic $encoded'));
|
||||
updatedHeaderEnabledList.add(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case APIAuthType.bearer:
|
||||
if (authData.bearer != null) {
|
||||
final bearerAuth = authData.bearer!;
|
||||
updatedHeaders.add(NameValueModel(
|
||||
name: 'Authorization', value: 'Bearer ${bearerAuth.token}'));
|
||||
updatedHeaderEnabledList.add(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case APIAuthType.jwt:
|
||||
if (authData.jwt != null) {
|
||||
final jwtAuth = authData.jwt!;
|
||||
|
||||
// Generate JWT token
|
||||
final jwtToken = generateJWT(jwtAuth);
|
||||
|
||||
if (jwtAuth.addTokenTo == 'header') {
|
||||
// Add to request header with prefix
|
||||
final headerValue = jwtAuth.headerPrefix.isNotEmpty
|
||||
? '${jwtAuth.headerPrefix} $jwtToken'
|
||||
: jwtToken;
|
||||
updatedHeaders
|
||||
.add(NameValueModel(name: 'Authorization', value: headerValue));
|
||||
updatedHeaderEnabledList.add(true);
|
||||
} else if (jwtAuth.addTokenTo == 'query') {
|
||||
// Add to query parameters(if selected)
|
||||
final paramKey = jwtAuth.queryParamKey.isNotEmpty
|
||||
? jwtAuth.queryParamKey
|
||||
: 'token';
|
||||
updatedParams.add(NameValueModel(name: paramKey, value: jwtToken));
|
||||
updatedParamEnabledList.add(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case APIAuthType.apiKey:
|
||||
if (authData.apikey != null) {
|
||||
final apiKeyAuth = authData.apikey!;
|
||||
if (apiKeyAuth.location == 'header') {
|
||||
updatedHeaders.add(
|
||||
NameValueModel(name: apiKeyAuth.name, value: apiKeyAuth.key));
|
||||
updatedHeaderEnabledList.add(true);
|
||||
} else if (apiKeyAuth.location == 'query') {
|
||||
updatedParams.add(
|
||||
NameValueModel(name: apiKeyAuth.name, value: apiKeyAuth.key));
|
||||
updatedParamEnabledList.add(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case APIAuthType.none:
|
||||
break;
|
||||
case APIAuthType.digest:
|
||||
// TODO: Handle this case.
|
||||
throw UnimplementedError();
|
||||
case APIAuthType.oauth1:
|
||||
// TODO: Handle this case.
|
||||
throw UnimplementedError();
|
||||
case APIAuthType.oauth2:
|
||||
// TODO: Handle this case.
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
return httpRequestModel.copyWith(
|
||||
headers: updatedHeaders,
|
||||
params: updatedParams,
|
||||
isHeaderEnabledList: updatedHeaderEnabledList,
|
||||
isParamEnabledList: updatedParamEnabledList,
|
||||
);
|
||||
}
|
||||
@@ -4,3 +4,4 @@ export 'http_request_utils.dart';
|
||||
export 'http_response_utils.dart';
|
||||
export 'string_utils.dart' hide RandomStringGenerator;
|
||||
export 'uri_utils.dart';
|
||||
export 'handle_auth.dart';
|
||||
|
||||
Reference in New Issue
Block a user