@qonversion/capacitor-plugin
Version:
Qonversion provides full in-app purchases infrastructure, so you do not need to build your own server for receipt validation. Implement in-app subscriptions, validate user receipts, check subscription status, and provide access to your app features and co
34 lines • 1.44 kB
JavaScript
import { UserPropertyKey } from './enums';
export class UserProperties {
constructor(properties) {
this.properties = properties;
this.definedProperties = properties.filter(property => property.definedKey !== UserPropertyKey.CUSTOM);
this.customProperties = properties.filter(property => property.definedKey === UserPropertyKey.CUSTOM);
this.flatPropertiesMap = new Map();
this.flatDefinedPropertiesMap = new Map();
this.flatCustomPropertiesMap = new Map();
properties.forEach(property => {
this.flatPropertiesMap.set(property.key, property.value);
if (property.definedKey == UserPropertyKey.CUSTOM) {
this.flatCustomPropertiesMap.set(property.key, property.value);
}
else {
this.flatDefinedPropertiesMap.set(property.definedKey, property.value);
}
});
}
/**
* Searches for a property with the given property {@link key} in all properties list.
*/
getProperty(key) {
return this.properties.find(userProperty => userProperty.key == key);
}
/**
* Searches for a property with the given Qonversion defined property {@link key}
* in defined properties list.
*/
getDefinedProperty(key) {
return this.definedProperties.find(userProperty => userProperty.definedKey == key);
}
}
//# sourceMappingURL=UserProperties.js.map