job-hoarder
Version:
Job board aggregator to pull in standardized job postings from company job pages
45 lines (44 loc) • 1.63 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var parser_1 = __importDefault(require("./parser"));
var axios_1 = __importDefault(require("axios"));
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://boards-api.greenhouse.io/v1/boards/" + this.companyId + "/jobs?content=true")
.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 axios_1.default
.get("https://boards-api.greenhouse.io/v1/boards/" + this.companyId + "/jobs/" + id)
.then(function (res) { return res.data; })
.then(this.parser.parseJob);
};
return Greenhouse;
}());
exports.default = Greenhouse;