oa-jira
Version:
Octet Agile's JIRA connectivity project.
45 lines (35 loc) • 1.35 kB
JavaScript
const commons = require('../../commons');
const constants = require('../constants');
class Resolution {
#id;
#description;
#name;
constructor({ id, description, name } = {}) {
this.#id = commons.string.check(id, constants.resolutions.settings.id);
this.#description = commons.string.check(description, constants.resolutions.settings.description);
this.#name = commons.string.check(name, constants.resolutions.settings.name);
}
getId = () => this.#id;
getDescription = () => this.#description;
getName = () => this.#name;
static check(resolution) {
return commons.object.check(resolution, { name: 'resolution', className: 'Resolution', _class: Resolution });
}
static resolve(resolution) {
return commons.object.resolve(resolution, { name: 'resolution', className: 'Resolution', _class: Resolution });
}
static create({ id, description, name } = {}) {
try {
return Promise.resolve(new Resolution({ id, description, name }));
} catch (error) {
return Promise.reject(error);
}
}
toString = () => `Resolution[${this.#name} #${this.#id}]`;
toJSON = () => {
const json = { id: this.#id, name: this.#name };
if (this.#description) json.description = this.#description;
return json;
};
}
module.exports = Resolution;