All files / src/model AlertResponse.ts

31.58% Statements 6/19
100% Branches 0/0
0% Functions 0/6
40% Lines 6/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58    1x   1x 1x 1x 1x           1x                                                                                        
import { Moment } from 'moment';
 
import { Util } from '../internal/Util';
 
import { Announcement } from './Announcement';
import { Event } from './Event';
import { SeamailThread } from './SeamailThread';
import { StreamPost } from './StreamPost';
 
/**
 * Represents an alert response.
 * @module AlertResponse
 */
export class AlertResponse {
  public static fromRest(data: any) {
    Util.assertHasProperties(data, 'status', 'last_checked_time');
 
    const ret = new AlertResponse();
    Util.setDateProperties(ret, data, 'last_checked_time');
 
    if (data.announcements) {
      ret.announcements = data.announcements.map(announcement => Announcement.fromRest(announcement));
    }
    if (data.tweet_mentions) {
      ret.tweet_mentions = data.tweet_mentions.map(twarrt => StreamPost.fromRest(twarrt));
    }
    /*
    if (data.forum_mentions) {
      ret.forum_mentions = data.forum_mentions.map(thread => ForumThread.fromRest(thread));
    }
    */
    if (data.unread_seamail) {
      ret.unread_seamail = data.unread_seamail.map(thread => SeamailThread.fromRest(thread));
    }
    if (data.upcoming_events) {
      ret.upcoming_events = data.upcoming_events.map(event => Event.fromRest(event));
    }
 
    return ret;
  }
 
  public last_checked_time: Moment;
 
  public announcements: Announcement[];
 
  public tweet_mentions: StreamPost[];
 
  // public forum_mentions: ForumThread[];
 
  public unread_seamail: SeamailThread[];
 
  public upcoming_events: Event[];
 
  public toJSON() {
    return this;
  }
}