@namiml/web-sdk
Version:
Nami Web SDK makes subscriptions & in-app purchases easy, with powerful built-in paywalls and A/B testing
56 lines (55 loc) • 2.58 kB
TypeScript
import { IEntitlements, NamiEntitlement } from "../../types/entitlements";
import { NamiPurchase } from "../../types/externals/purchase";
import { PaywallSKU, SKU } from "../../types/sku";
import { NamiSKU } from "../../types/externals/sku";
export declare class EntitlementUtils {
static instance: EntitlementUtils;
refIdToPurchasedSKUs: {
[key: string]: NamiSKU[];
};
refIdToRelatedSKUs: {
[key: string]: NamiSKU[];
};
refIdToActivePurchases: {
[key: string]: NamiPurchase[];
};
}
export declare const toNamiEntitlements: (entitlement: IEntitlements) => NamiEntitlement;
export declare const setActiveNamiEntitlements: (entitlements: NamiEntitlement[]) => void;
export declare const activeEntitlements: () => NamiEntitlement[];
export declare const invokeHandler: () => void;
export declare const getEntitlementRefIdsForSku: (purchasedSkuId: string) => string[];
/**
* Populate a list of [NamiEntitlement] from the entitlements that have been provided by the
* app config. Also clears any previous list of [NamiEntitlement] from cache
*/
export declare const createNamiEntitlements: (entitlements?: IEntitlements[]) => NamiEntitlement[];
/**
* For namiPurchase instance, it will have a purchasedSKU that will back the activation of
* the entitlement.
*
* The purchaseSku (pSKU) can then be used to retrieve all entitlements activated by that pSKU
*
* The entitlement will then be inspected to see if pSKU has yet to be tracked by that
* entitlement. If it has not, then it will be added.
*
* The entitlement will then be inspected to see if there any active purchases that match
* the NamiSKU. If there isn't any, then the NamiPurchase is then added to the
* entitlement's list of active purchases
*/
export declare const applyEntitlementActivation: (namiPurchase: NamiPurchase) => string[];
/**
* Using the Nami Purchase object, look up the corresponding NamiSKU
* and set the NamiEntitlement associated to NamiSKU as an active entitlement
*
* @return List of strings where each string is a reference Id of an entitlement
* that was just successfully activated
*/
export declare const activateEntitlementByPurchase: (purchase: NamiPurchase) => string[];
export declare const skuMapFromEntitlements: (entitlements?: IEntitlements[]) => {
[key: string]: NamiSKU[];
};
export declare const updateRelatedSKUsForNamiEntitlement: (entitlementRefId: string, entitlementRefIdToNamiSkus: {
[key: string]: NamiSKU[];
}) => void;
export declare function toNamiSKU(sku: PaywallSKU | SKU): NamiSKU;