import 'package:pshared/data/dto/payment/fx_quote.dart';
import 'package:pshared/data/mapper/money.dart';
import 'package:pshared/models/payment/fx/quote.dart';

extension FxQuoteDTOMapper on FxQuoteDTO {
  FxQuote toDomain() => FxQuote(
    quoteRef: quoteRef,
    baseCurrency: baseCurrency,
    quoteCurrency: quoteCurrency,
    side: side,
    price: price,
    baseAmount: baseAmount?.toDomain(),
    quoteAmount: quoteAmount?.toDomain(),
    expiresAtUnixMs: expiresAtUnixMs,
    pricedAtUnixMs: pricedAtUnixMs,
    provider: provider,
    rateRef: rateRef,
    firm: firm ?? false,
  );
}

extension FxQuoteMapper on FxQuote {
  FxQuoteDTO toDTO() => FxQuoteDTO(
    quoteRef: quoteRef,
    baseCurrency: baseCurrency,
    quoteCurrency: quoteCurrency,
    side: side,
    price: price,
    baseAmount: baseAmount?.toDTO(),
    quoteAmount: quoteAmount?.toDTO(),
    expiresAtUnixMs: expiresAtUnixMs,
    pricedAtUnixMs: pricedAtUnixMs,
    provider: provider,
    rateRef: rateRef,
    firm: firm,
  );
}
