40 lines
1.2 KiB
Dart
40 lines
1.2 KiB
Dart
part of '../auth_dtos.dart';
|
|
|
|
@freezed
|
|
class UserDto with _$UserDto {
|
|
const UserDto._();
|
|
|
|
const factory UserDto({
|
|
@JsonKey(name: 'id') String? id,
|
|
@JsonKey(name: 'organization_id') String? organizationId,
|
|
@JsonKey(name: 'outlet_id') String? outletId,
|
|
@JsonKey(name: 'name') String? name,
|
|
@JsonKey(name: 'email') String? email,
|
|
@JsonKey(name: 'role') String? role,
|
|
@JsonKey(name: 'permissions') Map<String, dynamic>? permissions,
|
|
@JsonKey(name: 'is_active') bool? isActive,
|
|
@JsonKey(name: 'created_at') String? createdAt,
|
|
@JsonKey(name: 'updated_at') String? updatedAt,
|
|
}) = _UserDto;
|
|
|
|
factory UserDto.fromJson(Map<String, dynamic> json) =>
|
|
_$UserDtoFromJson(json);
|
|
|
|
User toDomain() => User(
|
|
id: id ?? '',
|
|
organizationId: organizationId ?? '',
|
|
outletId: outletId ?? '',
|
|
name: name ?? '',
|
|
email: email ?? '',
|
|
role: role ?? '',
|
|
permissions: permissions ?? {},
|
|
isActive: isActive ?? false,
|
|
createdAt: createdAt != null
|
|
? DateTime.parse(createdAt ?? "")
|
|
: DateTime.fromMillisecondsSinceEpoch(0),
|
|
updatedAt: updatedAt != null
|
|
? DateTime.parse(updatedAt ?? "")
|
|
: DateTime.fromMillisecondsSinceEpoch(0),
|
|
);
|
|
}
|