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 || {}); } To(t, r, e) { const o = this.properties[t]; return null == o ? (this.No(t), null) : r(o) ? o.value : (this.Oo(e), null); } getStringProperty(t) { return this.To(t, this.Fo, "string"); } getNumberProperty(t) { return this.To(t, this.Go, "number"); } getBooleanProperty(t) { return this.To(t, this.Ho, "boolean"); } getImageProperty(t) { return this.To(t, this.Ko, "image"); } getJsonProperty(t) { return this.To(t, this.Lo, "jsonobject"); } getTimestampProperty(t) { return this.To(t, this.Qo, "datetime"); } Oo(t) { E.info(`Property is not of type ${t}.`); } No(t) { E.info(`${t} not found in properties.`); } Fo(t) { return "string" === t.type && "string" == typeof t.value; } Go(t) { return "number" === t.type && "number" == typeof t.value; } Ho(t) { return "boolean" === t.type && "boolean" == typeof t.value; } Ko(t) { return "image" === t.type && "string" == typeof t.value; } Lo(t) { return ( "jsonobject" === t.type && "object" == typeof t.value && t.value.constructor == Object ); } Qo(t) { return "datetime" === t.type && "number" == typeof t.value; } }