job-hoarder
Version:
Job board aggregator to pull in standardized job postings from company job pages
46 lines (45 loc) • 1.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("../utils");
var WorkableParser = /** @class */ (function () {
function WorkableParser(boardName) {
var _this = this;
/**
* Parse jobs from request result
* @param {string} data String of jobs
* @returns {array} List of parsed jobs
*/
this.parseJobs = function (data) {
if (!data)
throw new Error('No jobs to parse');
var jobs = utils_1.ensureJSON(data);
if (!jobs)
throw new Error('Failed to parse jobs');
return jobs.map(_this.parseJob);
};
/**
* Parses job from request result
* @param {string} data String of job result
* @returns {object} Object of parsed job
*/
this.parseJob = function (data) {
if (!data)
throw new Error('No job to parse');
var _a = utils_1.ensureJSON(data), id = _a.id, shortcode = _a.shortcode, title = _a.title, description = _a.description, benefits = _a.benefits, department = _a.department, _b = _a.location, city = _b.city, region = _b.region, country = _b.country, published = _a.published;
var url = "https://apply.workable.com/" + _this.boardName + "/j/" + shortcode + "/";
var jobLocation = [city, region, country].filter(function (val) { return val; }).join(', ');
return {
id: id,
url: url,
title: title,
datePosted: new Date(published),
jobLocation: jobLocation,
department: department,
description: description + "<br/>" + benefits,
};
};
this.boardName = boardName;
}
return WorkableParser;
}());
exports.default = WorkableParser;