52 lines
1.7 KiB
Dart
52 lines
1.7 KiB
Dart
|
|
part of '../order_dtos.dart';
|
||
|
|
|
||
|
|
@freezed
|
||
|
|
class PaymentRequestDto with _$PaymentRequestDto {
|
||
|
|
const PaymentRequestDto._();
|
||
|
|
|
||
|
|
const factory PaymentRequestDto({
|
||
|
|
@JsonKey(name: "order_id") String? orderId,
|
||
|
|
@JsonKey(name: "payment_method_id") String? paymentMethodId,
|
||
|
|
@JsonKey(name: "amount") int? amount,
|
||
|
|
@JsonKey(name: "transaction_id") String? transactionId,
|
||
|
|
@JsonKey(name: "split_number") int? splitNumber,
|
||
|
|
@JsonKey(name: "split_total") int? splitTotal,
|
||
|
|
@JsonKey(name: "split_description") String? splitDescription,
|
||
|
|
@JsonKey(name: "payment_order_items")
|
||
|
|
List<PaymentItemRequestDto>? paymentOrderItems,
|
||
|
|
}) = _PaymentRequestDto;
|
||
|
|
|
||
|
|
factory PaymentRequestDto.fromJson(Map<String, dynamic> json) =>
|
||
|
|
_$PaymentRequestDtoFromJson(json);
|
||
|
|
|
||
|
|
// Optional mapper ke domain
|
||
|
|
PaymentRequest toDomain() => PaymentRequest(
|
||
|
|
orderId: orderId ?? '',
|
||
|
|
paymentMethodId: paymentMethodId ?? '',
|
||
|
|
amount: amount ?? 0,
|
||
|
|
transactionId: transactionId ?? '',
|
||
|
|
splitNumber: splitNumber ?? 0,
|
||
|
|
splitTotal: splitTotal ?? 0,
|
||
|
|
splitDescription: splitDescription ?? '',
|
||
|
|
paymentOrderItems:
|
||
|
|
paymentOrderItems?.map((e) => e.toDomain()).toList() ?? const [],
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
@freezed
|
||
|
|
class PaymentItemRequestDto with _$PaymentItemRequestDto {
|
||
|
|
const PaymentItemRequestDto._();
|
||
|
|
|
||
|
|
const factory PaymentItemRequestDto({
|
||
|
|
@JsonKey(name: "order_item_id") String? orderItemId,
|
||
|
|
@JsonKey(name: "amount") int? amount,
|
||
|
|
}) = _PaymentItemRequestDto;
|
||
|
|
|
||
|
|
factory PaymentItemRequestDto.fromJson(Map<String, dynamic> json) =>
|
||
|
|
_$PaymentItemRequestDtoFromJson(json);
|
||
|
|
|
||
|
|
// Optional: mapper ke domain entity
|
||
|
|
PaymentItemRequest toDomain() =>
|
||
|
|
PaymentItemRequest(orderItemId: orderItemId ?? '', amount: amount ?? 0);
|
||
|
|
}
|