UNPKG

cordova-plugin-qonversion

Version:
120 lines (119 loc) 4.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Product = void 0; const PurchaseModel_1 = require("./PurchaseModel"); const PurchaseUpdateModel_1 = require("./PurchaseUpdateModel"); class Product { qonversionID; storeID; /** * Identifier of the base plan for Google product. */ basePlanID; /** * Google Play Store details of this product. * Android only. Null for iOS, or if the product was not found. * Doesn't take into account {@link basePlanID}. * @deprecated Consider using {@link storeDetails} instead. */ skuDetails; /** * Google Play Store details of this product. * Android only. Null for iOS, or if the product was not found. */ storeDetails; /** * App store details of this product. * iOS only. Null for Android, or if the product was not found. */ skProduct; offeringId; /** * For Android - the subscription base plan duration. If the {@link basePlanID} is not specified, * the duration is calculated using the deprecated {@link skuDetails}. * For iOS - the duration of the {@link skProduct}. * Null, if it's not a subscription product or the product was not found in the store. */ subscriptionPeriod; /** * The subscription trial duration of the default offer for Android or of the product for iOS. * See {@link ProductStoreDetails.defaultSubscriptionOfferDetails} for the information on how we * choose the default offer for Android. * Null, if it's not a subscription product or the product was not found the store. */ trialPeriod; /** * The calculated type of this product based on the store information. * On Android uses deprecated {@link skuDetails} for the old subscription products * where {@link basePlanID} is not specified, and {@link storeDetails} for all the other products. * On iOS uses {@link skProduct} information. */ type; /** * Formatted price of for this product, including the currency sign. */ prettyPrice; price; currencyCode; storeTitle; storeDescription; prettyIntroductoryPrice; constructor(qonversionID, storeID, basePlanID, skuDetails, storeDetails, skProduct, offeringId, subscriptionPeriod, trialPeriod, type, prettyPrice, price, currencyCode, storeTitle, storeDescription, prettyIntroductoryPrice) { this.qonversionID = qonversionID; this.storeID = storeID; this.basePlanID = basePlanID; this.skuDetails = skuDetails; this.storeDetails = storeDetails; this.skProduct = skProduct; this.offeringId = offeringId; this.subscriptionPeriod = subscriptionPeriod; this.trialPeriod = trialPeriod; this.type = type; this.prettyPrice = prettyPrice; this.price = price; this.currencyCode = currencyCode; this.storeTitle = storeTitle; this.storeDescription = storeDescription; this.prettyIntroductoryPrice = prettyIntroductoryPrice; } /** * Converts this product to purchase model to pass to {@link Qonversion.purchase}. * @param offerId concrete Android offer identifier if necessary. * If the products' base plan id is specified, but offer id is not provided for * purchase, then default offer will be used. * Ignored if base plan id is not specified. * Ignored for iOS. * To know how we choose the default offer, see {@link ProductStoreDetails.defaultSubscriptionOfferDetails}. * @returns purchase model to pass to the purchase method. */ toPurchaseModel(offerId = null) { return new PurchaseModel_1.PurchaseModel(this.qonversionID, offerId); } /** * Converts this product to purchase model to pass to {@link Qonversion.purchase}. * @param offer concrete Android offer which you'd like to purchase. * @return purchase model to pass to the purchase method. */ toPurchaseModelWithOffer(offer) { const model = this.toPurchaseModel(offer.offerId); // Remove offer for the case when provided offer details are for bare base plan. if (offer.offerId == null) { model.removeOffer(); } return model; } /** * Android only. * * Converts this product to purchase update (upgrade/downgrade) model * to pass to {@link Qonversion.updatePurchase}. * @param oldProductId Qonversion product identifier from which the upgrade/downgrade * will be initialized. * @param updatePolicy purchase update policy. * @return purchase model to pass to the update purchase method. */ toPurchaseUpdateModel(oldProductId, updatePolicy = null) { return new PurchaseUpdateModel_1.PurchaseUpdateModel(this.qonversionID, oldProductId, updatePolicy); } } exports.Product = Product;