@braze/web-sdk
Version:
Braze SDK for web sites and other JS platforms.
57 lines (56 loc) • 1.38 kB
JavaScript
import { logger as E } from "../../shared-lib/index.js";
export class PropertiesBase {
constructor(t) {
(this.properties = t), (this.properties = t || {});
}
Oo(t, r, e) {
const o = this.properties[t];
return null == o ? (this.Ko(t), null) : r(o) ? o.value : (this.Lo(e), null);
}
getStringProperty(t) {
return this.Oo(t, this.Qo, "string");
}
getNumberProperty(t) {
return this.Oo(t, this.Ro, "number");
}
getBooleanProperty(t) {
return this.Oo(t, this.Xo, "boolean");
}
getImageProperty(t) {
return this.Oo(t, this.Yo, "image");
}
getJsonProperty(t) {
return this.Oo(t, this.Zo, "jsonobject");
}
getTimestampProperty(t) {
return this.Oo(t, this.tp, "datetime");
}
Lo(t) {
E.info(`Property is not of type ${t}.`);
}
Ko(t) {
E.info(`${t} not found in properties.`);
}
Qo(t) {
return "string" === t.type && "string" == typeof t.value;
}
Ro(t) {
return "number" === t.type && "number" == typeof t.value;
}
Xo(t) {
return "boolean" === t.type && "boolean" == typeof t.value;
}
Yo(t) {
return "image" === t.type && "string" == typeof t.value;
}
Zo(t) {
return (
"jsonobject" === t.type &&
"object" == typeof t.value &&
t.value.constructor == Object
);
}
tp(t) {
return "datetime" === t.type && "number" == typeof t.value;
}
}