45 lines
1.4 KiB
Dart
45 lines
1.4 KiB
Dart
|
|
part of '../outlet_dtos.dart';
|
||
|
|
|
||
|
|
@freezed
|
||
|
|
class OutletDto with _$OutletDto {
|
||
|
|
const OutletDto._();
|
||
|
|
|
||
|
|
const factory OutletDto({
|
||
|
|
@JsonKey(name: 'id') String? id,
|
||
|
|
@JsonKey(name: 'organization_id') String? organizationId,
|
||
|
|
@JsonKey(name: 'name') String? name,
|
||
|
|
@JsonKey(name: 'address') String? address,
|
||
|
|
@JsonKey(name: 'phone_number') String? phoneNumber,
|
||
|
|
@JsonKey(name: 'business_type') String? businessType,
|
||
|
|
@JsonKey(name: 'currency') String? currency,
|
||
|
|
@JsonKey(name: 'tax_rate') int? taxRate,
|
||
|
|
@JsonKey(name: 'is_active') bool? isActive,
|
||
|
|
@JsonKey(name: 'created_at') String? createdAt,
|
||
|
|
@JsonKey(name: 'updated_at') String? updatedAt,
|
||
|
|
}) = _OutletDto;
|
||
|
|
|
||
|
|
factory OutletDto.fromJson(Map<String, dynamic> json) =>
|
||
|
|
_$OutletDtoFromJson(json);
|
||
|
|
|
||
|
|
/// Mapper ke domain
|
||
|
|
Outlet toDomain() {
|
||
|
|
return Outlet(
|
||
|
|
id: id ?? '',
|
||
|
|
organizationId: organizationId ?? '',
|
||
|
|
name: name ?? '',
|
||
|
|
address: address ?? '',
|
||
|
|
phoneNumber: phoneNumber ?? '',
|
||
|
|
businessType: businessType ?? '',
|
||
|
|
currency: currency ?? '',
|
||
|
|
taxRate: taxRate ?? 0,
|
||
|
|
isActive: isActive ?? false,
|
||
|
|
createdAt: createdAt != null
|
||
|
|
? DateTime.tryParse(createdAt!) ?? DateTime(1970)
|
||
|
|
: DateTime(1970),
|
||
|
|
updatedAt: updatedAt != null
|
||
|
|
? DateTime.tryParse(updatedAt!) ?? DateTime(1970)
|
||
|
|
: DateTime(1970),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|