magister.js
Version:
A JavaScript implementation of the Magister 6 API
119 lines (92 loc) • 2.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _lodash = _interopRequireDefault(require("lodash"));
var _magisterThing = _interopRequireDefault(require("./magisterThing"));
var _appointment = _interopRequireDefault(require("./appointment"));
var _util = require("./util");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class AbsenceInfo extends _magisterThing.default {
/**
* @private
* @param {Magister} magister
* @param {Object} raw
*/
constructor(magister, raw) {
super(magister);
/**
* @type {Number}
* @private
* @readonly
*/
this._type = raw.Verantwoordingtype;
/**
* @type {String}
* @readonly
*/
this.id = (0, _util.toString)(raw.Id);
/**
* @type {Date}
* @readonly
*/
this.begin = (0, _util.parseDate)(raw.Start);
/**
* @type {Date}
* @readonly
*/
this.end = (0, _util.parseDate)(raw.Eind);
/**
* @type {Number}
* @readonly
*/
this.schoolHour = raw.Lesuur;
/**
* @type {Boolean}
* @readonly
*/
this.isPermitted = raw.Geoorloofd;
/**
* @type {String}
* @readonly
*/
this.description = _lodash.default.toString(raw.Omschrijving).trim();
/**
* @type {String}
* @readonly
*/
this.code = _lodash.default.toString(raw.Code);
/**
* @type {Appointment}
* @readonly
*/
this.appointment = new _appointment.default(magister, raw.Afspraak); // REVIEW: do we want (and need) this?
}
/**
* @type {string}
* @readonly
*/
get type() {
switch (this._type) {
case 1:
return 'absent';
case 2:
return 'late';
case 3:
return 'sick';
case 4:
return 'discharged';
case 6:
return 'exemption';
case 7:
return 'books';
case 8:
return 'homework';
default:
return 'unknown';
}
}
}
var _default = AbsenceInfo;
exports.default = _default;