add auth register
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user