airship-server
Version:
Airship is a framework for Node.JS & TypeScript that helps you to write big, scalable and maintainable API servers.
124 lines (123 loc) • 3.3 kB
JavaScript
export class Event {
/**
* @class
* @property {number} groupId
* @property {string} description
* @property {EventExtraInfo[]|undefined} extraInfo
* @property {EventDay[]|undefined} days
* @property {string} cover
*/
constructor(groupId, description, extraInfo, days, cover) {
this.groupId = groupId;
this.description = description;
this.extraInfo = extraInfo;
this.days = days;
this.cover = cover;
}
/**
* @param {Object} raw
* @returns {Event}
*/
static deserialize(raw) {
return new Event(raw['groupId'], raw['description'], raw['extraInfo'] ? raw['extraInfo'].map((v) => v ? EventExtraInfo.deserialize(v) : undefined) : undefined, raw['days'] ? raw['days'].map((v) => v ? EventDay.deserialize(v) : undefined) : undefined, raw['cover']);
}
/**
* @returns {Object}
*/
serialize() {
return {
groupId: this.groupId,
description: this.description,
extraInfo: this.extraInfo ? this.extraInfo.map((v) => v ? v.serialize() : undefined) : undefined,
days: this.days ? this.days.map((v) => v ? v.serialize() : undefined) : undefined,
cover: this.cover
};
}
}
export class EventExtraInfo {
/**
* @class
* @property {string} title
* @property {string} text
*/
constructor(title, text) {
this.title = title;
this.text = text;
}
/**
* @param {Object} raw
* @returns {EventExtraInfo}
*/
static deserialize(raw) {
return new EventExtraInfo(raw['title'], raw['text']);
}
/**
* @returns {Object}
*/
serialize() {
return {
title: this.title,
text: this.text
};
}
}
export class EventDay {
/**
* @class
* @property {number} date
* @property {EventItem[]|undefined} items
*/
constructor(date, items) {
this.date = date;
this.items = items;
}
/**
* @param {Object} raw
* @returns {EventDay}
*/
static deserialize(raw) {
return new EventDay(raw['date'], raw['items'] ? raw['items'].map((v) => v ? EventItem.deserialize(v) : undefined) : undefined);
}
/**
* @returns {Object}
*/
serialize() {
return {
date: this.date,
items: this.items ? this.items.map((v) => v ? v.serialize() : undefined) : undefined
};
}
}
export class EventItem {
/**
* @class
* @property {number} id
* @property {string} name
* @property {number} timeHours
* @property {number} timeMinutes
*/
constructor(id, name, timeHours, timeMinutes) {
this.id = id;
this.name = name;
this.timeHours = timeHours;
this.timeMinutes = timeMinutes;
}
/**
* @param {Object} raw
* @returns {EventItem}
*/
static deserialize(raw) {
return new EventItem(raw['id'], raw['name'], raw['timeHours'], raw['timeMinutes']);
}
/**
* @returns {Object}
*/
serialize() {
return {
id: this.id,
name: this.name,
timeHours: this.timeHours,
timeMinutes: this.timeMinutes
};
}
}