add auth register

This commit is contained in:
Phuoc Nguyen
2025-11-07 15:55:02 +07:00
parent ce7396f729
commit 9e55983d82
16 changed files with 2376 additions and 110 deletions

View File

@@ -57,6 +57,48 @@ sealed class AuthSessionResponse with _$AuthSessionResponse {
_$AuthSessionResponseFromJson(json);
}
/// Session Data (for GET SESSION API)
///
/// Represents the session data structure from get_session API.
@freezed
sealed class GetSessionData with _$GetSessionData {
const factory GetSessionData({
required String sid,
@JsonKey(name: 'csrf_token') required String csrfToken,
}) = _GetSessionData;
factory GetSessionData.fromJson(Map<String, dynamic> json) =>
_$GetSessionDataFromJson(json);
}
/// Get Session Message
///
/// Wrapper for session data in get_session API response.
@freezed
sealed class GetSessionMessage with _$GetSessionMessage {
const factory GetSessionMessage({
required GetSessionData data,
}) = _GetSessionMessage;
factory GetSessionMessage.fromJson(Map<String, dynamic> json) =>
_$GetSessionMessageFromJson(json);
}
/// Get Session Response
///
/// Complete response from get_session API.
@freezed
sealed class GetSessionResponse with _$GetSessionResponse {
const factory GetSessionResponse({
required GetSessionMessage message,
@JsonKey(name: 'home_page') required String homePage,
@JsonKey(name: 'full_name') required String fullName,
}) = _GetSessionResponse;
factory GetSessionResponse.fromJson(Map<String, dynamic> json) =>
_$GetSessionResponseFromJson(json);
}
/// Session Storage Model
///
/// Simplified model for storing session data in Hive.
@@ -73,7 +115,17 @@ sealed class SessionData with _$SessionData {
factory SessionData.fromJson(Map<String, dynamic> json) =>
_$SessionDataFromJson(json);
/// Create from API response
/// Create from get_session API response
factory SessionData.fromGetSessionResponse(GetSessionResponse response) {
return SessionData(
sid: response.message.data.sid,
csrfToken: response.message.data.csrfToken,
fullName: response.fullName,
createdAt: DateTime.now(),
);
}
/// Create from auth login API response
factory SessionData.fromAuthResponse(AuthSessionResponse response) {
return SessionData(
sid: response.message.sid,