package com.red.circle.order.infra.convertor;

import com.google.api.services.androidpublisher.model.ProductPurchase;
import com.google.api.services.androidpublisher.model.SubscriptionPurchase;
import com.red.circle.component.pay.apple.LatestReceiptInfo;
import com.red.circle.component.pay.apple.PendingRenewalInfo;
import com.red.circle.framework.core.convertor.ConvertorModel;
import com.red.circle.order.domain.order.PurchaseHistory;
import com.red.circle.order.infra.database.rds.entity.order.OrderAppleLatestReceipt;
import com.red.circle.order.infra.database.rds.entity.order.OrderApplePendingRenewalInfo;
import com.red.circle.order.infra.database.rds.entity.order.OrderGoogleLatestPurchase;
import com.red.circle.order.infra.database.rds.entity.order.OrderGoogleLatestSubscription;
import com.red.circle.order.infra.database.rds.entity.order.OrderPurchaseHistory;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

/**
 * @author pengliang on 2020/3/20 14:52
 */
@Mapper(componentModel = ConvertorModel.SPRING)
public interface OrderPurchaseHistoryInfraConvertor {

  @Mappings({
      @Mapping(target = "expiresDateMs", source = "expiresDateMs", ignore = true),
      @Mapping(target = "purchaseDateMs", source = "purchaseDateMs", ignore = true)
  })
  OrderAppleLatestReceipt toOrderAppleLatestReceipt(LatestReceiptInfo latestReceiptInfo);

  OrderApplePendingRenewalInfo toOrderApplePendingRenewalInfo(
      PendingRenewalInfo pendingRenewalInfo);

  PurchaseHistory toPurchaseHistory(OrderPurchaseHistory orderPurchaseHistory);

  OrderPurchaseHistory toOrderPurchaseHistory(PurchaseHistory purchaseHistory);

  OrderGoogleLatestPurchase toOrderGoogleLatestPurchase(ProductPurchase productPurchase);

  OrderGoogleLatestSubscription toOrderGoogleLatestPurchase(
      SubscriptionPurchase subscriptionPurchase);

}
