@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
87 lines (86 loc) • 3.47 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.BluestackPreference = void 0;
var _Validate = require("./Common/Validate");
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); }
const gender = ['Male', 'Female', 'Unknown'];
const provider = ['', 'network', 'full', 'gps', 'passive'];
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 (!(0, _Validate.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 (!(0, _Validate.isNumber)(location.latitude)) {
throw new Error('`latitude` expects a number value');
} else if (!(0, _Validate.isNumber)(location.longitude)) {
throw new Error('`longitude` expects a number value');
} else {
this.location = location;
}
if (!(0, _Validate.isNumber)(consentFlag)) {
throw new Error('`consentFlag` expects a number value');
} else {
this.consentFlag = consentFlag;
}
}
setLanguage(language) {
if (!(0, _Validate.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 (!(0, _Validate.isString)(keyword)) {
throw new Error('`keyword` expects a string value');
} else {
this.keyword = keyword;
}
}
setContentUrl(contentUrl) {
if (!(0, _Validate.isString)(contentUrl)) {
throw new Error('`contentUrl` expects a string value');
} else if (!(0, _Validate.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;
}
}
exports.BluestackPreference = BluestackPreference;
//# sourceMappingURL=Preference.js.map