UNPKG

ih-black-lion

Version:

State handler for Arus projects

38 lines (31 loc) 898 B
import { isArrayLike, mapObj } from 'ramda'; export class Event { constructor(obj) { this.id = obj.sccNtfevtReqId; this.data = obj.data; this.status = obj.sccNtfevtStatus; this.startDate = obj.sccNtfevtStartdt; this.message = obj.sccNtfevtMessage; } } export default class Events { constructor(obj) { const evtObj = obj.sccNtfGetEventsResp; this.totalEventsCount = evtObj.totalEventsCount; this.readEventsCount = evtObj.readEventsCount; this.unreadEventsCount = evtObj.unreadEventsCount; this.events = {}; let length = 0; const items = evtObj.sccNtfEvent; if (isArrayLike(items)) { this.events = mapObj((evt) => { ++length; return new Event(evt); }, items); } else if (typeof items === 'object') { ++length; this.events['0'] = new Event(items); } this.events.length = length; } }