feat: sync auth to new api
This commit is contained in:
@@ -1,85 +1,83 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class AuthResponseModel {
|
||||
final String? status;
|
||||
final String? token;
|
||||
final User? user;
|
||||
final String? token;
|
||||
final User? user;
|
||||
|
||||
AuthResponseModel({
|
||||
this.status,
|
||||
this.token,
|
||||
this.user,
|
||||
});
|
||||
AuthResponseModel({
|
||||
this.token,
|
||||
this.user,
|
||||
});
|
||||
|
||||
factory AuthResponseModel.fromJson(String str) => AuthResponseModel.fromMap(json.decode(str));
|
||||
factory AuthResponseModel.fromJson(String str) =>
|
||||
AuthResponseModel.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory AuthResponseModel.fromMap(Map<String, dynamic> json) => AuthResponseModel(
|
||||
status: json["status"],
|
||||
factory AuthResponseModel.fromMap(Map<String, dynamic> json) =>
|
||||
AuthResponseModel(
|
||||
token: json["token"],
|
||||
user: json["user"] == null ? null : User.fromMap(json["user"]),
|
||||
);
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"status": status,
|
||||
Map<String, dynamic> toMap() => {
|
||||
"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;
|
||||
final String? id;
|
||||
final String? organizationId;
|
||||
final String? outletId;
|
||||
final String? name;
|
||||
final String? email;
|
||||
final String? role;
|
||||
final bool? isActive;
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
User({
|
||||
this.id,
|
||||
this.name,
|
||||
this.email,
|
||||
this.emailVerifiedAt,
|
||||
this.twoFactorSecret,
|
||||
this.twoFactorRecoveryCodes,
|
||||
this.twoFactorConfirmedAt,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.role,
|
||||
});
|
||||
User({
|
||||
this.id,
|
||||
this.organizationId,
|
||||
this.outletId,
|
||||
this.name,
|
||||
this.role,
|
||||
this.isActive,
|
||||
this.email,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
factory User.fromJson(String str) => User.fromMap(json.decode(str));
|
||||
factory User.fromJson(String str) => User.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory User.fromMap(Map<String, dynamic> json) => User(
|
||||
factory User.fromMap(Map<String, dynamic> json) => User(
|
||||
id: json["id"],
|
||||
organizationId: json["organization_id"],
|
||||
outletId: json["outlet_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"],
|
||||
);
|
||||
isActive: json["is_active"],
|
||||
createdAt: json["created_at"] == null
|
||||
? null
|
||||
: DateTime.parse(json["created_at"]),
|
||||
updatedAt: json["updated_at"] == null
|
||||
? null
|
||||
: DateTime.parse(json["updated_at"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
Map<String, dynamic> toMap() => {
|
||||
"id": id,
|
||||
"organization_id": organizationId,
|
||||
"outlet_id": outletId,
|
||||
"name": name,
|
||||
"email": email,
|
||||
"email_verified_at": emailVerifiedAt?.toIso8601String(),
|
||||
"two_factor_secret": twoFactorSecret,
|
||||
"two_factor_recovery_codes": twoFactorRecoveryCodes,
|
||||
"two_factor_confirmed_at": twoFactorConfirmedAt,
|
||||
"role": role,
|
||||
"is_active": isActive,
|
||||
"created_at": createdAt?.toIso8601String(),
|
||||
"updated_at": updatedAt?.toIso8601String(),
|
||||
"role": role,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user