All files / models Notifications.js

0% Statements 0/17
0% Branches 0/2
0% Functions 0/3
0% Lines 0/17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                                                                   
import { isArrayLike, mapObj } from 'ramda';
 
export class Notification {
  constructor(obj) {
    this.id = obj.sccNtfreqId;
    this.tag = obj.sccNtfreqItmTag;
    this.type = obj.sccNtfreqType;
    this.importance = obj.sccNtfreqImptnce;
    this.dateTime = obj.sccRowAddDttm;
    this.subject = obj.sccNtfreqSubject;
    this.message = obj.sccNtfreqMsgtext;
  }
}
 
export default class Notifications {
  constructor(obj) {
    this.notifications = {};
    let length = 0;
 
    const items = obj.sccGetNotifResp.ntkItem;
    if (isArrayLike(items)) {
      this.notifications = mapObj((notification) => {
        ++length;
        return new Notification(notification);
      }, items);
    } else {
      ++length;
      this.notifications['0'] = new Notification(items);
    }
 
    this.notifications.length = length;
  }
}