UNPKG

oa-jira

Version:

Octet Agile's JIRA connectivity project.

48 lines (38 loc) 1.36 kB
const commons = require('../../commons'); const constants = require('../constants'); class Project { #id; #key; #name; #type; constructor({ id, key, name, type } = {}) { this.#id = commons.string.check(id, constants.projects.settings.id); this.#key = commons.string.check(key, constants.projects.settings.key); this.#name = commons.string.check(name, constants.projects.settings.name); this.#type = commons.string.check(type, constants.projects.settings.type); } getId = () => this.#id; getKey = () => this.#key; getName = () => this.#name; getType = () => this.#type; static check(project) { return commons.object.check(project, { name: 'project', className: 'Project', _class: Project }); } static resolve(project) { return commons.object.resolve(project, { name: 'project', className: 'Project', _class: Project }); } static create({ id, key, name, type } = {}) { try { return Promise.resolve(new Project({ id, key, name, type })); } catch (error) { return Promise.reject(error); } } toString = () => `Project[${this.#name} #${this.#id}]`; toJSON = () => { const json = { id: this.#id, key: this.#key, name: this.#name }; if (this.#type) json.type = this.#type; return json; }; } module.exports = Project;