build method

Implementation

RequestPurchaseProps build() {
  final iosProps = ios.sku.isNotEmpty ? ios.build() : null;
  final androidProps = android.skus.isNotEmpty ? android.build() : null;

  if (_type == ProductQueryType.InApp) {
    return RequestPurchaseProps.inApp((
      ios: iosProps,
      android: androidProps,
      useAlternativeBilling: useAlternativeBilling,
    ));
  }

  if (_type == ProductQueryType.Subs) {
    final iosSub = iosProps == null
        ? null
        : RequestSubscriptionIosProps(
            sku: iosProps.sku,
            andDangerouslyFinishTransactionAutomatically:
                iosProps.andDangerouslyFinishTransactionAutomatically,
            appAccountToken: iosProps.appAccountToken,
            quantity: iosProps.quantity,
            withOffer: iosProps.withOffer,
          );

    final androidSub = androidProps == null
        ? null
        : RequestSubscriptionAndroidProps(
            skus: androidProps.skus,
            isOfferPersonalized: androidProps.isOfferPersonalized,
            obfuscatedAccountIdAndroid:
                androidProps.obfuscatedAccountIdAndroid,
            obfuscatedProfileIdAndroid:
                androidProps.obfuscatedProfileIdAndroid,
            purchaseTokenAndroid: null,
            replacementModeAndroid: null,
            subscriptionOffers: null,
          );

    return RequestPurchaseProps.subs((
      ios: iosSub,
      android: androidSub,
      useAlternativeBilling: useAlternativeBilling,
    ));
  }

  throw ArgumentError(
    'ProductQueryType.All is not supported in RequestPurchaseBuilder. '
    'Use RequestSubscriptionBuilder or specify ProductType.InApp/ProductType.Subs explicitly.',
  );
}