UNPKG

@azerion/bluestack-sdk-react-native

Version:

BlueStack provides functionalities for monetizing your mobile application: from premium sales with rich media, video and innovative formats, it facilitates inserting native mobile ads as well all standard display formats. BlueStack SDK is a library that a

80 lines 3.23 kB
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } import { isString, isNumber, isValidUrl, isValidISOCode } from './Common/Validate'; const gender = ['Male', 'Female', 'Unknown']; const provider = ['', 'network', 'full', 'gps', 'passive']; export class BluestackPreference { constructor() { _defineProperty(this, "age", void 0); _defineProperty(this, "location", void 0); _defineProperty(this, "consentFlag", void 0); _defineProperty(this, "language", void 0); _defineProperty(this, "gender", void 0); _defineProperty(this, "keyword", void 0); _defineProperty(this, "contentUrl", void 0); _defineProperty(this, "isProviderType", x => provider.includes(x)); _defineProperty(this, "isGenderType", x => gender.includes(x)); } setAge(age) { if (!isNumber(age)) { throw new Error('`age` expects a number value'); } else { this.age = age; } } setLocation(location, consentFlag) { if (!this.isProviderType(location.provider)) { throw new Error('`provider` expects a number value'); } else if (!isNumber(location.latitude)) { throw new Error('`latitude` expects a number value'); } else if (!isNumber(location.longitude)) { throw new Error('`longitude` expects a number value'); } else { this.location = location; } if (!isNumber(consentFlag)) { throw new Error('`consentFlag` expects a number value'); } else { this.consentFlag = consentFlag; } } setLanguage(language) { if (!isValidISOCode(language)) { throw new Error('`language` expects a (ISO Code) string value. Example: `en`'); } else { this.language = language; } } setGender(g) { if (this.isGenderType(g)) { this.gender = g; } else { throw new Error('`gender` expects a (Male, Female, Unknown) GenderType value'); } } setKeyword(keyword) { if (!isString(keyword)) { throw new Error('`keyword` expects a string value'); } else { this.keyword = keyword; } } setContentUrl(contentUrl) { if (!isString(contentUrl)) { throw new Error('`contentUrl` expects a string value'); } else if (!isValidUrl(contentUrl)) { throw new Error('`contentUrl` expects a valid HTTP or HTTPS url.'); } else if (contentUrl.length > 512) { throw new Error('Maximum length of a `contentUrl` is 512 characters.'); } else { this.contentUrl = contentUrl; } } getPreferenceJSON() { const preferenceJSON = JSON.stringify(this); // console.log('BluestackPreference.getMNGPreference(): ' + preferenceJSON); return preferenceJSON; } } //# sourceMappingURL=Preference.js.map