UNPKG

@magicbell/core

Version:

Official MagicBell API wrapper

39 lines 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const camelize_js_1 = tslib_1.__importDefault(require("../../lib/decorators/camelize.js")); const unwrap_js_1 = tslib_1.__importDefault(require("../../lib/decorators/unwrap.js")); const NotificationPreferencesRepository_js_1 = tslib_1.__importDefault(require("./NotificationPreferencesRepository.js")); /** * A representation of notification preferences. * * @example * const preferences = new NotificationPreferences() * await preferences.fetch() */ class NotificationPreferences { categories; repo; constructor(attrs) { this.set(attrs); this.repo = new NotificationPreferencesRepository_js_1.default(); } async fetch() { const json = await this.repo.get(); this.set(json); } async save(data) { const payload = { notification_preferences: data }; const json = await this.repo.update(payload); this.set(json); } set(json = {}) { Object.assign(this, json); } } exports.default = NotificationPreferences; tslib_1.__decorate([ (0, unwrap_js_1.default)('notification_preferences'), (0, camelize_js_1.default)() ], NotificationPreferences.prototype, "set", null); //# sourceMappingURL=NotificationPreferences.js.map