// Metro module 5826 (f5827). import CollectiblesBundledProductRecord from "./CollectiblesBundledProductRecord"; import { createCollectiblesItemsFromServerResponse } from "./CollectiblesItemRecord"; import { CollectiblesVariantProductRecord } from "./CollectiblesProductRecord"; import { REWARD_CATEGORY_AND_REWARD_SKU_IDS } from "../CollectiblesShopConstants"; import { PREMIUM_TYPE_NONE } from "../../../Constants"; import getPricesFromServer from "../../skus/utils/getPricesFromServer"; class CollectiblesPurchaseRecord { constructor(a0) { this.skuId = a0.skuId; this.name = a0.name; this.type = a0.type; this.premiumType = a0.premiumType; this.items = a0.items; this.categorySkuId = a0.categorySkuId; this.isCategoryReward = a0.isCategoryReward; this.prices = a0.prices; this.bundledProducts = a0.bundledProducts; this.googleSkuIds = a0.googleSkuIds; this.variants = a0.variants; this.eligibleOffers = a0.eligibleOffers; this.baseVariantName = a0.baseVariantName; this.baseVariantSkuId = a0.baseVariantSkuId; this.variantLabel = a0.variantLabel; this.variantValue = a0.variantValue; this.purchasedAt = a0.purchasedAt; this.purchaseType = a0.purchaseType; this.expiresAt = a0.expiresAt; } static fromServer({ type, sku_id, name, premium_type, category_sku_id, prices, bundled_products, variants, base_variant_name, base_variant_sku_id, variant_label, variant_value, purchased_at, purchase_type, expires_at, ...rest }) { const premiumType = premium_type !== PREMIUM_TYPE_NONE ? premium_type : null; const isCategoryReward = REWARD_CATEGORY_AND_REWARD_SKU_IDS.some((item) => item.rewardSkuId === sku_id); const pricesFromServer = getPricesFromServer(prices); const collectiblesItemsFromServerResponse = createCollectiblesItemsFromServerResponse(rest.items); const bundledProducts = bundled_products == null ? void 0 : bundled_products.map(CollectiblesBundledProductRecord.fromServer); const variants2 = variants == null ? void 0 : variants.map(CollectiblesVariantProductRecord.fromServer); const { google_sku_ids, eligible_offers } = rest; let purchasedAt = purchased_at; if (purchasedAt != null) { purchasedAt = new Date(purchased_at); } const expiresAt = expires_at != null ? new Date(expires_at) : null; const r70 = { __proto__: CollectiblesPurchaseRecord.prototype }; r70.skuId = sku_id; r70.name = name; r70.type = type; r70.premiumType = premiumType; r70.items = collectiblesItemsFromServerResponse; r70.categorySkuId = category_sku_id; r70.isCategoryReward = isCategoryReward; r70.prices = pricesFromServer; r70.bundledProducts = bundledProducts; r70.googleSkuIds = google_sku_ids; r70.variants = variants2; r70.eligibleOffers = eligible_offers; r70.baseVariantName = base_variant_name; r70.baseVariantSkuId = base_variant_sku_id; r70.variantLabel = variant_label; r70.variantValue = variant_value; r70.purchasedAt = purchasedAt; r70.purchaseType = purchase_type; r70.expiresAt = expiresAt; return r70; } } export default CollectiblesPurchaseRecord;