feat(apps): add auth data models
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
class AuthUser {
|
||||
final String id;
|
||||
final String email;
|
||||
|
||||
const AuthUser({required this.id, required this.email});
|
||||
|
||||
factory AuthUser.fromJson(Map<String, dynamic> json) {
|
||||
return AuthUser(id: json['id'] as String, email: json['email'] as String);
|
||||
}
|
||||
}
|
||||
|
||||
class AuthResponse {
|
||||
final String accessToken;
|
||||
final String refreshToken;
|
||||
final int expiresIn;
|
||||
final String tokenType;
|
||||
final AuthUser user;
|
||||
|
||||
const AuthResponse({
|
||||
required this.accessToken,
|
||||
required this.refreshToken,
|
||||
required this.expiresIn,
|
||||
required this.tokenType,
|
||||
required this.user,
|
||||
});
|
||||
|
||||
factory AuthResponse.fromJson(Map<String, dynamic> json) {
|
||||
return AuthResponse(
|
||||
accessToken: json['access_token'] as String,
|
||||
refreshToken: json['refresh_token'] as String,
|
||||
expiresIn: json['expires_in'] as int,
|
||||
tokenType: json['token_type'] as String,
|
||||
user: AuthUser.fromJson(json['user'] as Map<String, dynamic>),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SignupStartResponse {
|
||||
final String status;
|
||||
final String email;
|
||||
final String message;
|
||||
|
||||
const SignupStartResponse({
|
||||
required this.status,
|
||||
required this.email,
|
||||
required this.message,
|
||||
});
|
||||
|
||||
factory SignupStartResponse.fromJson(Map<String, dynamic> json) {
|
||||
return SignupStartResponse(
|
||||
status: json['status'] as String,
|
||||
email: json['email'] as String,
|
||||
message: json['message'] as String,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
class LoginRequest {
|
||||
final String email;
|
||||
final String password;
|
||||
|
||||
const LoginRequest({required this.email, required this.password});
|
||||
|
||||
Map<String, dynamic> toJson() => {'email': email, 'password': password};
|
||||
}
|
||||
|
||||
class RefreshRequest {
|
||||
final String refreshToken;
|
||||
|
||||
const RefreshRequest({required this.refreshToken});
|
||||
|
||||
Map<String, dynamic> toJson() => {'refresh_token': refreshToken};
|
||||
}
|
||||
|
||||
class LogoutRequest {
|
||||
final String refreshToken;
|
||||
|
||||
const LogoutRequest({required this.refreshToken});
|
||||
|
||||
Map<String, dynamic> toJson() => {'refresh_token': refreshToken};
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
class SignupStartRequest {
|
||||
final String username;
|
||||
final String email;
|
||||
final String password;
|
||||
|
||||
const SignupStartRequest({
|
||||
required this.username,
|
||||
required this.email,
|
||||
required this.password,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'username': username,
|
||||
'email': email,
|
||||
'password': password,
|
||||
};
|
||||
}
|
||||
|
||||
class SignupVerifyRequest {
|
||||
final String email;
|
||||
final String token;
|
||||
|
||||
const SignupVerifyRequest({required this.email, required this.token});
|
||||
|
||||
Map<String, dynamic> toJson() => {'email': email, 'token': token};
|
||||
}
|
||||
|
||||
class SignupResendRequest {
|
||||
final String email;
|
||||
|
||||
const SignupResendRequest({required this.email});
|
||||
|
||||
Map<String, dynamic> toJson() => {'email': email};
|
||||
}
|
||||
Reference in New Issue
Block a user