115 lines
3.5 KiB
TypeScript
115 lines
3.5 KiB
TypeScript
// Metro module 3836 (f3837).
|
|
import Record from "../lib/Record";
|
|
import { PremiumSubscriptionSKUs, PremiumTypes, SubscriptionPlans } from "../modules/premium/PremiumConstants";
|
|
import { $callWithNewTarget } from "../_hermes/prelude";
|
|
class SubscriptionPlanRecord extends Record {
|
|
constructor(a0) {
|
|
super();
|
|
this.id = a0.id;
|
|
this.name = a0.name;
|
|
this.interval = a0.interval;
|
|
this.intervalCount = a0.intervalCount;
|
|
this.taxInclusive = a0.taxInclusive;
|
|
this.skuId = a0.skuId;
|
|
this.currency = a0.currency;
|
|
this.price = a0.price;
|
|
this.prices = a0.prices;
|
|
}
|
|
static createFromServer(a0) {
|
|
const prices = a0.prices != null ? Object.keys(a0.prices).reduce((acc, item) => {
|
|
if (a0.prices == null) {
|
|
return acc;
|
|
}
|
|
const r5 = a0.prices[item];
|
|
acc[item] = {
|
|
countryPrices: {
|
|
countryCode: r5.country_prices.country_code,
|
|
prices: r5.country_prices.prices.map((price) => ({
|
|
amount: price.amount,
|
|
currency: price.currency,
|
|
tax: 0,
|
|
taxInclusive: a0.tax_inclusive
|
|
}))
|
|
},
|
|
paymentSourcePrices: Object.entries(r5.payment_source_prices).reduce((acc, a1) => {
|
|
const [r22, r7] = a1;
|
|
acc[r22] = r7.map((item) => ({
|
|
amount: item.amount,
|
|
currency: item.currency,
|
|
tax: 0,
|
|
taxInclusive: a0.tax_inclusive
|
|
}));
|
|
return acc;
|
|
}, {})
|
|
};
|
|
return acc;
|
|
}, {}) : {};
|
|
const { id, name, interval, interval_count, tax_inclusive, sku_id, currency, price } = a0;
|
|
const prototypeOf = Object.getPrototypeOf(SubscriptionPlanRecord);
|
|
const r30 = Object.create(SubscriptionPlanRecord.prototype);
|
|
const r31 = $callWithNewTarget(prototypeOf, r30, SubscriptionPlanRecord);
|
|
const r32 = r31 instanceof Object ? r31 : r30;
|
|
r32.id = id;
|
|
r32.name = name;
|
|
r32.interval = interval;
|
|
r32.intervalCount = interval_count;
|
|
r32.taxInclusive = tax_inclusive;
|
|
r32.skuId = sku_id;
|
|
r32.currency = currency;
|
|
r32.price = price;
|
|
r32.prices = prices;
|
|
return r32;
|
|
}
|
|
get premiumSubscriptionType() {
|
|
const skuId = this.skuId;
|
|
if (PremiumSubscriptionSKUs.LEGACY !== skuId && PremiumSubscriptionSKUs.TIER_2 !== skuId) {
|
|
if (PremiumSubscriptionSKUs.TIER_1 === skuId) {
|
|
return PremiumTypes.TIER_1;
|
|
}
|
|
if (PremiumSubscriptionSKUs.TIER_0 === skuId) {
|
|
return PremiumTypes.TIER_0;
|
|
}
|
|
return null;
|
|
}
|
|
return PremiumTypes.TIER_2;
|
|
}
|
|
toServerData() {
|
|
const prices = {};
|
|
let c13663_0 = prices;
|
|
Object.keys(this.prices).forEach((item) => {
|
|
const r4 = this.prices[item];
|
|
c13663_0[item] = {
|
|
country_prices: {
|
|
country_code: r4.countryPrices.countryCode,
|
|
prices: r4.countryPrices.prices
|
|
},
|
|
payment_source_prices: r4.paymentSourcePrices
|
|
};
|
|
});
|
|
return {
|
|
id: this.id,
|
|
name: this.name,
|
|
sku_id: this.skuId,
|
|
interval: this.interval,
|
|
interval_count: this.intervalCount,
|
|
tax_inclusive: this.taxInclusive,
|
|
currency: this.currency,
|
|
price: this.price,
|
|
prices,
|
|
price_tier: this.price
|
|
};
|
|
}
|
|
}
|
|
export default SubscriptionPlanRecord;
|
|
export function getPriceFromServer(a0, a1) {
|
|
return {
|
|
amount: a0.amount,
|
|
currency: a0.currency,
|
|
tax: 0,
|
|
taxInclusive: a1
|
|
};
|
|
}
|
|
export function isNoneSubscription(a0) {
|
|
return [SubscriptionPlans.NONE_MONTH, SubscriptionPlans.NONE_3_MONTH, SubscriptionPlans.NONE_6_MONTH, SubscriptionPlans.NONE_YEAR].includes(a0);
|
|
}
|