From 137f3d96366d25f2ef0a8b21e16b23b8e71e7f1a Mon Sep 17 00:00:00 2001 From: efrilm Date: Tue, 28 Oct 2025 00:58:39 +0700 Subject: [PATCH] create order with payment --- .../order/order_form/order_form_bloc.dart | 40 + .../order_form/order_form_bloc.freezed.dart | 429 ++++- .../order/order_form/order_form_event.dart | 6 + .../order/order_form/order_form_state.dart | 9 +- lib/common/url/api_path.dart | 1 + lib/domain/order/entities/order_entity.dart | 39 +- lib/domain/order/entities/payment_entity.dart | 38 + .../entities/payment_request_entity.dart | 37 + lib/domain/order/order.dart | 2 + lib/domain/order/order.freezed.dart | 1354 +++++++++----- .../repositories/i_order_repository.dart | 5 + .../datasources/remote_data_provider.dart | 68 + lib/infrastructure/order/dtos/order_dto.dart | 45 +- .../order/dtos/payment_dto.dart | 44 + .../order/dtos/payment_request_dto.dart | 51 + lib/infrastructure/order/order_dtos.dart | 2 + .../order/order_dtos.freezed.dart | 1584 +++++++++++------ lib/infrastructure/order/order_dtos.g.dart | 120 +- .../order/repositories/order_repository.dart | 23 + .../order/widgets/order_list_payment.dart | 4 +- 20 files changed, 2815 insertions(+), 1086 deletions(-) create mode 100644 lib/domain/order/entities/payment_entity.dart create mode 100644 lib/domain/order/entities/payment_request_entity.dart create mode 100644 lib/infrastructure/order/dtos/payment_dto.dart create mode 100644 lib/infrastructure/order/dtos/payment_request_dto.dart diff --git a/lib/application/order/order_form/order_form_bloc.dart b/lib/application/order/order_form/order_form_bloc.dart index 865bf94..a5ce553 100644 --- a/lib/application/order/order_form/order_form_bloc.dart +++ b/lib/application/order/order_form/order_form_bloc.dart @@ -66,6 +66,46 @@ class OrderFormBloc extends Bloc { .toList(), ); + failureOrOrder = await _repository.createOrderWithPayment( + request: request, + paymentMethodId: state.paymentMethod?.id ?? '', + ); + + emit( + state.copyWith( + isCreating: false, + failureOrCreateOrder: optionOf(failureOrOrder), + ), + ); + }, + createOrder: (e) async { + Either failureOrOrder; + + emit(state.copyWith(isCreating: true, failureOrCreateOrder: none())); + + final outlet = await _outletRepository.currentOutlet(); + + final request = OrderRequest( + outletId: outlet.id, + customerId: state.customer?.id ?? '', + tableNumber: e.table?.tableName ?? '', + tableId: e.table?.id ?? '', + orderType: e.orderType.name, + notes: '', + customerName: state.customerName ?? "", + orderItems: e.items + .map( + (item) => OrderItemRequest( + productId: item.product.id, + productVariantId: item.variant?.id ?? "", + quantity: item.quantity, + unitPrice: item.product.price.toInt(), + notes: item.notes, + ), + ) + .toList(), + ); + failureOrOrder = await _repository.createOrder(request: request); emit( diff --git a/lib/application/order/order_form/order_form_bloc.freezed.dart b/lib/application/order/order_form/order_form_bloc.freezed.dart index d9431d5..bb36fa6 100644 --- a/lib/application/order/order_form/order_form_bloc.freezed.dart +++ b/lib/application/order/order_form/order_form_bloc.freezed.dart @@ -28,6 +28,12 @@ mixin _$OrderFormEvent { Table? table, ) createOrderWithPayment, + required TResult Function( + List items, + OrderType orderType, + Table? table, + ) + createOrder, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult? whenOrNull({ @@ -40,6 +46,12 @@ mixin _$OrderFormEvent { Table? table, )? createOrderWithPayment, + TResult? Function( + List items, + OrderType orderType, + Table? table, + )? + createOrder, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult maybeWhen({ @@ -52,6 +64,12 @@ mixin _$OrderFormEvent { Table? table, )? createOrderWithPayment, + TResult Function( + List items, + OrderType orderType, + Table? table, + )? + createOrder, required TResult orElse(), }) => throw _privateConstructorUsedError; @optionalTypeArgs @@ -61,6 +79,7 @@ mixin _$OrderFormEvent { required TResult Function(_CustomerChanged value) customerChanged, required TResult Function(_CreateOrderWithPayment value) createOrderWithPayment, + required TResult Function(_CreateOrder value) createOrder, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult? mapOrNull({ @@ -68,6 +87,7 @@ mixin _$OrderFormEvent { TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged, TResult? Function(_CustomerChanged value)? customerChanged, TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment, + TResult? Function(_CreateOrder value)? createOrder, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult maybeMap({ @@ -75,6 +95,7 @@ mixin _$OrderFormEvent { TResult Function(_PaymentMethodChanged value)? paymentMethodChanged, TResult Function(_CustomerChanged value)? customerChanged, TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment, + TResult Function(_CreateOrder value)? createOrder, required TResult orElse(), }) => throw _privateConstructorUsedError; } @@ -194,6 +215,12 @@ class _$CustomerNameChangedImpl Table? table, ) createOrderWithPayment, + required TResult Function( + List items, + OrderType orderType, + Table? table, + ) + createOrder, }) { return customerNameChanged(customerName); } @@ -210,6 +237,12 @@ class _$CustomerNameChangedImpl Table? table, )? createOrderWithPayment, + TResult? Function( + List items, + OrderType orderType, + Table? table, + )? + createOrder, }) { return customerNameChanged?.call(customerName); } @@ -226,6 +259,12 @@ class _$CustomerNameChangedImpl Table? table, )? createOrderWithPayment, + TResult Function( + List items, + OrderType orderType, + Table? table, + )? + createOrder, required TResult orElse(), }) { if (customerNameChanged != null) { @@ -242,6 +281,7 @@ class _$CustomerNameChangedImpl required TResult Function(_CustomerChanged value) customerChanged, required TResult Function(_CreateOrderWithPayment value) createOrderWithPayment, + required TResult Function(_CreateOrder value) createOrder, }) { return customerNameChanged(this); } @@ -253,6 +293,7 @@ class _$CustomerNameChangedImpl TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged, TResult? Function(_CustomerChanged value)? customerChanged, TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment, + TResult? Function(_CreateOrder value)? createOrder, }) { return customerNameChanged?.call(this); } @@ -264,6 +305,7 @@ class _$CustomerNameChangedImpl TResult Function(_PaymentMethodChanged value)? paymentMethodChanged, TResult Function(_CustomerChanged value)? customerChanged, TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment, + TResult Function(_CreateOrder value)? createOrder, required TResult orElse(), }) { if (customerNameChanged != null) { @@ -391,6 +433,12 @@ class _$PaymentMethodChangedImpl Table? table, ) createOrderWithPayment, + required TResult Function( + List items, + OrderType orderType, + Table? table, + ) + createOrder, }) { return paymentMethodChanged(payment); } @@ -407,6 +455,12 @@ class _$PaymentMethodChangedImpl Table? table, )? createOrderWithPayment, + TResult? Function( + List items, + OrderType orderType, + Table? table, + )? + createOrder, }) { return paymentMethodChanged?.call(payment); } @@ -423,6 +477,12 @@ class _$PaymentMethodChangedImpl Table? table, )? createOrderWithPayment, + TResult Function( + List items, + OrderType orderType, + Table? table, + )? + createOrder, required TResult orElse(), }) { if (paymentMethodChanged != null) { @@ -439,6 +499,7 @@ class _$PaymentMethodChangedImpl required TResult Function(_CustomerChanged value) customerChanged, required TResult Function(_CreateOrderWithPayment value) createOrderWithPayment, + required TResult Function(_CreateOrder value) createOrder, }) { return paymentMethodChanged(this); } @@ -450,6 +511,7 @@ class _$PaymentMethodChangedImpl TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged, TResult? Function(_CustomerChanged value)? customerChanged, TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment, + TResult? Function(_CreateOrder value)? createOrder, }) { return paymentMethodChanged?.call(this); } @@ -461,6 +523,7 @@ class _$PaymentMethodChangedImpl TResult Function(_PaymentMethodChanged value)? paymentMethodChanged, TResult Function(_CustomerChanged value)? customerChanged, TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment, + TResult Function(_CreateOrder value)? createOrder, required TResult orElse(), }) { if (paymentMethodChanged != null) { @@ -592,6 +655,12 @@ class _$CustomerChangedImpl Table? table, ) createOrderWithPayment, + required TResult Function( + List items, + OrderType orderType, + Table? table, + ) + createOrder, }) { return customerChanged(customer); } @@ -608,6 +677,12 @@ class _$CustomerChangedImpl Table? table, )? createOrderWithPayment, + TResult? Function( + List items, + OrderType orderType, + Table? table, + )? + createOrder, }) { return customerChanged?.call(customer); } @@ -624,6 +699,12 @@ class _$CustomerChangedImpl Table? table, )? createOrderWithPayment, + TResult Function( + List items, + OrderType orderType, + Table? table, + )? + createOrder, required TResult orElse(), }) { if (customerChanged != null) { @@ -640,6 +721,7 @@ class _$CustomerChangedImpl required TResult Function(_CustomerChanged value) customerChanged, required TResult Function(_CreateOrderWithPayment value) createOrderWithPayment, + required TResult Function(_CreateOrder value) createOrder, }) { return customerChanged(this); } @@ -651,6 +733,7 @@ class _$CustomerChangedImpl TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged, TResult? Function(_CustomerChanged value)? customerChanged, TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment, + TResult? Function(_CreateOrder value)? createOrder, }) { return customerChanged?.call(this); } @@ -662,6 +745,7 @@ class _$CustomerChangedImpl TResult Function(_PaymentMethodChanged value)? paymentMethodChanged, TResult Function(_CustomerChanged value)? customerChanged, TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment, + TResult Function(_CreateOrder value)? createOrder, required TResult orElse(), }) { if (customerChanged != null) { @@ -831,6 +915,12 @@ class _$CreateOrderWithPaymentImpl Table? table, ) createOrderWithPayment, + required TResult Function( + List items, + OrderType orderType, + Table? table, + ) + createOrder, }) { return createOrderWithPayment(items, orderType, table); } @@ -847,6 +937,12 @@ class _$CreateOrderWithPaymentImpl Table? table, )? createOrderWithPayment, + TResult? Function( + List items, + OrderType orderType, + Table? table, + )? + createOrder, }) { return createOrderWithPayment?.call(items, orderType, table); } @@ -863,6 +959,12 @@ class _$CreateOrderWithPaymentImpl Table? table, )? createOrderWithPayment, + TResult Function( + List items, + OrderType orderType, + Table? table, + )? + createOrder, required TResult orElse(), }) { if (createOrderWithPayment != null) { @@ -879,6 +981,7 @@ class _$CreateOrderWithPaymentImpl required TResult Function(_CustomerChanged value) customerChanged, required TResult Function(_CreateOrderWithPayment value) createOrderWithPayment, + required TResult Function(_CreateOrder value) createOrder, }) { return createOrderWithPayment(this); } @@ -890,6 +993,7 @@ class _$CreateOrderWithPaymentImpl TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged, TResult? Function(_CustomerChanged value)? customerChanged, TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment, + TResult? Function(_CreateOrder value)? createOrder, }) { return createOrderWithPayment?.call(this); } @@ -901,6 +1005,7 @@ class _$CreateOrderWithPaymentImpl TResult Function(_PaymentMethodChanged value)? paymentMethodChanged, TResult Function(_CustomerChanged value)? customerChanged, TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment, + TResult Function(_CreateOrder value)? createOrder, required TResult orElse(), }) { if (createOrderWithPayment != null) { @@ -928,6 +1033,263 @@ abstract class _CreateOrderWithPayment implements OrderFormEvent { get copyWith => throw _privateConstructorUsedError; } +/// @nodoc +abstract class _$$CreateOrderImplCopyWith<$Res> { + factory _$$CreateOrderImplCopyWith( + _$CreateOrderImpl value, + $Res Function(_$CreateOrderImpl) then, + ) = __$$CreateOrderImplCopyWithImpl<$Res>; + @useResult + $Res call({List items, OrderType orderType, Table? table}); + + $TableCopyWith<$Res>? get table; +} + +/// @nodoc +class __$$CreateOrderImplCopyWithImpl<$Res> + extends _$OrderFormEventCopyWithImpl<$Res, _$CreateOrderImpl> + implements _$$CreateOrderImplCopyWith<$Res> { + __$$CreateOrderImplCopyWithImpl( + _$CreateOrderImpl _value, + $Res Function(_$CreateOrderImpl) _then, + ) : super(_value, _then); + + /// Create a copy of OrderFormEvent + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? items = null, + Object? orderType = null, + Object? table = freezed, + }) { + return _then( + _$CreateOrderImpl( + items: null == items + ? _value._items + : items // ignore: cast_nullable_to_non_nullable + as List, + orderType: null == orderType + ? _value.orderType + : orderType // ignore: cast_nullable_to_non_nullable + as OrderType, + table: freezed == table + ? _value.table + : table // ignore: cast_nullable_to_non_nullable + as Table?, + ), + ); + } + + /// Create a copy of OrderFormEvent + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $TableCopyWith<$Res>? get table { + if (_value.table == null) { + return null; + } + + return $TableCopyWith<$Res>(_value.table!, (value) { + return _then(_value.copyWith(table: value)); + }); + } +} + +/// @nodoc + +class _$CreateOrderImpl with DiagnosticableTreeMixin implements _CreateOrder { + const _$CreateOrderImpl({ + required final List items, + required this.orderType, + this.table, + }) : _items = items; + + final List _items; + @override + List get items { + if (_items is EqualUnmodifiableListView) return _items; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_items); + } + + @override + final OrderType orderType; + @override + final Table? table; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { + return 'OrderFormEvent.createOrder(items: $items, orderType: $orderType, table: $table)'; + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty('type', 'OrderFormEvent.createOrder')) + ..add(DiagnosticsProperty('items', items)) + ..add(DiagnosticsProperty('orderType', orderType)) + ..add(DiagnosticsProperty('table', table)); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CreateOrderImpl && + const DeepCollectionEquality().equals(other._items, _items) && + (identical(other.orderType, orderType) || + other.orderType == orderType) && + (identical(other.table, table) || other.table == table)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_items), + orderType, + table, + ); + + /// Create a copy of OrderFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$CreateOrderImplCopyWith<_$CreateOrderImpl> get copyWith => + __$$CreateOrderImplCopyWithImpl<_$CreateOrderImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String customerName) customerNameChanged, + required TResult Function(PaymentMethod payment) paymentMethodChanged, + required TResult Function(Customer? customer) customerChanged, + required TResult Function( + List items, + OrderType orderType, + Table? table, + ) + createOrderWithPayment, + required TResult Function( + List items, + OrderType orderType, + Table? table, + ) + createOrder, + }) { + return createOrder(items, orderType, table); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String customerName)? customerNameChanged, + TResult? Function(PaymentMethod payment)? paymentMethodChanged, + TResult? Function(Customer? customer)? customerChanged, + TResult? Function( + List items, + OrderType orderType, + Table? table, + )? + createOrderWithPayment, + TResult? Function( + List items, + OrderType orderType, + Table? table, + )? + createOrder, + }) { + return createOrder?.call(items, orderType, table); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String customerName)? customerNameChanged, + TResult Function(PaymentMethod payment)? paymentMethodChanged, + TResult Function(Customer? customer)? customerChanged, + TResult Function( + List items, + OrderType orderType, + Table? table, + )? + createOrderWithPayment, + TResult Function( + List items, + OrderType orderType, + Table? table, + )? + createOrder, + required TResult orElse(), + }) { + if (createOrder != null) { + return createOrder(items, orderType, table); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_CustomerNameChanged value) customerNameChanged, + required TResult Function(_PaymentMethodChanged value) paymentMethodChanged, + required TResult Function(_CustomerChanged value) customerChanged, + required TResult Function(_CreateOrderWithPayment value) + createOrderWithPayment, + required TResult Function(_CreateOrder value) createOrder, + }) { + return createOrder(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_CustomerNameChanged value)? customerNameChanged, + TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged, + TResult? Function(_CustomerChanged value)? customerChanged, + TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment, + TResult? Function(_CreateOrder value)? createOrder, + }) { + return createOrder?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_CustomerNameChanged value)? customerNameChanged, + TResult Function(_PaymentMethodChanged value)? paymentMethodChanged, + TResult Function(_CustomerChanged value)? customerChanged, + TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment, + TResult Function(_CreateOrder value)? createOrder, + required TResult orElse(), + }) { + if (createOrder != null) { + return createOrder(this); + } + return orElse(); + } +} + +abstract class _CreateOrder implements OrderFormEvent { + const factory _CreateOrder({ + required final List items, + required final OrderType orderType, + final Table? table, + }) = _$CreateOrderImpl; + + List get items; + OrderType get orderType; + Table? get table; + + /// Create a copy of OrderFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$CreateOrderImplCopyWith<_$CreateOrderImpl> get copyWith => + throw _privateConstructorUsedError; +} + /// @nodoc mixin _$OrderFormState { PaymentMethod? get paymentMethod => throw _privateConstructorUsedError; @@ -935,7 +1297,10 @@ mixin _$OrderFormState { Customer? get customer => throw _privateConstructorUsedError; Option> get failureOrCreateOrder => throw _privateConstructorUsedError; + Option> get failureOrCreateOrderWithPayment => + throw _privateConstructorUsedError; bool get isCreating => throw _privateConstructorUsedError; + bool get isCreatingWithPayment => throw _privateConstructorUsedError; /// Create a copy of OrderFormState /// with the given fields replaced by the non-null parameter values. @@ -956,7 +1321,9 @@ abstract class $OrderFormStateCopyWith<$Res> { String? customerName, Customer? customer, Option> failureOrCreateOrder, + Option> failureOrCreateOrderWithPayment, bool isCreating, + bool isCreatingWithPayment, }); $PaymentMethodCopyWith<$Res>? get paymentMethod; @@ -982,7 +1349,9 @@ class _$OrderFormStateCopyWithImpl<$Res, $Val extends OrderFormState> Object? customerName = freezed, Object? customer = freezed, Object? failureOrCreateOrder = null, + Object? failureOrCreateOrderWithPayment = null, Object? isCreating = null, + Object? isCreatingWithPayment = null, }) { return _then( _value.copyWith( @@ -1002,10 +1371,19 @@ class _$OrderFormStateCopyWithImpl<$Res, $Val extends OrderFormState> ? _value.failureOrCreateOrder : failureOrCreateOrder // ignore: cast_nullable_to_non_nullable as Option>, + failureOrCreateOrderWithPayment: + null == failureOrCreateOrderWithPayment + ? _value.failureOrCreateOrderWithPayment + : failureOrCreateOrderWithPayment // ignore: cast_nullable_to_non_nullable + as Option>, isCreating: null == isCreating ? _value.isCreating : isCreating // ignore: cast_nullable_to_non_nullable as bool, + isCreatingWithPayment: null == isCreatingWithPayment + ? _value.isCreatingWithPayment + : isCreatingWithPayment // ignore: cast_nullable_to_non_nullable + as bool, ) as $Val, ); @@ -1054,7 +1432,9 @@ abstract class _$$OrderFormStateImplCopyWith<$Res> String? customerName, Customer? customer, Option> failureOrCreateOrder, + Option> failureOrCreateOrderWithPayment, bool isCreating, + bool isCreatingWithPayment, }); @override @@ -1081,7 +1461,9 @@ class __$$OrderFormStateImplCopyWithImpl<$Res> Object? customerName = freezed, Object? customer = freezed, Object? failureOrCreateOrder = null, + Object? failureOrCreateOrderWithPayment = null, Object? isCreating = null, + Object? isCreatingWithPayment = null, }) { return _then( _$OrderFormStateImpl( @@ -1101,10 +1483,18 @@ class __$$OrderFormStateImplCopyWithImpl<$Res> ? _value.failureOrCreateOrder : failureOrCreateOrder // ignore: cast_nullable_to_non_nullable as Option>, + failureOrCreateOrderWithPayment: null == failureOrCreateOrderWithPayment + ? _value.failureOrCreateOrderWithPayment + : failureOrCreateOrderWithPayment // ignore: cast_nullable_to_non_nullable + as Option>, isCreating: null == isCreating ? _value.isCreating : isCreating // ignore: cast_nullable_to_non_nullable as bool, + isCreatingWithPayment: null == isCreatingWithPayment + ? _value.isCreatingWithPayment + : isCreatingWithPayment // ignore: cast_nullable_to_non_nullable + as bool, ), ); } @@ -1120,7 +1510,9 @@ class _$OrderFormStateImpl this.customerName, this.customer, required this.failureOrCreateOrder, + required this.failureOrCreateOrderWithPayment, this.isCreating = false, + this.isCreatingWithPayment = false, }); @override @@ -1132,12 +1524,17 @@ class _$OrderFormStateImpl @override final Option> failureOrCreateOrder; @override + final Option> failureOrCreateOrderWithPayment; + @override @JsonKey() final bool isCreating; + @override + @JsonKey() + final bool isCreatingWithPayment; @override String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { - return 'OrderFormState(paymentMethod: $paymentMethod, customerName: $customerName, customer: $customer, failureOrCreateOrder: $failureOrCreateOrder, isCreating: $isCreating)'; + return 'OrderFormState(paymentMethod: $paymentMethod, customerName: $customerName, customer: $customer, failureOrCreateOrder: $failureOrCreateOrder, failureOrCreateOrderWithPayment: $failureOrCreateOrderWithPayment, isCreating: $isCreating, isCreatingWithPayment: $isCreatingWithPayment)'; } @override @@ -1149,7 +1546,16 @@ class _$OrderFormStateImpl ..add(DiagnosticsProperty('customerName', customerName)) ..add(DiagnosticsProperty('customer', customer)) ..add(DiagnosticsProperty('failureOrCreateOrder', failureOrCreateOrder)) - ..add(DiagnosticsProperty('isCreating', isCreating)); + ..add( + DiagnosticsProperty( + 'failureOrCreateOrderWithPayment', + failureOrCreateOrderWithPayment, + ), + ) + ..add(DiagnosticsProperty('isCreating', isCreating)) + ..add( + DiagnosticsProperty('isCreatingWithPayment', isCreatingWithPayment), + ); } @override @@ -1165,8 +1571,16 @@ class _$OrderFormStateImpl other.customer == customer) && (identical(other.failureOrCreateOrder, failureOrCreateOrder) || other.failureOrCreateOrder == failureOrCreateOrder) && + (identical( + other.failureOrCreateOrderWithPayment, + failureOrCreateOrderWithPayment, + ) || + other.failureOrCreateOrderWithPayment == + failureOrCreateOrderWithPayment) && (identical(other.isCreating, isCreating) || - other.isCreating == isCreating)); + other.isCreating == isCreating) && + (identical(other.isCreatingWithPayment, isCreatingWithPayment) || + other.isCreatingWithPayment == isCreatingWithPayment)); } @override @@ -1176,7 +1590,9 @@ class _$OrderFormStateImpl customerName, customer, failureOrCreateOrder, + failureOrCreateOrderWithPayment, isCreating, + isCreatingWithPayment, ); /// Create a copy of OrderFormState @@ -1197,7 +1613,10 @@ abstract class _OrderFormState implements OrderFormState { final String? customerName, final Customer? customer, required final Option> failureOrCreateOrder, + required final Option> + failureOrCreateOrderWithPayment, final bool isCreating, + final bool isCreatingWithPayment, }) = _$OrderFormStateImpl; @override @@ -1209,7 +1628,11 @@ abstract class _OrderFormState implements OrderFormState { @override Option> get failureOrCreateOrder; @override + Option> get failureOrCreateOrderWithPayment; + @override bool get isCreating; + @override + bool get isCreatingWithPayment; /// Create a copy of OrderFormState /// with the given fields replaced by the non-null parameter values. diff --git a/lib/application/order/order_form/order_form_event.dart b/lib/application/order/order_form/order_form_event.dart index 9a99352..d500c76 100644 --- a/lib/application/order/order_form/order_form_event.dart +++ b/lib/application/order/order_form/order_form_event.dart @@ -13,4 +13,10 @@ class OrderFormEvent with _$OrderFormEvent { required OrderType orderType, Table? table, }) = _CreateOrderWithPayment; + + const factory OrderFormEvent.createOrder({ + required List items, + required OrderType orderType, + Table? table, + }) = _CreateOrder; } diff --git a/lib/application/order/order_form/order_form_state.dart b/lib/application/order/order_form/order_form_state.dart index 486b874..a3fb4e4 100644 --- a/lib/application/order/order_form/order_form_state.dart +++ b/lib/application/order/order_form/order_form_state.dart @@ -7,9 +7,14 @@ class OrderFormState with _$OrderFormState { String? customerName, Customer? customer, required Option> failureOrCreateOrder, + required Option> + failureOrCreateOrderWithPayment, @Default(false) bool isCreating, + @Default(false) bool isCreatingWithPayment, }) = _OrderFormState; - factory OrderFormState.initial() => - OrderFormState(failureOrCreateOrder: none()); + factory OrderFormState.initial() => OrderFormState( + failureOrCreateOrder: none(), + failureOrCreateOrderWithPayment: none(), + ); } diff --git a/lib/common/url/api_path.dart b/lib/common/url/api_path.dart index fc0bfd7..fec0c50 100644 --- a/lib/common/url/api_path.dart +++ b/lib/common/url/api_path.dart @@ -7,4 +7,5 @@ class ApiPath { static const String customers = '/api/v1/customers'; static const String paymentMethods = '/api/v1/payment-methods'; static const String orders = '/api/v1/orders'; + static const String payments = '/api/v1/payments'; } diff --git a/lib/domain/order/entities/order_entity.dart b/lib/domain/order/entities/order_entity.dart index 79f1d5f..cc8468f 100644 --- a/lib/domain/order/entities/order_entity.dart +++ b/lib/domain/order/entities/order_entity.dart @@ -39,7 +39,7 @@ class Order with _$Order { required DateTime createdAt, required DateTime updatedAt, required List orderItems, - required List payments, + required List payments, required int totalPaid, required int paymentCount, required String splitType, @@ -115,40 +115,3 @@ class OrderItem with _$OrderItem { paidQuantity: 0, ); } - -@freezed -class PaymentOrder with _$PaymentOrder { - const factory PaymentOrder({ - required String id, - required String orderId, - required String paymentMethodId, - required String paymentMethodName, - required String paymentMethodType, - required int amount, - required String status, - required int splitNumber, - required int splitTotal, - required String splitDescription, - required int refundAmount, - required Map metadata, - required DateTime createdAt, - required DateTime updatedAt, - }) = _PaymentOrder; - - factory PaymentOrder.empty() => PaymentOrder( - id: '', - orderId: '', - paymentMethodId: '', - paymentMethodName: '', - paymentMethodType: '', - amount: 0, - status: '', - splitNumber: 0, - splitTotal: 0, - splitDescription: '', - refundAmount: 0, - metadata: const {}, - createdAt: DateTime(1970), - updatedAt: DateTime(1970), - ); -} diff --git a/lib/domain/order/entities/payment_entity.dart b/lib/domain/order/entities/payment_entity.dart new file mode 100644 index 0000000..203dfe0 --- /dev/null +++ b/lib/domain/order/entities/payment_entity.dart @@ -0,0 +1,38 @@ +part of '../order.dart'; + +@freezed +class Payment with _$Payment { + const factory Payment({ + required String id, + required String orderId, + required String paymentMethodId, + required String paymentMethodName, + required String paymentMethodType, + required int amount, + required String status, + required int splitNumber, + required int splitTotal, + required String splitDescription, + required int refundAmount, + required Map metadata, + required DateTime createdAt, + required DateTime updatedAt, + }) = _Payment; + + factory Payment.empty() => Payment( + id: '', + orderId: '', + paymentMethodId: '', + paymentMethodName: '', + paymentMethodType: '', + amount: 0, + status: '', + splitNumber: 0, + splitTotal: 0, + splitDescription: '', + refundAmount: 0, + metadata: const {}, + createdAt: DateTime(1970), + updatedAt: DateTime(1970), + ); +} diff --git a/lib/domain/order/entities/payment_request_entity.dart b/lib/domain/order/entities/payment_request_entity.dart new file mode 100644 index 0000000..909f8ba --- /dev/null +++ b/lib/domain/order/entities/payment_request_entity.dart @@ -0,0 +1,37 @@ +part of '../order.dart'; + +@freezed +class PaymentRequest with _$PaymentRequest { + const factory PaymentRequest({ + required String orderId, + required String paymentMethodId, + required int amount, + required String transactionId, + required int splitNumber, + required int splitTotal, + required String splitDescription, + required List paymentOrderItems, + }) = _PaymentRequest; + + factory PaymentRequest.empty() => const PaymentRequest( + orderId: '', + paymentMethodId: '', + amount: 0, + transactionId: '', + splitNumber: 0, + splitTotal: 0, + splitDescription: '', + paymentOrderItems: [], + ); +} + +@freezed +class PaymentItemRequest with _$PaymentItemRequest { + const factory PaymentItemRequest({ + required String orderItemId, + required int amount, + }) = _PaymentItemRequest; + + factory PaymentItemRequest.empty() => + const PaymentItemRequest(orderItemId: '', amount: 0); +} diff --git a/lib/domain/order/order.dart b/lib/domain/order/order.dart index ac3239b..92464db 100644 --- a/lib/domain/order/order.dart +++ b/lib/domain/order/order.dart @@ -7,5 +7,7 @@ part 'order.freezed.dart'; part 'entities/order_entity.dart'; part 'entities/order_request_entity.dart'; +part 'entities/payment_request_entity.dart'; +part 'entities/payment_entity.dart'; part 'failures/order_failure.dart'; part 'repositories/i_order_repository.dart'; diff --git a/lib/domain/order/order.freezed.dart b/lib/domain/order/order.freezed.dart index fe6e87e..37fefe8 100644 --- a/lib/domain/order/order.freezed.dart +++ b/lib/domain/order/order.freezed.dart @@ -276,7 +276,7 @@ mixin _$Order { DateTime get createdAt => throw _privateConstructorUsedError; DateTime get updatedAt => throw _privateConstructorUsedError; List get orderItems => throw _privateConstructorUsedError; - List get payments => throw _privateConstructorUsedError; + List get payments => throw _privateConstructorUsedError; int get totalPaid => throw _privateConstructorUsedError; int get paymentCount => throw _privateConstructorUsedError; String get splitType => throw _privateConstructorUsedError; @@ -315,7 +315,7 @@ abstract class $OrderCopyWith<$Res> { DateTime createdAt, DateTime updatedAt, List orderItems, - List payments, + List payments, int totalPaid, int paymentCount, String splitType, @@ -457,7 +457,7 @@ class _$OrderCopyWithImpl<$Res, $Val extends Order> payments: null == payments ? _value.payments : payments // ignore: cast_nullable_to_non_nullable - as List, + as List, totalPaid: null == totalPaid ? _value.totalPaid : totalPaid // ignore: cast_nullable_to_non_nullable @@ -507,7 +507,7 @@ abstract class _$$OrderImplCopyWith<$Res> implements $OrderCopyWith<$Res> { DateTime createdAt, DateTime updatedAt, List orderItems, - List payments, + List payments, int totalPaid, int paymentCount, String splitType, @@ -648,7 +648,7 @@ class __$$OrderImplCopyWithImpl<$Res> payments: null == payments ? _value._payments : payments // ignore: cast_nullable_to_non_nullable - as List, + as List, totalPaid: null == totalPaid ? _value.totalPaid : totalPaid // ignore: cast_nullable_to_non_nullable @@ -692,7 +692,7 @@ class _$OrderImpl implements _Order { required this.createdAt, required this.updatedAt, required final List orderItems, - required final List payments, + required final List payments, required this.totalPaid, required this.paymentCount, required this.splitType, @@ -756,9 +756,9 @@ class _$OrderImpl implements _Order { return EqualUnmodifiableListView(_orderItems); } - final List _payments; + final List _payments; @override - List get payments { + List get payments { if (_payments is EqualUnmodifiableListView) return _payments; // ignore: implicit_dynamic_type return EqualUnmodifiableListView(_payments); @@ -894,7 +894,7 @@ abstract class _Order implements Order { required final DateTime createdAt, required final DateTime updatedAt, required final List orderItems, - required final List payments, + required final List payments, required final int totalPaid, required final int paymentCount, required final String splitType, @@ -945,7 +945,7 @@ abstract class _Order implements Order { @override List get orderItems; @override - List get payments; + List get payments; @override int get totalPaid; @override @@ -1441,441 +1441,6 @@ abstract class _OrderItem implements OrderItem { throw _privateConstructorUsedError; } -/// @nodoc -mixin _$PaymentOrder { - String get id => throw _privateConstructorUsedError; - String get orderId => throw _privateConstructorUsedError; - String get paymentMethodId => throw _privateConstructorUsedError; - String get paymentMethodName => throw _privateConstructorUsedError; - String get paymentMethodType => throw _privateConstructorUsedError; - int get amount => throw _privateConstructorUsedError; - String get status => throw _privateConstructorUsedError; - int get splitNumber => throw _privateConstructorUsedError; - int get splitTotal => throw _privateConstructorUsedError; - String get splitDescription => throw _privateConstructorUsedError; - int get refundAmount => throw _privateConstructorUsedError; - Map get metadata => throw _privateConstructorUsedError; - DateTime get createdAt => throw _privateConstructorUsedError; - DateTime get updatedAt => throw _privateConstructorUsedError; - - /// Create a copy of PaymentOrder - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $PaymentOrderCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $PaymentOrderCopyWith<$Res> { - factory $PaymentOrderCopyWith( - PaymentOrder value, - $Res Function(PaymentOrder) then, - ) = _$PaymentOrderCopyWithImpl<$Res, PaymentOrder>; - @useResult - $Res call({ - String id, - String orderId, - String paymentMethodId, - String paymentMethodName, - String paymentMethodType, - int amount, - String status, - int splitNumber, - int splitTotal, - String splitDescription, - int refundAmount, - Map metadata, - DateTime createdAt, - DateTime updatedAt, - }); -} - -/// @nodoc -class _$PaymentOrderCopyWithImpl<$Res, $Val extends PaymentOrder> - implements $PaymentOrderCopyWith<$Res> { - _$PaymentOrderCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of PaymentOrder - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? orderId = null, - Object? paymentMethodId = null, - Object? paymentMethodName = null, - Object? paymentMethodType = null, - Object? amount = null, - Object? status = null, - Object? splitNumber = null, - Object? splitTotal = null, - Object? splitDescription = null, - Object? refundAmount = null, - Object? metadata = null, - Object? createdAt = null, - Object? updatedAt = null, - }) { - return _then( - _value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String, - orderId: null == orderId - ? _value.orderId - : orderId // ignore: cast_nullable_to_non_nullable - as String, - paymentMethodId: null == paymentMethodId - ? _value.paymentMethodId - : paymentMethodId // ignore: cast_nullable_to_non_nullable - as String, - paymentMethodName: null == paymentMethodName - ? _value.paymentMethodName - : paymentMethodName // ignore: cast_nullable_to_non_nullable - as String, - paymentMethodType: null == paymentMethodType - ? _value.paymentMethodType - : paymentMethodType // ignore: cast_nullable_to_non_nullable - as String, - amount: null == amount - ? _value.amount - : amount // ignore: cast_nullable_to_non_nullable - as int, - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String, - splitNumber: null == splitNumber - ? _value.splitNumber - : splitNumber // ignore: cast_nullable_to_non_nullable - as int, - splitTotal: null == splitTotal - ? _value.splitTotal - : splitTotal // ignore: cast_nullable_to_non_nullable - as int, - splitDescription: null == splitDescription - ? _value.splitDescription - : splitDescription // ignore: cast_nullable_to_non_nullable - as String, - refundAmount: null == refundAmount - ? _value.refundAmount - : refundAmount // ignore: cast_nullable_to_non_nullable - as int, - metadata: null == metadata - ? _value.metadata - : metadata // ignore: cast_nullable_to_non_nullable - as Map, - createdAt: null == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as DateTime, - updatedAt: null == updatedAt - ? _value.updatedAt - : updatedAt // ignore: cast_nullable_to_non_nullable - as DateTime, - ) - as $Val, - ); - } -} - -/// @nodoc -abstract class _$$PaymentOrderImplCopyWith<$Res> - implements $PaymentOrderCopyWith<$Res> { - factory _$$PaymentOrderImplCopyWith( - _$PaymentOrderImpl value, - $Res Function(_$PaymentOrderImpl) then, - ) = __$$PaymentOrderImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String id, - String orderId, - String paymentMethodId, - String paymentMethodName, - String paymentMethodType, - int amount, - String status, - int splitNumber, - int splitTotal, - String splitDescription, - int refundAmount, - Map metadata, - DateTime createdAt, - DateTime updatedAt, - }); -} - -/// @nodoc -class __$$PaymentOrderImplCopyWithImpl<$Res> - extends _$PaymentOrderCopyWithImpl<$Res, _$PaymentOrderImpl> - implements _$$PaymentOrderImplCopyWith<$Res> { - __$$PaymentOrderImplCopyWithImpl( - _$PaymentOrderImpl _value, - $Res Function(_$PaymentOrderImpl) _then, - ) : super(_value, _then); - - /// Create a copy of PaymentOrder - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? orderId = null, - Object? paymentMethodId = null, - Object? paymentMethodName = null, - Object? paymentMethodType = null, - Object? amount = null, - Object? status = null, - Object? splitNumber = null, - Object? splitTotal = null, - Object? splitDescription = null, - Object? refundAmount = null, - Object? metadata = null, - Object? createdAt = null, - Object? updatedAt = null, - }) { - return _then( - _$PaymentOrderImpl( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String, - orderId: null == orderId - ? _value.orderId - : orderId // ignore: cast_nullable_to_non_nullable - as String, - paymentMethodId: null == paymentMethodId - ? _value.paymentMethodId - : paymentMethodId // ignore: cast_nullable_to_non_nullable - as String, - paymentMethodName: null == paymentMethodName - ? _value.paymentMethodName - : paymentMethodName // ignore: cast_nullable_to_non_nullable - as String, - paymentMethodType: null == paymentMethodType - ? _value.paymentMethodType - : paymentMethodType // ignore: cast_nullable_to_non_nullable - as String, - amount: null == amount - ? _value.amount - : amount // ignore: cast_nullable_to_non_nullable - as int, - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String, - splitNumber: null == splitNumber - ? _value.splitNumber - : splitNumber // ignore: cast_nullable_to_non_nullable - as int, - splitTotal: null == splitTotal - ? _value.splitTotal - : splitTotal // ignore: cast_nullable_to_non_nullable - as int, - splitDescription: null == splitDescription - ? _value.splitDescription - : splitDescription // ignore: cast_nullable_to_non_nullable - as String, - refundAmount: null == refundAmount - ? _value.refundAmount - : refundAmount // ignore: cast_nullable_to_non_nullable - as int, - metadata: null == metadata - ? _value._metadata - : metadata // ignore: cast_nullable_to_non_nullable - as Map, - createdAt: null == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as DateTime, - updatedAt: null == updatedAt - ? _value.updatedAt - : updatedAt // ignore: cast_nullable_to_non_nullable - as DateTime, - ), - ); - } -} - -/// @nodoc - -class _$PaymentOrderImpl implements _PaymentOrder { - const _$PaymentOrderImpl({ - required this.id, - required this.orderId, - required this.paymentMethodId, - required this.paymentMethodName, - required this.paymentMethodType, - required this.amount, - required this.status, - required this.splitNumber, - required this.splitTotal, - required this.splitDescription, - required this.refundAmount, - required final Map metadata, - required this.createdAt, - required this.updatedAt, - }) : _metadata = metadata; - - @override - final String id; - @override - final String orderId; - @override - final String paymentMethodId; - @override - final String paymentMethodName; - @override - final String paymentMethodType; - @override - final int amount; - @override - final String status; - @override - final int splitNumber; - @override - final int splitTotal; - @override - final String splitDescription; - @override - final int refundAmount; - final Map _metadata; - @override - Map get metadata { - if (_metadata is EqualUnmodifiableMapView) return _metadata; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(_metadata); - } - - @override - final DateTime createdAt; - @override - final DateTime updatedAt; - - @override - String toString() { - return 'PaymentOrder(id: $id, orderId: $orderId, paymentMethodId: $paymentMethodId, paymentMethodName: $paymentMethodName, paymentMethodType: $paymentMethodType, amount: $amount, status: $status, splitNumber: $splitNumber, splitTotal: $splitTotal, splitDescription: $splitDescription, refundAmount: $refundAmount, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PaymentOrderImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.orderId, orderId) || other.orderId == orderId) && - (identical(other.paymentMethodId, paymentMethodId) || - other.paymentMethodId == paymentMethodId) && - (identical(other.paymentMethodName, paymentMethodName) || - other.paymentMethodName == paymentMethodName) && - (identical(other.paymentMethodType, paymentMethodType) || - other.paymentMethodType == paymentMethodType) && - (identical(other.amount, amount) || other.amount == amount) && - (identical(other.status, status) || other.status == status) && - (identical(other.splitNumber, splitNumber) || - other.splitNumber == splitNumber) && - (identical(other.splitTotal, splitTotal) || - other.splitTotal == splitTotal) && - (identical(other.splitDescription, splitDescription) || - other.splitDescription == splitDescription) && - (identical(other.refundAmount, refundAmount) || - other.refundAmount == refundAmount) && - const DeepCollectionEquality().equals(other._metadata, _metadata) && - (identical(other.createdAt, createdAt) || - other.createdAt == createdAt) && - (identical(other.updatedAt, updatedAt) || - other.updatedAt == updatedAt)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - id, - orderId, - paymentMethodId, - paymentMethodName, - paymentMethodType, - amount, - status, - splitNumber, - splitTotal, - splitDescription, - refundAmount, - const DeepCollectionEquality().hash(_metadata), - createdAt, - updatedAt, - ); - - /// Create a copy of PaymentOrder - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PaymentOrderImplCopyWith<_$PaymentOrderImpl> get copyWith => - __$$PaymentOrderImplCopyWithImpl<_$PaymentOrderImpl>(this, _$identity); -} - -abstract class _PaymentOrder implements PaymentOrder { - const factory _PaymentOrder({ - required final String id, - required final String orderId, - required final String paymentMethodId, - required final String paymentMethodName, - required final String paymentMethodType, - required final int amount, - required final String status, - required final int splitNumber, - required final int splitTotal, - required final String splitDescription, - required final int refundAmount, - required final Map metadata, - required final DateTime createdAt, - required final DateTime updatedAt, - }) = _$PaymentOrderImpl; - - @override - String get id; - @override - String get orderId; - @override - String get paymentMethodId; - @override - String get paymentMethodName; - @override - String get paymentMethodType; - @override - int get amount; - @override - String get status; - @override - int get splitNumber; - @override - int get splitTotal; - @override - String get splitDescription; - @override - int get refundAmount; - @override - Map get metadata; - @override - DateTime get createdAt; - @override - DateTime get updatedAt; - - /// Create a copy of PaymentOrder - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PaymentOrderImplCopyWith<_$PaymentOrderImpl> get copyWith => - throw _privateConstructorUsedError; -} - /// @nodoc mixin _$OrderRequest { String get outletId => throw _privateConstructorUsedError; @@ -2422,6 +1987,905 @@ abstract class _OrderItemRequest implements OrderItemRequest { throw _privateConstructorUsedError; } +/// @nodoc +mixin _$PaymentRequest { + String get orderId => throw _privateConstructorUsedError; + String get paymentMethodId => throw _privateConstructorUsedError; + int get amount => throw _privateConstructorUsedError; + String get transactionId => throw _privateConstructorUsedError; + int get splitNumber => throw _privateConstructorUsedError; + int get splitTotal => throw _privateConstructorUsedError; + String get splitDescription => throw _privateConstructorUsedError; + List get paymentOrderItems => + throw _privateConstructorUsedError; + + /// Create a copy of PaymentRequest + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PaymentRequestCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PaymentRequestCopyWith<$Res> { + factory $PaymentRequestCopyWith( + PaymentRequest value, + $Res Function(PaymentRequest) then, + ) = _$PaymentRequestCopyWithImpl<$Res, PaymentRequest>; + @useResult + $Res call({ + String orderId, + String paymentMethodId, + int amount, + String transactionId, + int splitNumber, + int splitTotal, + String splitDescription, + List paymentOrderItems, + }); +} + +/// @nodoc +class _$PaymentRequestCopyWithImpl<$Res, $Val extends PaymentRequest> + implements $PaymentRequestCopyWith<$Res> { + _$PaymentRequestCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PaymentRequest + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? orderId = null, + Object? paymentMethodId = null, + Object? amount = null, + Object? transactionId = null, + Object? splitNumber = null, + Object? splitTotal = null, + Object? splitDescription = null, + Object? paymentOrderItems = null, + }) { + return _then( + _value.copyWith( + orderId: null == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodId: null == paymentMethodId + ? _value.paymentMethodId + : paymentMethodId // ignore: cast_nullable_to_non_nullable + as String, + amount: null == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int, + transactionId: null == transactionId + ? _value.transactionId + : transactionId // ignore: cast_nullable_to_non_nullable + as String, + splitNumber: null == splitNumber + ? _value.splitNumber + : splitNumber // ignore: cast_nullable_to_non_nullable + as int, + splitTotal: null == splitTotal + ? _value.splitTotal + : splitTotal // ignore: cast_nullable_to_non_nullable + as int, + splitDescription: null == splitDescription + ? _value.splitDescription + : splitDescription // ignore: cast_nullable_to_non_nullable + as String, + paymentOrderItems: null == paymentOrderItems + ? _value.paymentOrderItems + : paymentOrderItems // ignore: cast_nullable_to_non_nullable + as List, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$PaymentRequestImplCopyWith<$Res> + implements $PaymentRequestCopyWith<$Res> { + factory _$$PaymentRequestImplCopyWith( + _$PaymentRequestImpl value, + $Res Function(_$PaymentRequestImpl) then, + ) = __$$PaymentRequestImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + String orderId, + String paymentMethodId, + int amount, + String transactionId, + int splitNumber, + int splitTotal, + String splitDescription, + List paymentOrderItems, + }); +} + +/// @nodoc +class __$$PaymentRequestImplCopyWithImpl<$Res> + extends _$PaymentRequestCopyWithImpl<$Res, _$PaymentRequestImpl> + implements _$$PaymentRequestImplCopyWith<$Res> { + __$$PaymentRequestImplCopyWithImpl( + _$PaymentRequestImpl _value, + $Res Function(_$PaymentRequestImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PaymentRequest + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? orderId = null, + Object? paymentMethodId = null, + Object? amount = null, + Object? transactionId = null, + Object? splitNumber = null, + Object? splitTotal = null, + Object? splitDescription = null, + Object? paymentOrderItems = null, + }) { + return _then( + _$PaymentRequestImpl( + orderId: null == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodId: null == paymentMethodId + ? _value.paymentMethodId + : paymentMethodId // ignore: cast_nullable_to_non_nullable + as String, + amount: null == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int, + transactionId: null == transactionId + ? _value.transactionId + : transactionId // ignore: cast_nullable_to_non_nullable + as String, + splitNumber: null == splitNumber + ? _value.splitNumber + : splitNumber // ignore: cast_nullable_to_non_nullable + as int, + splitTotal: null == splitTotal + ? _value.splitTotal + : splitTotal // ignore: cast_nullable_to_non_nullable + as int, + splitDescription: null == splitDescription + ? _value.splitDescription + : splitDescription // ignore: cast_nullable_to_non_nullable + as String, + paymentOrderItems: null == paymentOrderItems + ? _value._paymentOrderItems + : paymentOrderItems // ignore: cast_nullable_to_non_nullable + as List, + ), + ); + } +} + +/// @nodoc + +class _$PaymentRequestImpl implements _PaymentRequest { + const _$PaymentRequestImpl({ + required this.orderId, + required this.paymentMethodId, + required this.amount, + required this.transactionId, + required this.splitNumber, + required this.splitTotal, + required this.splitDescription, + required final List paymentOrderItems, + }) : _paymentOrderItems = paymentOrderItems; + + @override + final String orderId; + @override + final String paymentMethodId; + @override + final int amount; + @override + final String transactionId; + @override + final int splitNumber; + @override + final int splitTotal; + @override + final String splitDescription; + final List _paymentOrderItems; + @override + List get paymentOrderItems { + if (_paymentOrderItems is EqualUnmodifiableListView) + return _paymentOrderItems; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_paymentOrderItems); + } + + @override + String toString() { + return 'PaymentRequest(orderId: $orderId, paymentMethodId: $paymentMethodId, amount: $amount, transactionId: $transactionId, splitNumber: $splitNumber, splitTotal: $splitTotal, splitDescription: $splitDescription, paymentOrderItems: $paymentOrderItems)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentRequestImpl && + (identical(other.orderId, orderId) || other.orderId == orderId) && + (identical(other.paymentMethodId, paymentMethodId) || + other.paymentMethodId == paymentMethodId) && + (identical(other.amount, amount) || other.amount == amount) && + (identical(other.transactionId, transactionId) || + other.transactionId == transactionId) && + (identical(other.splitNumber, splitNumber) || + other.splitNumber == splitNumber) && + (identical(other.splitTotal, splitTotal) || + other.splitTotal == splitTotal) && + (identical(other.splitDescription, splitDescription) || + other.splitDescription == splitDescription) && + const DeepCollectionEquality().equals( + other._paymentOrderItems, + _paymentOrderItems, + )); + } + + @override + int get hashCode => Object.hash( + runtimeType, + orderId, + paymentMethodId, + amount, + transactionId, + splitNumber, + splitTotal, + splitDescription, + const DeepCollectionEquality().hash(_paymentOrderItems), + ); + + /// Create a copy of PaymentRequest + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PaymentRequestImplCopyWith<_$PaymentRequestImpl> get copyWith => + __$$PaymentRequestImplCopyWithImpl<_$PaymentRequestImpl>( + this, + _$identity, + ); +} + +abstract class _PaymentRequest implements PaymentRequest { + const factory _PaymentRequest({ + required final String orderId, + required final String paymentMethodId, + required final int amount, + required final String transactionId, + required final int splitNumber, + required final int splitTotal, + required final String splitDescription, + required final List paymentOrderItems, + }) = _$PaymentRequestImpl; + + @override + String get orderId; + @override + String get paymentMethodId; + @override + int get amount; + @override + String get transactionId; + @override + int get splitNumber; + @override + int get splitTotal; + @override + String get splitDescription; + @override + List get paymentOrderItems; + + /// Create a copy of PaymentRequest + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PaymentRequestImplCopyWith<_$PaymentRequestImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$PaymentItemRequest { + String get orderItemId => throw _privateConstructorUsedError; + int get amount => throw _privateConstructorUsedError; + + /// Create a copy of PaymentItemRequest + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PaymentItemRequestCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PaymentItemRequestCopyWith<$Res> { + factory $PaymentItemRequestCopyWith( + PaymentItemRequest value, + $Res Function(PaymentItemRequest) then, + ) = _$PaymentItemRequestCopyWithImpl<$Res, PaymentItemRequest>; + @useResult + $Res call({String orderItemId, int amount}); +} + +/// @nodoc +class _$PaymentItemRequestCopyWithImpl<$Res, $Val extends PaymentItemRequest> + implements $PaymentItemRequestCopyWith<$Res> { + _$PaymentItemRequestCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PaymentItemRequest + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? orderItemId = null, Object? amount = null}) { + return _then( + _value.copyWith( + orderItemId: null == orderItemId + ? _value.orderItemId + : orderItemId // ignore: cast_nullable_to_non_nullable + as String, + amount: null == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$PaymentItemRequestImplCopyWith<$Res> + implements $PaymentItemRequestCopyWith<$Res> { + factory _$$PaymentItemRequestImplCopyWith( + _$PaymentItemRequestImpl value, + $Res Function(_$PaymentItemRequestImpl) then, + ) = __$$PaymentItemRequestImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String orderItemId, int amount}); +} + +/// @nodoc +class __$$PaymentItemRequestImplCopyWithImpl<$Res> + extends _$PaymentItemRequestCopyWithImpl<$Res, _$PaymentItemRequestImpl> + implements _$$PaymentItemRequestImplCopyWith<$Res> { + __$$PaymentItemRequestImplCopyWithImpl( + _$PaymentItemRequestImpl _value, + $Res Function(_$PaymentItemRequestImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PaymentItemRequest + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? orderItemId = null, Object? amount = null}) { + return _then( + _$PaymentItemRequestImpl( + orderItemId: null == orderItemId + ? _value.orderItemId + : orderItemId // ignore: cast_nullable_to_non_nullable + as String, + amount: null == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int, + ), + ); + } +} + +/// @nodoc + +class _$PaymentItemRequestImpl implements _PaymentItemRequest { + const _$PaymentItemRequestImpl({ + required this.orderItemId, + required this.amount, + }); + + @override + final String orderItemId; + @override + final int amount; + + @override + String toString() { + return 'PaymentItemRequest(orderItemId: $orderItemId, amount: $amount)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentItemRequestImpl && + (identical(other.orderItemId, orderItemId) || + other.orderItemId == orderItemId) && + (identical(other.amount, amount) || other.amount == amount)); + } + + @override + int get hashCode => Object.hash(runtimeType, orderItemId, amount); + + /// Create a copy of PaymentItemRequest + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PaymentItemRequestImplCopyWith<_$PaymentItemRequestImpl> get copyWith => + __$$PaymentItemRequestImplCopyWithImpl<_$PaymentItemRequestImpl>( + this, + _$identity, + ); +} + +abstract class _PaymentItemRequest implements PaymentItemRequest { + const factory _PaymentItemRequest({ + required final String orderItemId, + required final int amount, + }) = _$PaymentItemRequestImpl; + + @override + String get orderItemId; + @override + int get amount; + + /// Create a copy of PaymentItemRequest + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PaymentItemRequestImplCopyWith<_$PaymentItemRequestImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$Payment { + String get id => throw _privateConstructorUsedError; + String get orderId => throw _privateConstructorUsedError; + String get paymentMethodId => throw _privateConstructorUsedError; + String get paymentMethodName => throw _privateConstructorUsedError; + String get paymentMethodType => throw _privateConstructorUsedError; + int get amount => throw _privateConstructorUsedError; + String get status => throw _privateConstructorUsedError; + int get splitNumber => throw _privateConstructorUsedError; + int get splitTotal => throw _privateConstructorUsedError; + String get splitDescription => throw _privateConstructorUsedError; + int get refundAmount => throw _privateConstructorUsedError; + Map get metadata => throw _privateConstructorUsedError; + DateTime get createdAt => throw _privateConstructorUsedError; + DateTime get updatedAt => throw _privateConstructorUsedError; + + /// Create a copy of Payment + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PaymentCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PaymentCopyWith<$Res> { + factory $PaymentCopyWith(Payment value, $Res Function(Payment) then) = + _$PaymentCopyWithImpl<$Res, Payment>; + @useResult + $Res call({ + String id, + String orderId, + String paymentMethodId, + String paymentMethodName, + String paymentMethodType, + int amount, + String status, + int splitNumber, + int splitTotal, + String splitDescription, + int refundAmount, + Map metadata, + DateTime createdAt, + DateTime updatedAt, + }); +} + +/// @nodoc +class _$PaymentCopyWithImpl<$Res, $Val extends Payment> + implements $PaymentCopyWith<$Res> { + _$PaymentCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Payment + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? orderId = null, + Object? paymentMethodId = null, + Object? paymentMethodName = null, + Object? paymentMethodType = null, + Object? amount = null, + Object? status = null, + Object? splitNumber = null, + Object? splitTotal = null, + Object? splitDescription = null, + Object? refundAmount = null, + Object? metadata = null, + Object? createdAt = null, + Object? updatedAt = null, + }) { + return _then( + _value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + orderId: null == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodId: null == paymentMethodId + ? _value.paymentMethodId + : paymentMethodId // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodName: null == paymentMethodName + ? _value.paymentMethodName + : paymentMethodName // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodType: null == paymentMethodType + ? _value.paymentMethodType + : paymentMethodType // ignore: cast_nullable_to_non_nullable + as String, + amount: null == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + splitNumber: null == splitNumber + ? _value.splitNumber + : splitNumber // ignore: cast_nullable_to_non_nullable + as int, + splitTotal: null == splitTotal + ? _value.splitTotal + : splitTotal // ignore: cast_nullable_to_non_nullable + as int, + splitDescription: null == splitDescription + ? _value.splitDescription + : splitDescription // ignore: cast_nullable_to_non_nullable + as String, + refundAmount: null == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int, + metadata: null == metadata + ? _value.metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$PaymentImplCopyWith<$Res> implements $PaymentCopyWith<$Res> { + factory _$$PaymentImplCopyWith( + _$PaymentImpl value, + $Res Function(_$PaymentImpl) then, + ) = __$$PaymentImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + String id, + String orderId, + String paymentMethodId, + String paymentMethodName, + String paymentMethodType, + int amount, + String status, + int splitNumber, + int splitTotal, + String splitDescription, + int refundAmount, + Map metadata, + DateTime createdAt, + DateTime updatedAt, + }); +} + +/// @nodoc +class __$$PaymentImplCopyWithImpl<$Res> + extends _$PaymentCopyWithImpl<$Res, _$PaymentImpl> + implements _$$PaymentImplCopyWith<$Res> { + __$$PaymentImplCopyWithImpl( + _$PaymentImpl _value, + $Res Function(_$PaymentImpl) _then, + ) : super(_value, _then); + + /// Create a copy of Payment + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? orderId = null, + Object? paymentMethodId = null, + Object? paymentMethodName = null, + Object? paymentMethodType = null, + Object? amount = null, + Object? status = null, + Object? splitNumber = null, + Object? splitTotal = null, + Object? splitDescription = null, + Object? refundAmount = null, + Object? metadata = null, + Object? createdAt = null, + Object? updatedAt = null, + }) { + return _then( + _$PaymentImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + orderId: null == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodId: null == paymentMethodId + ? _value.paymentMethodId + : paymentMethodId // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodName: null == paymentMethodName + ? _value.paymentMethodName + : paymentMethodName // ignore: cast_nullable_to_non_nullable + as String, + paymentMethodType: null == paymentMethodType + ? _value.paymentMethodType + : paymentMethodType // ignore: cast_nullable_to_non_nullable + as String, + amount: null == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String, + splitNumber: null == splitNumber + ? _value.splitNumber + : splitNumber // ignore: cast_nullable_to_non_nullable + as int, + splitTotal: null == splitTotal + ? _value.splitTotal + : splitTotal // ignore: cast_nullable_to_non_nullable + as int, + splitDescription: null == splitDescription + ? _value.splitDescription + : splitDescription // ignore: cast_nullable_to_non_nullable + as String, + refundAmount: null == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int, + metadata: null == metadata + ? _value._metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map, + createdAt: null == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime, + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime, + ), + ); + } +} + +/// @nodoc + +class _$PaymentImpl implements _Payment { + const _$PaymentImpl({ + required this.id, + required this.orderId, + required this.paymentMethodId, + required this.paymentMethodName, + required this.paymentMethodType, + required this.amount, + required this.status, + required this.splitNumber, + required this.splitTotal, + required this.splitDescription, + required this.refundAmount, + required final Map metadata, + required this.createdAt, + required this.updatedAt, + }) : _metadata = metadata; + + @override + final String id; + @override + final String orderId; + @override + final String paymentMethodId; + @override + final String paymentMethodName; + @override + final String paymentMethodType; + @override + final int amount; + @override + final String status; + @override + final int splitNumber; + @override + final int splitTotal; + @override + final String splitDescription; + @override + final int refundAmount; + final Map _metadata; + @override + Map get metadata { + if (_metadata is EqualUnmodifiableMapView) return _metadata; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_metadata); + } + + @override + final DateTime createdAt; + @override + final DateTime updatedAt; + + @override + String toString() { + return 'Payment(id: $id, orderId: $orderId, paymentMethodId: $paymentMethodId, paymentMethodName: $paymentMethodName, paymentMethodType: $paymentMethodType, amount: $amount, status: $status, splitNumber: $splitNumber, splitTotal: $splitTotal, splitDescription: $splitDescription, refundAmount: $refundAmount, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.orderId, orderId) || other.orderId == orderId) && + (identical(other.paymentMethodId, paymentMethodId) || + other.paymentMethodId == paymentMethodId) && + (identical(other.paymentMethodName, paymentMethodName) || + other.paymentMethodName == paymentMethodName) && + (identical(other.paymentMethodType, paymentMethodType) || + other.paymentMethodType == paymentMethodType) && + (identical(other.amount, amount) || other.amount == amount) && + (identical(other.status, status) || other.status == status) && + (identical(other.splitNumber, splitNumber) || + other.splitNumber == splitNumber) && + (identical(other.splitTotal, splitTotal) || + other.splitTotal == splitTotal) && + (identical(other.splitDescription, splitDescription) || + other.splitDescription == splitDescription) && + (identical(other.refundAmount, refundAmount) || + other.refundAmount == refundAmount) && + const DeepCollectionEquality().equals(other._metadata, _metadata) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + id, + orderId, + paymentMethodId, + paymentMethodName, + paymentMethodType, + amount, + status, + splitNumber, + splitTotal, + splitDescription, + refundAmount, + const DeepCollectionEquality().hash(_metadata), + createdAt, + updatedAt, + ); + + /// Create a copy of Payment + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PaymentImplCopyWith<_$PaymentImpl> get copyWith => + __$$PaymentImplCopyWithImpl<_$PaymentImpl>(this, _$identity); +} + +abstract class _Payment implements Payment { + const factory _Payment({ + required final String id, + required final String orderId, + required final String paymentMethodId, + required final String paymentMethodName, + required final String paymentMethodType, + required final int amount, + required final String status, + required final int splitNumber, + required final int splitTotal, + required final String splitDescription, + required final int refundAmount, + required final Map metadata, + required final DateTime createdAt, + required final DateTime updatedAt, + }) = _$PaymentImpl; + + @override + String get id; + @override + String get orderId; + @override + String get paymentMethodId; + @override + String get paymentMethodName; + @override + String get paymentMethodType; + @override + int get amount; + @override + String get status; + @override + int get splitNumber; + @override + int get splitTotal; + @override + String get splitDescription; + @override + int get refundAmount; + @override + Map get metadata; + @override + DateTime get createdAt; + @override + DateTime get updatedAt; + + /// Create a copy of Payment + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PaymentImplCopyWith<_$PaymentImpl> get copyWith => + throw _privateConstructorUsedError; +} + /// @nodoc mixin _$OrderFailure { @optionalTypeArgs diff --git a/lib/domain/order/repositories/i_order_repository.dart b/lib/domain/order/repositories/i_order_repository.dart index ba2659f..e420987 100644 --- a/lib/domain/order/repositories/i_order_repository.dart +++ b/lib/domain/order/repositories/i_order_repository.dart @@ -13,4 +13,9 @@ abstract class IOrderRepository { Future> createOrder({ required OrderRequest request, }); + + Future> createOrderWithPayment({ + required OrderRequest request, + required String paymentMethodId, + }); } diff --git a/lib/infrastructure/order/datasources/remote_data_provider.dart b/lib/infrastructure/order/datasources/remote_data_provider.dart index f219809..00c04a4 100644 --- a/lib/infrastructure/order/datasources/remote_data_provider.dart +++ b/lib/infrastructure/order/datasources/remote_data_provider.dart @@ -83,4 +83,72 @@ class OrderRemoteDataProvider { return DC.error(OrderFailure.serverError(e)); } } + + Future> storeWithPaymentOrder({ + required OrderRequestDto request, + required String paymentMethodId, + }) async { + try { + final response = await _apiClient.post( + ApiPath.orders, + data: request.toRequest(), + headers: getAuthorizationHeader(), + ); + + if (response.data['success'] == false) { + return DC.error(OrderFailure.unexpectedError()); + } else { + final order = OrderDto.fromJson( + response.data['data'] as Map, + ); + final paymentRequest = PaymentRequestDto( + orderId: order.id, + amount: order.totalAmount, + paymentMethodId: paymentMethodId, + splitNumber: 1, + splitTotal: 1, + splitDescription: '', + paymentOrderItems: order.orderItems + ?.map( + (item) => PaymentItemRequestDto( + amount: item.totalPrice, + orderItemId: item.id, + ), + ) + .toList(), + ); + storePayment(paymentRequest); + + return DC.data(order); + } + } on ApiFailure catch (e, s) { + log('storeOrderError', name: _logName, error: e, stackTrace: s); + return DC.error(OrderFailure.serverError(e)); + } + } + + Future> storePayment( + PaymentRequestDto request, + ) async { + try { + final response = await _apiClient.post( + ApiPath.payments, + data: request.toJson(), + headers: getAuthorizationHeader(), + ); + + if (response.data['success'] == false) { + return DC.error(OrderFailure.unexpectedError()); + } + + final payment = PaymentDto.fromJson( + response.data['data'] as Map, + ); + + return DC.data(payment); + } on ApiFailure catch (e, s) { + log('storePaymentError', name: _logName, error: e, stackTrace: s); + return DC.error(OrderFailure.serverError(e)); + } + } } diff --git a/lib/infrastructure/order/dtos/order_dto.dart b/lib/infrastructure/order/dtos/order_dto.dart index fba1391..0b713cf 100644 --- a/lib/infrastructure/order/dtos/order_dto.dart +++ b/lib/infrastructure/order/dtos/order_dto.dart @@ -51,7 +51,7 @@ class OrderDto with _$OrderDto { @JsonKey(name: "created_at") String? createdAt, @JsonKey(name: "updated_at") String? updatedAt, @JsonKey(name: "order_items") List? orderItems, - @JsonKey(name: "payments") List? payments, + @JsonKey(name: "payments") List? payments, @JsonKey(name: "total_paid") int? totalPaid, @JsonKey(name: "payment_count") int? paymentCount, @JsonKey(name: "split_type") String? splitType, @@ -137,46 +137,3 @@ class OrderItemDto with _$OrderItemDto { paidQuantity: paidQuantity ?? 0, ); } - -@freezed -class PaymentOrderDto with _$PaymentOrderDto { - const PaymentOrderDto._(); - - const factory PaymentOrderDto({ - @JsonKey(name: "id") String? id, - @JsonKey(name: "order_id") String? orderId, - @JsonKey(name: "payment_method_id") String? paymentMethodId, - @JsonKey(name: "payment_method_name") String? paymentMethodName, - @JsonKey(name: "payment_method_type") String? paymentMethodType, - @JsonKey(name: "amount") int? amount, - @JsonKey(name: "status") String? status, - @JsonKey(name: "split_number") int? splitNumber, - @JsonKey(name: "split_total") int? splitTotal, - @JsonKey(name: "split_description") String? splitDescription, - @JsonKey(name: "refund_amount") int? refundAmount, - @JsonKey(name: "metadata") Map? metadata, - @JsonKey(name: "created_at") String? createdAt, - @JsonKey(name: "updated_at") String? updatedAt, - }) = _PaymentOrderDto; - - factory PaymentOrderDto.fromJson(Map json) => - _$PaymentOrderDtoFromJson(json); - - // Optional mapper ke domain entity - PaymentOrder toDomain() => PaymentOrder( - id: id ?? '', - orderId: orderId ?? '', - paymentMethodId: paymentMethodId ?? '', - paymentMethodName: paymentMethodName ?? '', - paymentMethodType: paymentMethodType ?? '', - amount: amount ?? 0, - status: status ?? '', - splitNumber: splitNumber ?? 0, - splitTotal: splitTotal ?? 0, - splitDescription: splitDescription ?? '', - refundAmount: refundAmount ?? 0, - metadata: metadata ?? const {}, - createdAt: createdAt != null ? DateTime.parse(createdAt!) : DateTime(1970), - updatedAt: updatedAt != null ? DateTime.parse(updatedAt!) : DateTime(1970), - ); -} diff --git a/lib/infrastructure/order/dtos/payment_dto.dart b/lib/infrastructure/order/dtos/payment_dto.dart new file mode 100644 index 0000000..7200b66 --- /dev/null +++ b/lib/infrastructure/order/dtos/payment_dto.dart @@ -0,0 +1,44 @@ +part of '../order_dtos.dart'; + +@freezed +class PaymentDto with _$PaymentDto { + const PaymentDto._(); + + const factory PaymentDto({ + @JsonKey(name: "id") String? id, + @JsonKey(name: "order_id") String? orderId, + @JsonKey(name: "payment_method_id") String? paymentMethodId, + @JsonKey(name: "payment_method_name") String? paymentMethodName, + @JsonKey(name: "payment_method_type") String? paymentMethodType, + @JsonKey(name: "amount") int? amount, + @JsonKey(name: "status") String? status, + @JsonKey(name: "split_number") int? splitNumber, + @JsonKey(name: "split_total") int? splitTotal, + @JsonKey(name: "split_description") String? splitDescription, + @JsonKey(name: "refund_amount") int? refundAmount, + @JsonKey(name: "metadata") Map? metadata, + @JsonKey(name: "created_at") String? createdAt, + @JsonKey(name: "updated_at") String? updatedAt, + }) = _PaymentOrderDto; + + factory PaymentDto.fromJson(Map json) => + _$PaymentDtoFromJson(json); + + // Optional mapper ke domain entity + Payment toDomain() => Payment( + id: id ?? '', + orderId: orderId ?? '', + paymentMethodId: paymentMethodId ?? '', + paymentMethodName: paymentMethodName ?? '', + paymentMethodType: paymentMethodType ?? '', + amount: amount ?? 0, + status: status ?? '', + splitNumber: splitNumber ?? 0, + splitTotal: splitTotal ?? 0, + splitDescription: splitDescription ?? '', + refundAmount: refundAmount ?? 0, + metadata: metadata ?? const {}, + createdAt: createdAt != null ? DateTime.parse(createdAt!) : DateTime(1970), + updatedAt: updatedAt != null ? DateTime.parse(updatedAt!) : DateTime(1970), + ); +} diff --git a/lib/infrastructure/order/dtos/payment_request_dto.dart b/lib/infrastructure/order/dtos/payment_request_dto.dart new file mode 100644 index 0000000..a6cef3e --- /dev/null +++ b/lib/infrastructure/order/dtos/payment_request_dto.dart @@ -0,0 +1,51 @@ +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? paymentOrderItems, + }) = _PaymentRequestDto; + + factory PaymentRequestDto.fromJson(Map 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 json) => + _$PaymentItemRequestDtoFromJson(json); + + // Optional: mapper ke domain entity + PaymentItemRequest toDomain() => + PaymentItemRequest(orderItemId: orderItemId ?? '', amount: amount ?? 0); +} diff --git a/lib/infrastructure/order/order_dtos.dart b/lib/infrastructure/order/order_dtos.dart index 5094e5c..a1ca0b0 100644 --- a/lib/infrastructure/order/order_dtos.dart +++ b/lib/infrastructure/order/order_dtos.dart @@ -7,3 +7,5 @@ part 'order_dtos.g.dart'; part 'dtos/order_dto.dart'; part 'dtos/order_request_dto.dart'; +part 'dtos/payment_request_dto.dart'; +part 'dtos/payment_dto.dart'; diff --git a/lib/infrastructure/order/order_dtos.freezed.dart b/lib/infrastructure/order/order_dtos.freezed.dart index 68fb71b..c09ce69 100644 --- a/lib/infrastructure/order/order_dtos.freezed.dart +++ b/lib/infrastructure/order/order_dtos.freezed.dart @@ -343,7 +343,7 @@ mixin _$OrderDto { @JsonKey(name: "order_items") List? get orderItems => throw _privateConstructorUsedError; @JsonKey(name: "payments") - List? get payments => throw _privateConstructorUsedError; + List? get payments => throw _privateConstructorUsedError; @JsonKey(name: "total_paid") int? get totalPaid => throw _privateConstructorUsedError; @JsonKey(name: "payment_count") @@ -389,7 +389,7 @@ abstract class $OrderDtoCopyWith<$Res> { @JsonKey(name: "created_at") String? createdAt, @JsonKey(name: "updated_at") String? updatedAt, @JsonKey(name: "order_items") List? orderItems, - @JsonKey(name: "payments") List? payments, + @JsonKey(name: "payments") List? payments, @JsonKey(name: "total_paid") int? totalPaid, @JsonKey(name: "payment_count") int? paymentCount, @JsonKey(name: "split_type") String? splitType, @@ -531,7 +531,7 @@ class _$OrderDtoCopyWithImpl<$Res, $Val extends OrderDto> payments: freezed == payments ? _value.payments : payments // ignore: cast_nullable_to_non_nullable - as List?, + as List?, totalPaid: freezed == totalPaid ? _value.totalPaid : totalPaid // ignore: cast_nullable_to_non_nullable @@ -582,7 +582,7 @@ abstract class _$$OrderDtoImplCopyWith<$Res> @JsonKey(name: "created_at") String? createdAt, @JsonKey(name: "updated_at") String? updatedAt, @JsonKey(name: "order_items") List? orderItems, - @JsonKey(name: "payments") List? payments, + @JsonKey(name: "payments") List? payments, @JsonKey(name: "total_paid") int? totalPaid, @JsonKey(name: "payment_count") int? paymentCount, @JsonKey(name: "split_type") String? splitType, @@ -723,7 +723,7 @@ class __$$OrderDtoImplCopyWithImpl<$Res> payments: freezed == payments ? _value._payments : payments // ignore: cast_nullable_to_non_nullable - as List?, + as List?, totalPaid: freezed == totalPaid ? _value.totalPaid : totalPaid // ignore: cast_nullable_to_non_nullable @@ -767,7 +767,7 @@ class _$OrderDtoImpl extends _OrderDto { @JsonKey(name: "created_at") this.createdAt, @JsonKey(name: "updated_at") this.updatedAt, @JsonKey(name: "order_items") final List? orderItems, - @JsonKey(name: "payments") final List? payments, + @JsonKey(name: "payments") final List? payments, @JsonKey(name: "total_paid") this.totalPaid, @JsonKey(name: "payment_count") this.paymentCount, @JsonKey(name: "split_type") this.splitType, @@ -861,10 +861,10 @@ class _$OrderDtoImpl extends _OrderDto { return EqualUnmodifiableListView(value); } - final List? _payments; + final List? _payments; @override @JsonKey(name: "payments") - List? get payments { + List? get payments { final value = _payments; if (value == null) return null; if (_payments is EqualUnmodifiableListView) return _payments; @@ -1011,7 +1011,7 @@ abstract class _OrderDto extends OrderDto { @JsonKey(name: "created_at") final String? createdAt, @JsonKey(name: "updated_at") final String? updatedAt, @JsonKey(name: "order_items") final List? orderItems, - @JsonKey(name: "payments") final List? payments, + @JsonKey(name: "payments") final List? payments, @JsonKey(name: "total_paid") final int? totalPaid, @JsonKey(name: "payment_count") final int? paymentCount, @JsonKey(name: "split_type") final String? splitType, @@ -1089,7 +1089,7 @@ abstract class _OrderDto extends OrderDto { List? get orderItems; @override @JsonKey(name: "payments") - List? get payments; + List? get payments; @override @JsonKey(name: "total_paid") int? get totalPaid; @@ -1661,509 +1661,6 @@ abstract class _OrderItemDto extends OrderItemDto { throw _privateConstructorUsedError; } -PaymentOrderDto _$PaymentOrderDtoFromJson(Map json) { - return _PaymentOrderDto.fromJson(json); -} - -/// @nodoc -mixin _$PaymentOrderDto { - @JsonKey(name: "id") - String? get id => throw _privateConstructorUsedError; - @JsonKey(name: "order_id") - String? get orderId => throw _privateConstructorUsedError; - @JsonKey(name: "payment_method_id") - String? get paymentMethodId => throw _privateConstructorUsedError; - @JsonKey(name: "payment_method_name") - String? get paymentMethodName => throw _privateConstructorUsedError; - @JsonKey(name: "payment_method_type") - String? get paymentMethodType => throw _privateConstructorUsedError; - @JsonKey(name: "amount") - int? get amount => throw _privateConstructorUsedError; - @JsonKey(name: "status") - String? get status => throw _privateConstructorUsedError; - @JsonKey(name: "split_number") - int? get splitNumber => throw _privateConstructorUsedError; - @JsonKey(name: "split_total") - int? get splitTotal => throw _privateConstructorUsedError; - @JsonKey(name: "split_description") - String? get splitDescription => throw _privateConstructorUsedError; - @JsonKey(name: "refund_amount") - int? get refundAmount => throw _privateConstructorUsedError; - @JsonKey(name: "metadata") - Map? get metadata => throw _privateConstructorUsedError; - @JsonKey(name: "created_at") - String? get createdAt => throw _privateConstructorUsedError; - @JsonKey(name: "updated_at") - String? get updatedAt => throw _privateConstructorUsedError; - - /// Serializes this PaymentOrderDto to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of PaymentOrderDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $PaymentOrderDtoCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $PaymentOrderDtoCopyWith<$Res> { - factory $PaymentOrderDtoCopyWith( - PaymentOrderDto value, - $Res Function(PaymentOrderDto) then, - ) = _$PaymentOrderDtoCopyWithImpl<$Res, PaymentOrderDto>; - @useResult - $Res call({ - @JsonKey(name: "id") String? id, - @JsonKey(name: "order_id") String? orderId, - @JsonKey(name: "payment_method_id") String? paymentMethodId, - @JsonKey(name: "payment_method_name") String? paymentMethodName, - @JsonKey(name: "payment_method_type") String? paymentMethodType, - @JsonKey(name: "amount") int? amount, - @JsonKey(name: "status") String? status, - @JsonKey(name: "split_number") int? splitNumber, - @JsonKey(name: "split_total") int? splitTotal, - @JsonKey(name: "split_description") String? splitDescription, - @JsonKey(name: "refund_amount") int? refundAmount, - @JsonKey(name: "metadata") Map? metadata, - @JsonKey(name: "created_at") String? createdAt, - @JsonKey(name: "updated_at") String? updatedAt, - }); -} - -/// @nodoc -class _$PaymentOrderDtoCopyWithImpl<$Res, $Val extends PaymentOrderDto> - implements $PaymentOrderDtoCopyWith<$Res> { - _$PaymentOrderDtoCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of PaymentOrderDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - Object? orderId = freezed, - Object? paymentMethodId = freezed, - Object? paymentMethodName = freezed, - Object? paymentMethodType = freezed, - Object? amount = freezed, - Object? status = freezed, - Object? splitNumber = freezed, - Object? splitTotal = freezed, - Object? splitDescription = freezed, - Object? refundAmount = freezed, - Object? metadata = freezed, - Object? createdAt = freezed, - Object? updatedAt = freezed, - }) { - return _then( - _value.copyWith( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String?, - orderId: freezed == orderId - ? _value.orderId - : orderId // ignore: cast_nullable_to_non_nullable - as String?, - paymentMethodId: freezed == paymentMethodId - ? _value.paymentMethodId - : paymentMethodId // ignore: cast_nullable_to_non_nullable - as String?, - paymentMethodName: freezed == paymentMethodName - ? _value.paymentMethodName - : paymentMethodName // ignore: cast_nullable_to_non_nullable - as String?, - paymentMethodType: freezed == paymentMethodType - ? _value.paymentMethodType - : paymentMethodType // ignore: cast_nullable_to_non_nullable - as String?, - amount: freezed == amount - ? _value.amount - : amount // ignore: cast_nullable_to_non_nullable - as int?, - status: freezed == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String?, - splitNumber: freezed == splitNumber - ? _value.splitNumber - : splitNumber // ignore: cast_nullable_to_non_nullable - as int?, - splitTotal: freezed == splitTotal - ? _value.splitTotal - : splitTotal // ignore: cast_nullable_to_non_nullable - as int?, - splitDescription: freezed == splitDescription - ? _value.splitDescription - : splitDescription // ignore: cast_nullable_to_non_nullable - as String?, - refundAmount: freezed == refundAmount - ? _value.refundAmount - : refundAmount // ignore: cast_nullable_to_non_nullable - as int?, - metadata: freezed == metadata - ? _value.metadata - : metadata // ignore: cast_nullable_to_non_nullable - as Map?, - createdAt: freezed == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as String?, - updatedAt: freezed == updatedAt - ? _value.updatedAt - : updatedAt // ignore: cast_nullable_to_non_nullable - as String?, - ) - as $Val, - ); - } -} - -/// @nodoc -abstract class _$$PaymentOrderDtoImplCopyWith<$Res> - implements $PaymentOrderDtoCopyWith<$Res> { - factory _$$PaymentOrderDtoImplCopyWith( - _$PaymentOrderDtoImpl value, - $Res Function(_$PaymentOrderDtoImpl) then, - ) = __$$PaymentOrderDtoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - @JsonKey(name: "id") String? id, - @JsonKey(name: "order_id") String? orderId, - @JsonKey(name: "payment_method_id") String? paymentMethodId, - @JsonKey(name: "payment_method_name") String? paymentMethodName, - @JsonKey(name: "payment_method_type") String? paymentMethodType, - @JsonKey(name: "amount") int? amount, - @JsonKey(name: "status") String? status, - @JsonKey(name: "split_number") int? splitNumber, - @JsonKey(name: "split_total") int? splitTotal, - @JsonKey(name: "split_description") String? splitDescription, - @JsonKey(name: "refund_amount") int? refundAmount, - @JsonKey(name: "metadata") Map? metadata, - @JsonKey(name: "created_at") String? createdAt, - @JsonKey(name: "updated_at") String? updatedAt, - }); -} - -/// @nodoc -class __$$PaymentOrderDtoImplCopyWithImpl<$Res> - extends _$PaymentOrderDtoCopyWithImpl<$Res, _$PaymentOrderDtoImpl> - implements _$$PaymentOrderDtoImplCopyWith<$Res> { - __$$PaymentOrderDtoImplCopyWithImpl( - _$PaymentOrderDtoImpl _value, - $Res Function(_$PaymentOrderDtoImpl) _then, - ) : super(_value, _then); - - /// Create a copy of PaymentOrderDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - Object? orderId = freezed, - Object? paymentMethodId = freezed, - Object? paymentMethodName = freezed, - Object? paymentMethodType = freezed, - Object? amount = freezed, - Object? status = freezed, - Object? splitNumber = freezed, - Object? splitTotal = freezed, - Object? splitDescription = freezed, - Object? refundAmount = freezed, - Object? metadata = freezed, - Object? createdAt = freezed, - Object? updatedAt = freezed, - }) { - return _then( - _$PaymentOrderDtoImpl( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String?, - orderId: freezed == orderId - ? _value.orderId - : orderId // ignore: cast_nullable_to_non_nullable - as String?, - paymentMethodId: freezed == paymentMethodId - ? _value.paymentMethodId - : paymentMethodId // ignore: cast_nullable_to_non_nullable - as String?, - paymentMethodName: freezed == paymentMethodName - ? _value.paymentMethodName - : paymentMethodName // ignore: cast_nullable_to_non_nullable - as String?, - paymentMethodType: freezed == paymentMethodType - ? _value.paymentMethodType - : paymentMethodType // ignore: cast_nullable_to_non_nullable - as String?, - amount: freezed == amount - ? _value.amount - : amount // ignore: cast_nullable_to_non_nullable - as int?, - status: freezed == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String?, - splitNumber: freezed == splitNumber - ? _value.splitNumber - : splitNumber // ignore: cast_nullable_to_non_nullable - as int?, - splitTotal: freezed == splitTotal - ? _value.splitTotal - : splitTotal // ignore: cast_nullable_to_non_nullable - as int?, - splitDescription: freezed == splitDescription - ? _value.splitDescription - : splitDescription // ignore: cast_nullable_to_non_nullable - as String?, - refundAmount: freezed == refundAmount - ? _value.refundAmount - : refundAmount // ignore: cast_nullable_to_non_nullable - as int?, - metadata: freezed == metadata - ? _value._metadata - : metadata // ignore: cast_nullable_to_non_nullable - as Map?, - createdAt: freezed == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as String?, - updatedAt: freezed == updatedAt - ? _value.updatedAt - : updatedAt // ignore: cast_nullable_to_non_nullable - as String?, - ), - ); - } -} - -/// @nodoc -@JsonSerializable() -class _$PaymentOrderDtoImpl extends _PaymentOrderDto { - const _$PaymentOrderDtoImpl({ - @JsonKey(name: "id") this.id, - @JsonKey(name: "order_id") this.orderId, - @JsonKey(name: "payment_method_id") this.paymentMethodId, - @JsonKey(name: "payment_method_name") this.paymentMethodName, - @JsonKey(name: "payment_method_type") this.paymentMethodType, - @JsonKey(name: "amount") this.amount, - @JsonKey(name: "status") this.status, - @JsonKey(name: "split_number") this.splitNumber, - @JsonKey(name: "split_total") this.splitTotal, - @JsonKey(name: "split_description") this.splitDescription, - @JsonKey(name: "refund_amount") this.refundAmount, - @JsonKey(name: "metadata") final Map? metadata, - @JsonKey(name: "created_at") this.createdAt, - @JsonKey(name: "updated_at") this.updatedAt, - }) : _metadata = metadata, - super._(); - - factory _$PaymentOrderDtoImpl.fromJson(Map json) => - _$$PaymentOrderDtoImplFromJson(json); - - @override - @JsonKey(name: "id") - final String? id; - @override - @JsonKey(name: "order_id") - final String? orderId; - @override - @JsonKey(name: "payment_method_id") - final String? paymentMethodId; - @override - @JsonKey(name: "payment_method_name") - final String? paymentMethodName; - @override - @JsonKey(name: "payment_method_type") - final String? paymentMethodType; - @override - @JsonKey(name: "amount") - final int? amount; - @override - @JsonKey(name: "status") - final String? status; - @override - @JsonKey(name: "split_number") - final int? splitNumber; - @override - @JsonKey(name: "split_total") - final int? splitTotal; - @override - @JsonKey(name: "split_description") - final String? splitDescription; - @override - @JsonKey(name: "refund_amount") - final int? refundAmount; - final Map? _metadata; - @override - @JsonKey(name: "metadata") - Map? get metadata { - final value = _metadata; - if (value == null) return null; - if (_metadata is EqualUnmodifiableMapView) return _metadata; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - @override - @JsonKey(name: "created_at") - final String? createdAt; - @override - @JsonKey(name: "updated_at") - final String? updatedAt; - - @override - String toString() { - return 'PaymentOrderDto(id: $id, orderId: $orderId, paymentMethodId: $paymentMethodId, paymentMethodName: $paymentMethodName, paymentMethodType: $paymentMethodType, amount: $amount, status: $status, splitNumber: $splitNumber, splitTotal: $splitTotal, splitDescription: $splitDescription, refundAmount: $refundAmount, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PaymentOrderDtoImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.orderId, orderId) || other.orderId == orderId) && - (identical(other.paymentMethodId, paymentMethodId) || - other.paymentMethodId == paymentMethodId) && - (identical(other.paymentMethodName, paymentMethodName) || - other.paymentMethodName == paymentMethodName) && - (identical(other.paymentMethodType, paymentMethodType) || - other.paymentMethodType == paymentMethodType) && - (identical(other.amount, amount) || other.amount == amount) && - (identical(other.status, status) || other.status == status) && - (identical(other.splitNumber, splitNumber) || - other.splitNumber == splitNumber) && - (identical(other.splitTotal, splitTotal) || - other.splitTotal == splitTotal) && - (identical(other.splitDescription, splitDescription) || - other.splitDescription == splitDescription) && - (identical(other.refundAmount, refundAmount) || - other.refundAmount == refundAmount) && - const DeepCollectionEquality().equals(other._metadata, _metadata) && - (identical(other.createdAt, createdAt) || - other.createdAt == createdAt) && - (identical(other.updatedAt, updatedAt) || - other.updatedAt == updatedAt)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - id, - orderId, - paymentMethodId, - paymentMethodName, - paymentMethodType, - amount, - status, - splitNumber, - splitTotal, - splitDescription, - refundAmount, - const DeepCollectionEquality().hash(_metadata), - createdAt, - updatedAt, - ); - - /// Create a copy of PaymentOrderDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PaymentOrderDtoImplCopyWith<_$PaymentOrderDtoImpl> get copyWith => - __$$PaymentOrderDtoImplCopyWithImpl<_$PaymentOrderDtoImpl>( - this, - _$identity, - ); - - @override - Map toJson() { - return _$$PaymentOrderDtoImplToJson(this); - } -} - -abstract class _PaymentOrderDto extends PaymentOrderDto { - const factory _PaymentOrderDto({ - @JsonKey(name: "id") final String? id, - @JsonKey(name: "order_id") final String? orderId, - @JsonKey(name: "payment_method_id") final String? paymentMethodId, - @JsonKey(name: "payment_method_name") final String? paymentMethodName, - @JsonKey(name: "payment_method_type") final String? paymentMethodType, - @JsonKey(name: "amount") final int? amount, - @JsonKey(name: "status") final String? status, - @JsonKey(name: "split_number") final int? splitNumber, - @JsonKey(name: "split_total") final int? splitTotal, - @JsonKey(name: "split_description") final String? splitDescription, - @JsonKey(name: "refund_amount") final int? refundAmount, - @JsonKey(name: "metadata") final Map? metadata, - @JsonKey(name: "created_at") final String? createdAt, - @JsonKey(name: "updated_at") final String? updatedAt, - }) = _$PaymentOrderDtoImpl; - const _PaymentOrderDto._() : super._(); - - factory _PaymentOrderDto.fromJson(Map json) = - _$PaymentOrderDtoImpl.fromJson; - - @override - @JsonKey(name: "id") - String? get id; - @override - @JsonKey(name: "order_id") - String? get orderId; - @override - @JsonKey(name: "payment_method_id") - String? get paymentMethodId; - @override - @JsonKey(name: "payment_method_name") - String? get paymentMethodName; - @override - @JsonKey(name: "payment_method_type") - String? get paymentMethodType; - @override - @JsonKey(name: "amount") - int? get amount; - @override - @JsonKey(name: "status") - String? get status; - @override - @JsonKey(name: "split_number") - int? get splitNumber; - @override - @JsonKey(name: "split_total") - int? get splitTotal; - @override - @JsonKey(name: "split_description") - String? get splitDescription; - @override - @JsonKey(name: "refund_amount") - int? get refundAmount; - @override - @JsonKey(name: "metadata") - Map? get metadata; - @override - @JsonKey(name: "created_at") - String? get createdAt; - @override - @JsonKey(name: "updated_at") - String? get updatedAt; - - /// Create a copy of PaymentOrderDto - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PaymentOrderDtoImplCopyWith<_$PaymentOrderDtoImpl> get copyWith => - throw _privateConstructorUsedError; -} - OrderRequestDto _$OrderRequestDtoFromJson(Map json) { return _OrderRequestDto.fromJson(json); } @@ -2795,3 +2292,1064 @@ abstract class _OrderItemRequestDto extends OrderItemRequestDto { _$$OrderItemRequestDtoImplCopyWith<_$OrderItemRequestDtoImpl> get copyWith => throw _privateConstructorUsedError; } + +PaymentRequestDto _$PaymentRequestDtoFromJson(Map json) { + return _PaymentRequestDto.fromJson(json); +} + +/// @nodoc +mixin _$PaymentRequestDto { + @JsonKey(name: "order_id") + String? get orderId => throw _privateConstructorUsedError; + @JsonKey(name: "payment_method_id") + String? get paymentMethodId => throw _privateConstructorUsedError; + @JsonKey(name: "amount") + int? get amount => throw _privateConstructorUsedError; + @JsonKey(name: "transaction_id") + String? get transactionId => throw _privateConstructorUsedError; + @JsonKey(name: "split_number") + int? get splitNumber => throw _privateConstructorUsedError; + @JsonKey(name: "split_total") + int? get splitTotal => throw _privateConstructorUsedError; + @JsonKey(name: "split_description") + String? get splitDescription => throw _privateConstructorUsedError; + @JsonKey(name: "payment_order_items") + List? get paymentOrderItems => + throw _privateConstructorUsedError; + + /// Serializes this PaymentRequestDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PaymentRequestDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PaymentRequestDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PaymentRequestDtoCopyWith<$Res> { + factory $PaymentRequestDtoCopyWith( + PaymentRequestDto value, + $Res Function(PaymentRequestDto) then, + ) = _$PaymentRequestDtoCopyWithImpl<$Res, PaymentRequestDto>; + @useResult + $Res call({ + @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? paymentOrderItems, + }); +} + +/// @nodoc +class _$PaymentRequestDtoCopyWithImpl<$Res, $Val extends PaymentRequestDto> + implements $PaymentRequestDtoCopyWith<$Res> { + _$PaymentRequestDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PaymentRequestDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? orderId = freezed, + Object? paymentMethodId = freezed, + Object? amount = freezed, + Object? transactionId = freezed, + Object? splitNumber = freezed, + Object? splitTotal = freezed, + Object? splitDescription = freezed, + Object? paymentOrderItems = freezed, + }) { + return _then( + _value.copyWith( + orderId: freezed == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodId: freezed == paymentMethodId + ? _value.paymentMethodId + : paymentMethodId // ignore: cast_nullable_to_non_nullable + as String?, + amount: freezed == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int?, + transactionId: freezed == transactionId + ? _value.transactionId + : transactionId // ignore: cast_nullable_to_non_nullable + as String?, + splitNumber: freezed == splitNumber + ? _value.splitNumber + : splitNumber // ignore: cast_nullable_to_non_nullable + as int?, + splitTotal: freezed == splitTotal + ? _value.splitTotal + : splitTotal // ignore: cast_nullable_to_non_nullable + as int?, + splitDescription: freezed == splitDescription + ? _value.splitDescription + : splitDescription // ignore: cast_nullable_to_non_nullable + as String?, + paymentOrderItems: freezed == paymentOrderItems + ? _value.paymentOrderItems + : paymentOrderItems // ignore: cast_nullable_to_non_nullable + as List?, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$PaymentRequestDtoImplCopyWith<$Res> + implements $PaymentRequestDtoCopyWith<$Res> { + factory _$$PaymentRequestDtoImplCopyWith( + _$PaymentRequestDtoImpl value, + $Res Function(_$PaymentRequestDtoImpl) then, + ) = __$$PaymentRequestDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @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? paymentOrderItems, + }); +} + +/// @nodoc +class __$$PaymentRequestDtoImplCopyWithImpl<$Res> + extends _$PaymentRequestDtoCopyWithImpl<$Res, _$PaymentRequestDtoImpl> + implements _$$PaymentRequestDtoImplCopyWith<$Res> { + __$$PaymentRequestDtoImplCopyWithImpl( + _$PaymentRequestDtoImpl _value, + $Res Function(_$PaymentRequestDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PaymentRequestDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? orderId = freezed, + Object? paymentMethodId = freezed, + Object? amount = freezed, + Object? transactionId = freezed, + Object? splitNumber = freezed, + Object? splitTotal = freezed, + Object? splitDescription = freezed, + Object? paymentOrderItems = freezed, + }) { + return _then( + _$PaymentRequestDtoImpl( + orderId: freezed == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodId: freezed == paymentMethodId + ? _value.paymentMethodId + : paymentMethodId // ignore: cast_nullable_to_non_nullable + as String?, + amount: freezed == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int?, + transactionId: freezed == transactionId + ? _value.transactionId + : transactionId // ignore: cast_nullable_to_non_nullable + as String?, + splitNumber: freezed == splitNumber + ? _value.splitNumber + : splitNumber // ignore: cast_nullable_to_non_nullable + as int?, + splitTotal: freezed == splitTotal + ? _value.splitTotal + : splitTotal // ignore: cast_nullable_to_non_nullable + as int?, + splitDescription: freezed == splitDescription + ? _value.splitDescription + : splitDescription // ignore: cast_nullable_to_non_nullable + as String?, + paymentOrderItems: freezed == paymentOrderItems + ? _value._paymentOrderItems + : paymentOrderItems // ignore: cast_nullable_to_non_nullable + as List?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$PaymentRequestDtoImpl extends _PaymentRequestDto { + const _$PaymentRequestDtoImpl({ + @JsonKey(name: "order_id") this.orderId, + @JsonKey(name: "payment_method_id") this.paymentMethodId, + @JsonKey(name: "amount") this.amount, + @JsonKey(name: "transaction_id") this.transactionId, + @JsonKey(name: "split_number") this.splitNumber, + @JsonKey(name: "split_total") this.splitTotal, + @JsonKey(name: "split_description") this.splitDescription, + @JsonKey(name: "payment_order_items") + final List? paymentOrderItems, + }) : _paymentOrderItems = paymentOrderItems, + super._(); + + factory _$PaymentRequestDtoImpl.fromJson(Map json) => + _$$PaymentRequestDtoImplFromJson(json); + + @override + @JsonKey(name: "order_id") + final String? orderId; + @override + @JsonKey(name: "payment_method_id") + final String? paymentMethodId; + @override + @JsonKey(name: "amount") + final int? amount; + @override + @JsonKey(name: "transaction_id") + final String? transactionId; + @override + @JsonKey(name: "split_number") + final int? splitNumber; + @override + @JsonKey(name: "split_total") + final int? splitTotal; + @override + @JsonKey(name: "split_description") + final String? splitDescription; + final List? _paymentOrderItems; + @override + @JsonKey(name: "payment_order_items") + List? get paymentOrderItems { + final value = _paymentOrderItems; + if (value == null) return null; + if (_paymentOrderItems is EqualUnmodifiableListView) + return _paymentOrderItems; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + String toString() { + return 'PaymentRequestDto(orderId: $orderId, paymentMethodId: $paymentMethodId, amount: $amount, transactionId: $transactionId, splitNumber: $splitNumber, splitTotal: $splitTotal, splitDescription: $splitDescription, paymentOrderItems: $paymentOrderItems)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentRequestDtoImpl && + (identical(other.orderId, orderId) || other.orderId == orderId) && + (identical(other.paymentMethodId, paymentMethodId) || + other.paymentMethodId == paymentMethodId) && + (identical(other.amount, amount) || other.amount == amount) && + (identical(other.transactionId, transactionId) || + other.transactionId == transactionId) && + (identical(other.splitNumber, splitNumber) || + other.splitNumber == splitNumber) && + (identical(other.splitTotal, splitTotal) || + other.splitTotal == splitTotal) && + (identical(other.splitDescription, splitDescription) || + other.splitDescription == splitDescription) && + const DeepCollectionEquality().equals( + other._paymentOrderItems, + _paymentOrderItems, + )); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + orderId, + paymentMethodId, + amount, + transactionId, + splitNumber, + splitTotal, + splitDescription, + const DeepCollectionEquality().hash(_paymentOrderItems), + ); + + /// Create a copy of PaymentRequestDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PaymentRequestDtoImplCopyWith<_$PaymentRequestDtoImpl> get copyWith => + __$$PaymentRequestDtoImplCopyWithImpl<_$PaymentRequestDtoImpl>( + this, + _$identity, + ); + + @override + Map toJson() { + return _$$PaymentRequestDtoImplToJson(this); + } +} + +abstract class _PaymentRequestDto extends PaymentRequestDto { + const factory _PaymentRequestDto({ + @JsonKey(name: "order_id") final String? orderId, + @JsonKey(name: "payment_method_id") final String? paymentMethodId, + @JsonKey(name: "amount") final int? amount, + @JsonKey(name: "transaction_id") final String? transactionId, + @JsonKey(name: "split_number") final int? splitNumber, + @JsonKey(name: "split_total") final int? splitTotal, + @JsonKey(name: "split_description") final String? splitDescription, + @JsonKey(name: "payment_order_items") + final List? paymentOrderItems, + }) = _$PaymentRequestDtoImpl; + const _PaymentRequestDto._() : super._(); + + factory _PaymentRequestDto.fromJson(Map json) = + _$PaymentRequestDtoImpl.fromJson; + + @override + @JsonKey(name: "order_id") + String? get orderId; + @override + @JsonKey(name: "payment_method_id") + String? get paymentMethodId; + @override + @JsonKey(name: "amount") + int? get amount; + @override + @JsonKey(name: "transaction_id") + String? get transactionId; + @override + @JsonKey(name: "split_number") + int? get splitNumber; + @override + @JsonKey(name: "split_total") + int? get splitTotal; + @override + @JsonKey(name: "split_description") + String? get splitDescription; + @override + @JsonKey(name: "payment_order_items") + List? get paymentOrderItems; + + /// Create a copy of PaymentRequestDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PaymentRequestDtoImplCopyWith<_$PaymentRequestDtoImpl> get copyWith => + throw _privateConstructorUsedError; +} + +PaymentItemRequestDto _$PaymentItemRequestDtoFromJson( + Map json, +) { + return _PaymentItemRequestDto.fromJson(json); +} + +/// @nodoc +mixin _$PaymentItemRequestDto { + @JsonKey(name: "order_item_id") + String? get orderItemId => throw _privateConstructorUsedError; + @JsonKey(name: "amount") + int? get amount => throw _privateConstructorUsedError; + + /// Serializes this PaymentItemRequestDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PaymentItemRequestDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PaymentItemRequestDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PaymentItemRequestDtoCopyWith<$Res> { + factory $PaymentItemRequestDtoCopyWith( + PaymentItemRequestDto value, + $Res Function(PaymentItemRequestDto) then, + ) = _$PaymentItemRequestDtoCopyWithImpl<$Res, PaymentItemRequestDto>; + @useResult + $Res call({ + @JsonKey(name: "order_item_id") String? orderItemId, + @JsonKey(name: "amount") int? amount, + }); +} + +/// @nodoc +class _$PaymentItemRequestDtoCopyWithImpl< + $Res, + $Val extends PaymentItemRequestDto +> + implements $PaymentItemRequestDtoCopyWith<$Res> { + _$PaymentItemRequestDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PaymentItemRequestDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? orderItemId = freezed, Object? amount = freezed}) { + return _then( + _value.copyWith( + orderItemId: freezed == orderItemId + ? _value.orderItemId + : orderItemId // ignore: cast_nullable_to_non_nullable + as String?, + amount: freezed == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int?, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$PaymentItemRequestDtoImplCopyWith<$Res> + implements $PaymentItemRequestDtoCopyWith<$Res> { + factory _$$PaymentItemRequestDtoImplCopyWith( + _$PaymentItemRequestDtoImpl value, + $Res Function(_$PaymentItemRequestDtoImpl) then, + ) = __$$PaymentItemRequestDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: "order_item_id") String? orderItemId, + @JsonKey(name: "amount") int? amount, + }); +} + +/// @nodoc +class __$$PaymentItemRequestDtoImplCopyWithImpl<$Res> + extends + _$PaymentItemRequestDtoCopyWithImpl<$Res, _$PaymentItemRequestDtoImpl> + implements _$$PaymentItemRequestDtoImplCopyWith<$Res> { + __$$PaymentItemRequestDtoImplCopyWithImpl( + _$PaymentItemRequestDtoImpl _value, + $Res Function(_$PaymentItemRequestDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PaymentItemRequestDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? orderItemId = freezed, Object? amount = freezed}) { + return _then( + _$PaymentItemRequestDtoImpl( + orderItemId: freezed == orderItemId + ? _value.orderItemId + : orderItemId // ignore: cast_nullable_to_non_nullable + as String?, + amount: freezed == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$PaymentItemRequestDtoImpl extends _PaymentItemRequestDto { + const _$PaymentItemRequestDtoImpl({ + @JsonKey(name: "order_item_id") this.orderItemId, + @JsonKey(name: "amount") this.amount, + }) : super._(); + + factory _$PaymentItemRequestDtoImpl.fromJson(Map json) => + _$$PaymentItemRequestDtoImplFromJson(json); + + @override + @JsonKey(name: "order_item_id") + final String? orderItemId; + @override + @JsonKey(name: "amount") + final int? amount; + + @override + String toString() { + return 'PaymentItemRequestDto(orderItemId: $orderItemId, amount: $amount)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentItemRequestDtoImpl && + (identical(other.orderItemId, orderItemId) || + other.orderItemId == orderItemId) && + (identical(other.amount, amount) || other.amount == amount)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, orderItemId, amount); + + /// Create a copy of PaymentItemRequestDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PaymentItemRequestDtoImplCopyWith<_$PaymentItemRequestDtoImpl> + get copyWith => + __$$PaymentItemRequestDtoImplCopyWithImpl<_$PaymentItemRequestDtoImpl>( + this, + _$identity, + ); + + @override + Map toJson() { + return _$$PaymentItemRequestDtoImplToJson(this); + } +} + +abstract class _PaymentItemRequestDto extends PaymentItemRequestDto { + const factory _PaymentItemRequestDto({ + @JsonKey(name: "order_item_id") final String? orderItemId, + @JsonKey(name: "amount") final int? amount, + }) = _$PaymentItemRequestDtoImpl; + const _PaymentItemRequestDto._() : super._(); + + factory _PaymentItemRequestDto.fromJson(Map json) = + _$PaymentItemRequestDtoImpl.fromJson; + + @override + @JsonKey(name: "order_item_id") + String? get orderItemId; + @override + @JsonKey(name: "amount") + int? get amount; + + /// Create a copy of PaymentItemRequestDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PaymentItemRequestDtoImplCopyWith<_$PaymentItemRequestDtoImpl> + get copyWith => throw _privateConstructorUsedError; +} + +PaymentDto _$PaymentDtoFromJson(Map json) { + return _PaymentOrderDto.fromJson(json); +} + +/// @nodoc +mixin _$PaymentDto { + @JsonKey(name: "id") + String? get id => throw _privateConstructorUsedError; + @JsonKey(name: "order_id") + String? get orderId => throw _privateConstructorUsedError; + @JsonKey(name: "payment_method_id") + String? get paymentMethodId => throw _privateConstructorUsedError; + @JsonKey(name: "payment_method_name") + String? get paymentMethodName => throw _privateConstructorUsedError; + @JsonKey(name: "payment_method_type") + String? get paymentMethodType => throw _privateConstructorUsedError; + @JsonKey(name: "amount") + int? get amount => throw _privateConstructorUsedError; + @JsonKey(name: "status") + String? get status => throw _privateConstructorUsedError; + @JsonKey(name: "split_number") + int? get splitNumber => throw _privateConstructorUsedError; + @JsonKey(name: "split_total") + int? get splitTotal => throw _privateConstructorUsedError; + @JsonKey(name: "split_description") + String? get splitDescription => throw _privateConstructorUsedError; + @JsonKey(name: "refund_amount") + int? get refundAmount => throw _privateConstructorUsedError; + @JsonKey(name: "metadata") + Map? get metadata => throw _privateConstructorUsedError; + @JsonKey(name: "created_at") + String? get createdAt => throw _privateConstructorUsedError; + @JsonKey(name: "updated_at") + String? get updatedAt => throw _privateConstructorUsedError; + + /// Serializes this PaymentDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PaymentDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PaymentDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PaymentDtoCopyWith<$Res> { + factory $PaymentDtoCopyWith( + PaymentDto value, + $Res Function(PaymentDto) then, + ) = _$PaymentDtoCopyWithImpl<$Res, PaymentDto>; + @useResult + $Res call({ + @JsonKey(name: "id") String? id, + @JsonKey(name: "order_id") String? orderId, + @JsonKey(name: "payment_method_id") String? paymentMethodId, + @JsonKey(name: "payment_method_name") String? paymentMethodName, + @JsonKey(name: "payment_method_type") String? paymentMethodType, + @JsonKey(name: "amount") int? amount, + @JsonKey(name: "status") String? status, + @JsonKey(name: "split_number") int? splitNumber, + @JsonKey(name: "split_total") int? splitTotal, + @JsonKey(name: "split_description") String? splitDescription, + @JsonKey(name: "refund_amount") int? refundAmount, + @JsonKey(name: "metadata") Map? metadata, + @JsonKey(name: "created_at") String? createdAt, + @JsonKey(name: "updated_at") String? updatedAt, + }); +} + +/// @nodoc +class _$PaymentDtoCopyWithImpl<$Res, $Val extends PaymentDto> + implements $PaymentDtoCopyWith<$Res> { + _$PaymentDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PaymentDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? orderId = freezed, + Object? paymentMethodId = freezed, + Object? paymentMethodName = freezed, + Object? paymentMethodType = freezed, + Object? amount = freezed, + Object? status = freezed, + Object? splitNumber = freezed, + Object? splitTotal = freezed, + Object? splitDescription = freezed, + Object? refundAmount = freezed, + Object? metadata = freezed, + Object? createdAt = freezed, + Object? updatedAt = freezed, + }) { + return _then( + _value.copyWith( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + orderId: freezed == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodId: freezed == paymentMethodId + ? _value.paymentMethodId + : paymentMethodId // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodName: freezed == paymentMethodName + ? _value.paymentMethodName + : paymentMethodName // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodType: freezed == paymentMethodType + ? _value.paymentMethodType + : paymentMethodType // ignore: cast_nullable_to_non_nullable + as String?, + amount: freezed == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + splitNumber: freezed == splitNumber + ? _value.splitNumber + : splitNumber // ignore: cast_nullable_to_non_nullable + as int?, + splitTotal: freezed == splitTotal + ? _value.splitTotal + : splitTotal // ignore: cast_nullable_to_non_nullable + as int?, + splitDescription: freezed == splitDescription + ? _value.splitDescription + : splitDescription // ignore: cast_nullable_to_non_nullable + as String?, + refundAmount: freezed == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int?, + metadata: freezed == metadata + ? _value.metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map?, + createdAt: freezed == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String?, + updatedAt: freezed == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String?, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$PaymentOrderDtoImplCopyWith<$Res> + implements $PaymentDtoCopyWith<$Res> { + factory _$$PaymentOrderDtoImplCopyWith( + _$PaymentOrderDtoImpl value, + $Res Function(_$PaymentOrderDtoImpl) then, + ) = __$$PaymentOrderDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + @JsonKey(name: "id") String? id, + @JsonKey(name: "order_id") String? orderId, + @JsonKey(name: "payment_method_id") String? paymentMethodId, + @JsonKey(name: "payment_method_name") String? paymentMethodName, + @JsonKey(name: "payment_method_type") String? paymentMethodType, + @JsonKey(name: "amount") int? amount, + @JsonKey(name: "status") String? status, + @JsonKey(name: "split_number") int? splitNumber, + @JsonKey(name: "split_total") int? splitTotal, + @JsonKey(name: "split_description") String? splitDescription, + @JsonKey(name: "refund_amount") int? refundAmount, + @JsonKey(name: "metadata") Map? metadata, + @JsonKey(name: "created_at") String? createdAt, + @JsonKey(name: "updated_at") String? updatedAt, + }); +} + +/// @nodoc +class __$$PaymentOrderDtoImplCopyWithImpl<$Res> + extends _$PaymentDtoCopyWithImpl<$Res, _$PaymentOrderDtoImpl> + implements _$$PaymentOrderDtoImplCopyWith<$Res> { + __$$PaymentOrderDtoImplCopyWithImpl( + _$PaymentOrderDtoImpl _value, + $Res Function(_$PaymentOrderDtoImpl) _then, + ) : super(_value, _then); + + /// Create a copy of PaymentDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = freezed, + Object? orderId = freezed, + Object? paymentMethodId = freezed, + Object? paymentMethodName = freezed, + Object? paymentMethodType = freezed, + Object? amount = freezed, + Object? status = freezed, + Object? splitNumber = freezed, + Object? splitTotal = freezed, + Object? splitDescription = freezed, + Object? refundAmount = freezed, + Object? metadata = freezed, + Object? createdAt = freezed, + Object? updatedAt = freezed, + }) { + return _then( + _$PaymentOrderDtoImpl( + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, + orderId: freezed == orderId + ? _value.orderId + : orderId // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodId: freezed == paymentMethodId + ? _value.paymentMethodId + : paymentMethodId // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodName: freezed == paymentMethodName + ? _value.paymentMethodName + : paymentMethodName // ignore: cast_nullable_to_non_nullable + as String?, + paymentMethodType: freezed == paymentMethodType + ? _value.paymentMethodType + : paymentMethodType // ignore: cast_nullable_to_non_nullable + as String?, + amount: freezed == amount + ? _value.amount + : amount // ignore: cast_nullable_to_non_nullable + as int?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + splitNumber: freezed == splitNumber + ? _value.splitNumber + : splitNumber // ignore: cast_nullable_to_non_nullable + as int?, + splitTotal: freezed == splitTotal + ? _value.splitTotal + : splitTotal // ignore: cast_nullable_to_non_nullable + as int?, + splitDescription: freezed == splitDescription + ? _value.splitDescription + : splitDescription // ignore: cast_nullable_to_non_nullable + as String?, + refundAmount: freezed == refundAmount + ? _value.refundAmount + : refundAmount // ignore: cast_nullable_to_non_nullable + as int?, + metadata: freezed == metadata + ? _value._metadata + : metadata // ignore: cast_nullable_to_non_nullable + as Map?, + createdAt: freezed == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as String?, + updatedAt: freezed == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as String?, + ), + ); + } +} + +/// @nodoc +@JsonSerializable() +class _$PaymentOrderDtoImpl extends _PaymentOrderDto { + const _$PaymentOrderDtoImpl({ + @JsonKey(name: "id") this.id, + @JsonKey(name: "order_id") this.orderId, + @JsonKey(name: "payment_method_id") this.paymentMethodId, + @JsonKey(name: "payment_method_name") this.paymentMethodName, + @JsonKey(name: "payment_method_type") this.paymentMethodType, + @JsonKey(name: "amount") this.amount, + @JsonKey(name: "status") this.status, + @JsonKey(name: "split_number") this.splitNumber, + @JsonKey(name: "split_total") this.splitTotal, + @JsonKey(name: "split_description") this.splitDescription, + @JsonKey(name: "refund_amount") this.refundAmount, + @JsonKey(name: "metadata") final Map? metadata, + @JsonKey(name: "created_at") this.createdAt, + @JsonKey(name: "updated_at") this.updatedAt, + }) : _metadata = metadata, + super._(); + + factory _$PaymentOrderDtoImpl.fromJson(Map json) => + _$$PaymentOrderDtoImplFromJson(json); + + @override + @JsonKey(name: "id") + final String? id; + @override + @JsonKey(name: "order_id") + final String? orderId; + @override + @JsonKey(name: "payment_method_id") + final String? paymentMethodId; + @override + @JsonKey(name: "payment_method_name") + final String? paymentMethodName; + @override + @JsonKey(name: "payment_method_type") + final String? paymentMethodType; + @override + @JsonKey(name: "amount") + final int? amount; + @override + @JsonKey(name: "status") + final String? status; + @override + @JsonKey(name: "split_number") + final int? splitNumber; + @override + @JsonKey(name: "split_total") + final int? splitTotal; + @override + @JsonKey(name: "split_description") + final String? splitDescription; + @override + @JsonKey(name: "refund_amount") + final int? refundAmount; + final Map? _metadata; + @override + @JsonKey(name: "metadata") + Map? get metadata { + final value = _metadata; + if (value == null) return null; + if (_metadata is EqualUnmodifiableMapView) return _metadata; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + @override + @JsonKey(name: "created_at") + final String? createdAt; + @override + @JsonKey(name: "updated_at") + final String? updatedAt; + + @override + String toString() { + return 'PaymentDto(id: $id, orderId: $orderId, paymentMethodId: $paymentMethodId, paymentMethodName: $paymentMethodName, paymentMethodType: $paymentMethodType, amount: $amount, status: $status, splitNumber: $splitNumber, splitTotal: $splitTotal, splitDescription: $splitDescription, refundAmount: $refundAmount, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaymentOrderDtoImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.orderId, orderId) || other.orderId == orderId) && + (identical(other.paymentMethodId, paymentMethodId) || + other.paymentMethodId == paymentMethodId) && + (identical(other.paymentMethodName, paymentMethodName) || + other.paymentMethodName == paymentMethodName) && + (identical(other.paymentMethodType, paymentMethodType) || + other.paymentMethodType == paymentMethodType) && + (identical(other.amount, amount) || other.amount == amount) && + (identical(other.status, status) || other.status == status) && + (identical(other.splitNumber, splitNumber) || + other.splitNumber == splitNumber) && + (identical(other.splitTotal, splitTotal) || + other.splitTotal == splitTotal) && + (identical(other.splitDescription, splitDescription) || + other.splitDescription == splitDescription) && + (identical(other.refundAmount, refundAmount) || + other.refundAmount == refundAmount) && + const DeepCollectionEquality().equals(other._metadata, _metadata) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + id, + orderId, + paymentMethodId, + paymentMethodName, + paymentMethodType, + amount, + status, + splitNumber, + splitTotal, + splitDescription, + refundAmount, + const DeepCollectionEquality().hash(_metadata), + createdAt, + updatedAt, + ); + + /// Create a copy of PaymentDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PaymentOrderDtoImplCopyWith<_$PaymentOrderDtoImpl> get copyWith => + __$$PaymentOrderDtoImplCopyWithImpl<_$PaymentOrderDtoImpl>( + this, + _$identity, + ); + + @override + Map toJson() { + return _$$PaymentOrderDtoImplToJson(this); + } +} + +abstract class _PaymentOrderDto extends PaymentDto { + const factory _PaymentOrderDto({ + @JsonKey(name: "id") final String? id, + @JsonKey(name: "order_id") final String? orderId, + @JsonKey(name: "payment_method_id") final String? paymentMethodId, + @JsonKey(name: "payment_method_name") final String? paymentMethodName, + @JsonKey(name: "payment_method_type") final String? paymentMethodType, + @JsonKey(name: "amount") final int? amount, + @JsonKey(name: "status") final String? status, + @JsonKey(name: "split_number") final int? splitNumber, + @JsonKey(name: "split_total") final int? splitTotal, + @JsonKey(name: "split_description") final String? splitDescription, + @JsonKey(name: "refund_amount") final int? refundAmount, + @JsonKey(name: "metadata") final Map? metadata, + @JsonKey(name: "created_at") final String? createdAt, + @JsonKey(name: "updated_at") final String? updatedAt, + }) = _$PaymentOrderDtoImpl; + const _PaymentOrderDto._() : super._(); + + factory _PaymentOrderDto.fromJson(Map json) = + _$PaymentOrderDtoImpl.fromJson; + + @override + @JsonKey(name: "id") + String? get id; + @override + @JsonKey(name: "order_id") + String? get orderId; + @override + @JsonKey(name: "payment_method_id") + String? get paymentMethodId; + @override + @JsonKey(name: "payment_method_name") + String? get paymentMethodName; + @override + @JsonKey(name: "payment_method_type") + String? get paymentMethodType; + @override + @JsonKey(name: "amount") + int? get amount; + @override + @JsonKey(name: "status") + String? get status; + @override + @JsonKey(name: "split_number") + int? get splitNumber; + @override + @JsonKey(name: "split_total") + int? get splitTotal; + @override + @JsonKey(name: "split_description") + String? get splitDescription; + @override + @JsonKey(name: "refund_amount") + int? get refundAmount; + @override + @JsonKey(name: "metadata") + Map? get metadata; + @override + @JsonKey(name: "created_at") + String? get createdAt; + @override + @JsonKey(name: "updated_at") + String? get updatedAt; + + /// Create a copy of PaymentDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PaymentOrderDtoImplCopyWith<_$PaymentOrderDtoImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/infrastructure/order/order_dtos.g.dart b/lib/infrastructure/order/order_dtos.g.dart index d7612c7..c0099ff 100644 --- a/lib/infrastructure/order/order_dtos.g.dart +++ b/lib/infrastructure/order/order_dtos.g.dart @@ -53,7 +53,7 @@ _$OrderDtoImpl _$$OrderDtoImplFromJson(Map json) => ?.map((e) => OrderItemDto.fromJson(e as Map)) .toList(), payments: (json['payments'] as List?) - ?.map((e) => PaymentOrderDto.fromJson(e as Map)) + ?.map((e) => PaymentDto.fromJson(e as Map)) .toList(), totalPaid: (json['total_paid'] as num?)?.toInt(), paymentCount: (json['payment_count'] as num?)?.toInt(), @@ -130,44 +130,6 @@ Map _$$OrderItemDtoImplToJson(_$OrderItemDtoImpl instance) => 'paid_quantity': instance.paidQuantity, }; -_$PaymentOrderDtoImpl _$$PaymentOrderDtoImplFromJson( - Map json, -) => _$PaymentOrderDtoImpl( - id: json['id'] as String?, - orderId: json['order_id'] as String?, - paymentMethodId: json['payment_method_id'] as String?, - paymentMethodName: json['payment_method_name'] as String?, - paymentMethodType: json['payment_method_type'] as String?, - amount: (json['amount'] as num?)?.toInt(), - status: json['status'] as String?, - splitNumber: (json['split_number'] as num?)?.toInt(), - splitTotal: (json['split_total'] as num?)?.toInt(), - splitDescription: json['split_description'] as String?, - refundAmount: (json['refund_amount'] as num?)?.toInt(), - metadata: json['metadata'] as Map?, - createdAt: json['created_at'] as String?, - updatedAt: json['updated_at'] as String?, -); - -Map _$$PaymentOrderDtoImplToJson( - _$PaymentOrderDtoImpl instance, -) => { - 'id': instance.id, - 'order_id': instance.orderId, - 'payment_method_id': instance.paymentMethodId, - 'payment_method_name': instance.paymentMethodName, - 'payment_method_type': instance.paymentMethodType, - 'amount': instance.amount, - 'status': instance.status, - 'split_number': instance.splitNumber, - 'split_total': instance.splitTotal, - 'split_description': instance.splitDescription, - 'refund_amount': instance.refundAmount, - 'metadata': instance.metadata, - 'created_at': instance.createdAt, - 'updated_at': instance.updatedAt, -}; - _$OrderRequestDtoImpl _$$OrderRequestDtoImplFromJson( Map json, ) => _$OrderRequestDtoImpl( @@ -215,3 +177,83 @@ Map _$$OrderItemRequestDtoImplToJson( 'unit_price': instance.unitPrice, 'notes': instance.notes, }; + +_$PaymentRequestDtoImpl _$$PaymentRequestDtoImplFromJson( + Map json, +) => _$PaymentRequestDtoImpl( + orderId: json['order_id'] as String?, + paymentMethodId: json['payment_method_id'] as String?, + amount: (json['amount'] as num?)?.toInt(), + transactionId: json['transaction_id'] as String?, + splitNumber: (json['split_number'] as num?)?.toInt(), + splitTotal: (json['split_total'] as num?)?.toInt(), + splitDescription: json['split_description'] as String?, + paymentOrderItems: (json['payment_order_items'] as List?) + ?.map((e) => PaymentItemRequestDto.fromJson(e as Map)) + .toList(), +); + +Map _$$PaymentRequestDtoImplToJson( + _$PaymentRequestDtoImpl instance, +) => { + 'order_id': instance.orderId, + 'payment_method_id': instance.paymentMethodId, + 'amount': instance.amount, + 'transaction_id': instance.transactionId, + 'split_number': instance.splitNumber, + 'split_total': instance.splitTotal, + 'split_description': instance.splitDescription, + 'payment_order_items': instance.paymentOrderItems, +}; + +_$PaymentItemRequestDtoImpl _$$PaymentItemRequestDtoImplFromJson( + Map json, +) => _$PaymentItemRequestDtoImpl( + orderItemId: json['order_item_id'] as String?, + amount: (json['amount'] as num?)?.toInt(), +); + +Map _$$PaymentItemRequestDtoImplToJson( + _$PaymentItemRequestDtoImpl instance, +) => { + 'order_item_id': instance.orderItemId, + 'amount': instance.amount, +}; + +_$PaymentOrderDtoImpl _$$PaymentOrderDtoImplFromJson( + Map json, +) => _$PaymentOrderDtoImpl( + id: json['id'] as String?, + orderId: json['order_id'] as String?, + paymentMethodId: json['payment_method_id'] as String?, + paymentMethodName: json['payment_method_name'] as String?, + paymentMethodType: json['payment_method_type'] as String?, + amount: (json['amount'] as num?)?.toInt(), + status: json['status'] as String?, + splitNumber: (json['split_number'] as num?)?.toInt(), + splitTotal: (json['split_total'] as num?)?.toInt(), + splitDescription: json['split_description'] as String?, + refundAmount: (json['refund_amount'] as num?)?.toInt(), + metadata: json['metadata'] as Map?, + createdAt: json['created_at'] as String?, + updatedAt: json['updated_at'] as String?, +); + +Map _$$PaymentOrderDtoImplToJson( + _$PaymentOrderDtoImpl instance, +) => { + 'id': instance.id, + 'order_id': instance.orderId, + 'payment_method_id': instance.paymentMethodId, + 'payment_method_name': instance.paymentMethodName, + 'payment_method_type': instance.paymentMethodType, + 'amount': instance.amount, + 'status': instance.status, + 'split_number': instance.splitNumber, + 'split_total': instance.splitTotal, + 'split_description': instance.splitDescription, + 'refund_amount': instance.refundAmount, + 'metadata': instance.metadata, + 'created_at': instance.createdAt, + 'updated_at': instance.updatedAt, +}; diff --git a/lib/infrastructure/order/repositories/order_repository.dart b/lib/infrastructure/order/repositories/order_repository.dart index dd7d2af..6289719 100644 --- a/lib/infrastructure/order/repositories/order_repository.dart +++ b/lib/infrastructure/order/repositories/order_repository.dart @@ -65,4 +65,27 @@ class OrderRepository implements IOrderRepository { return left(const OrderFailure.unexpectedError()); } } + + @override + Future> createOrderWithPayment({ + required OrderRequest request, + required String paymentMethodId, + }) async { + try { + final result = await _dataProvider.storeWithPaymentOrder( + request: OrderRequestDto.fromDomain(request), + paymentMethodId: paymentMethodId, + ); + + if (result.hasError) { + return left(result.error!); + } + + final order = result.data!.toDomain(); + return right(order); + } catch (e) { + log('createOrderError', name: _logName, error: e); + return left(const OrderFailure.unexpectedError()); + } + } } diff --git a/lib/presentation/pages/order/widgets/order_list_payment.dart b/lib/presentation/pages/order/widgets/order_list_payment.dart index 3a2f792..423b1c4 100644 --- a/lib/presentation/pages/order/widgets/order_list_payment.dart +++ b/lib/presentation/pages/order/widgets/order_list_payment.dart @@ -40,7 +40,7 @@ class OrderListPayment extends StatelessWidget { (index) => Padding( padding: const EdgeInsets.only(bottom: 8.0), child: _buildPaymentItem( - order?.payments[index] ?? PaymentOrder.empty(), + order?.payments[index] ?? Payment.empty(), ), ), ), @@ -124,7 +124,7 @@ class OrderListPayment extends StatelessWidget { } } - Row _buildPaymentItem(PaymentOrder payment) { + Row _buildPaymentItem(Payment payment) { return Row( children: [ Container(