job-hoarder
Version:
Job board aggregator to pull in standardized job postings from company job pages
48 lines (47 loc) • 1.65 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var axios_1 = __importDefault(require("axios"));
var parser_1 = __importDefault(require("./parser"));
var Greenhouse = /** @class */ (function () {
function Greenhouse(params) {
// Allow string paramater to resolve
if (typeof params === 'string') {
params = {
companyId: params,
};
}
if (!params || !params.companyId)
throw new Error('Client must have a company Id');
this.companyId = params.companyId;
this.parser = new parser_1.default();
}
/**
* Gets jobs from job board
* @returns {array} List of jobs
*/
Greenhouse.prototype.getJobs = function () {
return axios_1.default
.get("https://api.collage.co/v1/positions/" + this.companyId)
.then(function (res) { return res.data; })
.then(this.parser.parseJobs);
};
/**
* Gets job details from job board
* @param {string} id Id of job to retrieve
* @returns {object} Job assigned to Id
*/
Greenhouse.prototype.getJob = function (id) {
return this.getJobs().then(function (jobs) {
var job = jobs.find(function (j) { return j.id === id; });
if (!job) {
throw new Error('Could not find job with given id ' + id);
}
return job;
});
};
return Greenhouse;
}());
exports.default = Greenhouse;