import 'package:pshared/data/dto/payment/intent/payment.dart';
import 'package:pshared/data/mapper/payment/fees/treatment.dart';
import 'package:pshared/data/mapper/payment/payment.dart';
import 'package:pshared/data/mapper/payment/enums.dart';
import 'package:pshared/data/mapper/payment/intent/customer.dart';
import 'package:pshared/data/mapper/payment/intent/fx.dart';
import 'package:pshared/data/mapper/money.dart';
import 'package:pshared/models/payment/intent.dart';

extension PaymentIntentMapper on PaymentIntent {
  PaymentIntentDTO toDTO() => PaymentIntentDTO(
    kind: paymentKindToValue(kind),
    source: source?.toDTO(),
    destination: destination?.toDTO(),
    amount: amount?.toDTO(),
    fx: fx?.toDTO(),
    settlementMode: settlementModeToValue(settlementMode),
    attributes: attributes,
    comment: comment,
    customer: customer?.toDTO(),
    feeTreatment: feeTreatmentToValue(feeTreatment),
  );
}

extension PaymentIntentDTOMapper on PaymentIntentDTO {
  PaymentIntent toDomain() => PaymentIntent(
    kind: paymentKindFromValue(kind),
    source: source?.toDomain(),
    destination: destination?.toDomain(),
    amount: amount?.toDomain(),
    fx: fx?.toDomain(),
    settlementMode: settlementModeFromValue(settlementMode),
    attributes: attributes,
    comment: comment,
    customer: customer?.toDomain(),
    feeTreatment: feeTreatmentFromValue(feeTreatment),
  );
}
