-
Notifications
You must be signed in to change notification settings - Fork 534
/
Copy pathauthorization_model.dart
80 lines (69 loc) · 2.16 KB
/
authorization_model.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import 'package:apidash/consts.dart';
import 'package:apidash_core/apidash_core.dart';
part 'authorization_model.freezed.dart';
part 'authorization_model.g.dart';
@freezed
class AuthorizationModel with _$AuthorizationModel {
@JsonSerializable(
explicitToJson: true,
anyMap: true,
)
const factory AuthorizationModel({
@Default(AuthType.noauth) AuthType authType,
@Default(false) bool isEnabled,
@Default(BasicAuthModel(username: '', password: '')) BasicAuthModel basicAuthModel,
@Default(BearerAuthModel(token: '')) BearerAuthModel bearerAuthModel,
@Default(ApiKeyAuthModel(key: '', value: '', addTo: AddTo.header)) ApiKeyAuthModel apiKeyAuthModel,
// JWTBearerAuthModel? jwtBearerAuthModel,
// DigestAuthModel? digestAuthModel,
// OAuth1AuthModel? oauth1AuthModel,
// OAuth2AuthModel? oauth2AuthModel,
}) = _AuthorizationModel;
factory AuthorizationModel.fromJson(Map<String, Object?> json) =>
_$AuthorizationModelFromJson(json);
}
@freezed
class BasicAuthModel with _$BasicAuthModel {
@JsonSerializable(
explicitToJson: true,
anyMap: true,
)
const factory BasicAuthModel({
@Default("") String username,
@Default("") String password,
}) = _BasicAuthModel;
factory BasicAuthModel.fromJson(Map<String, Object?> json) =>
_$BasicAuthModelFromJson(json);
}
@freezed
class BearerAuthModel with _$BearerAuthModel {
@JsonSerializable(
explicitToJson: true,
anyMap: true,
)
const factory BearerAuthModel({
@Default("") String token,
}) = _BearerAuthModel;
factory BearerAuthModel.fromJson(Map<String, Object?> json) =>
_$BearerAuthModelFromJson(json);
}
@freezed
class ApiKeyAuthModel with _$ApiKeyAuthModel {
@JsonSerializable(
explicitToJson: true,
anyMap: true,
)
const factory ApiKeyAuthModel({
@Default("") String key,
@Default("") String value,
@Default(AddTo.header) AddTo addTo,
}) = _ApiKeyAuthModel;
factory ApiKeyAuthModel.fromJson(Map<String, Object?> json) =>
_$ApiKeyAuthModelFromJson(json);
}
// @freezed
// class DigestAuthModel with _$DigestAuthModel {
// @JsonSerializable(
// explicitToJson: true,
// anyMap: true,
// )