86 lines
2.5 KiB
Dart
86 lines
2.5 KiB
Dart
import 'dart:convert';
|
|
|
|
class AuthResponseModel {
|
|
final String? status;
|
|
final String? token;
|
|
final User? user;
|
|
|
|
AuthResponseModel({
|
|
this.status,
|
|
this.token,
|
|
this.user,
|
|
});
|
|
|
|
factory AuthResponseModel.fromJson(String str) => AuthResponseModel.fromMap(json.decode(str));
|
|
|
|
String toJson() => json.encode(toMap());
|
|
|
|
factory AuthResponseModel.fromMap(Map<String, dynamic> json) => AuthResponseModel(
|
|
status: json["status"],
|
|
token: json["token"],
|
|
user: json["user"] == null ? null : User.fromMap(json["user"]),
|
|
);
|
|
|
|
Map<String, dynamic> toMap() => {
|
|
"status": status,
|
|
"token": token,
|
|
"user": user?.toMap(),
|
|
};
|
|
}
|
|
|
|
class User {
|
|
final int? id;
|
|
final String? name;
|
|
final String? email;
|
|
final DateTime? emailVerifiedAt;
|
|
final dynamic twoFactorSecret;
|
|
final dynamic twoFactorRecoveryCodes;
|
|
final dynamic twoFactorConfirmedAt;
|
|
final DateTime? createdAt;
|
|
final DateTime? updatedAt;
|
|
final String? role;
|
|
|
|
User({
|
|
this.id,
|
|
this.name,
|
|
this.email,
|
|
this.emailVerifiedAt,
|
|
this.twoFactorSecret,
|
|
this.twoFactorRecoveryCodes,
|
|
this.twoFactorConfirmedAt,
|
|
this.createdAt,
|
|
this.updatedAt,
|
|
this.role,
|
|
});
|
|
|
|
factory User.fromJson(String str) => User.fromMap(json.decode(str));
|
|
|
|
String toJson() => json.encode(toMap());
|
|
|
|
factory User.fromMap(Map<String, dynamic> json) => User(
|
|
id: json["id"],
|
|
name: json["name"],
|
|
email: json["email"],
|
|
emailVerifiedAt: json["email_verified_at"] == null ? null : DateTime.parse(json["email_verified_at"]),
|
|
twoFactorSecret: json["two_factor_secret"],
|
|
twoFactorRecoveryCodes: json["two_factor_recovery_codes"],
|
|
twoFactorConfirmedAt: json["two_factor_confirmed_at"],
|
|
createdAt: json["created_at"] == null ? null : DateTime.parse(json["created_at"]),
|
|
updatedAt: json["updated_at"] == null ? null : DateTime.parse(json["updated_at"]),
|
|
role: json["role"],
|
|
);
|
|
|
|
Map<String, dynamic> toMap() => {
|
|
"id": id,
|
|
"name": name,
|
|
"email": email,
|
|
"email_verified_at": emailVerifiedAt?.toIso8601String(),
|
|
"two_factor_secret": twoFactorSecret,
|
|
"two_factor_recovery_codes": twoFactorRecoveryCodes,
|
|
"two_factor_confirmed_at": twoFactorConfirmedAt,
|
|
"created_at": createdAt?.toIso8601String(),
|
|
"updated_at": updatedAt?.toIso8601String(),
|
|
"role": role,
|
|
};
|
|
}
|