UNPKG

@braze/web-sdk

Version:

Braze SDK for web sites and other JS platforms.

57 lines (56 loc) 1.38 kB
import { logger as E } from "../../shared-lib/index.js"; export class PropertiesBase { constructor(t) { (this.properties = t), (this.properties = t || {}); } tp(t, r, e) { const o = this.properties[t]; return null == o ? (this.rp(t), null) : r(o) ? o.value : (this.ep(e), null); } getStringProperty(t) { return this.tp(t, this.op, "string"); } getNumberProperty(t) { return this.tp(t, this.sp, "number"); } getBooleanProperty(t) { return this.tp(t, this.ip, "boolean"); } getImageProperty(t) { return this.tp(t, this.np, "image"); } getJsonProperty(t) { return this.tp(t, this.pp, "jsonobject"); } getTimestampProperty(t) { return this.tp(t, this.up, "datetime"); } ep(t) { E.info(`Property is not of type ${t}.`); } rp(t) { E.info(`${t} not found in properties.`); } op(t) { return "string" === t.type && "string" == typeof t.value; } sp(t) { return "number" === t.type && "number" == typeof t.value; } ip(t) { return "boolean" === t.type && "boolean" == typeof t.value; } np(t) { return "image" === t.type && "string" == typeof t.value; } pp(t) { return ( "jsonobject" === t.type && "object" == typeof t.value && t.value.constructor == Object ); } up(t) { return "datetime" === t.type && "number" == typeof t.value; } }