UNPKG

@buildit/job-listings

Version:

Small JS library for fetching Buildit job listings data from SmartRecruiter's API

58 lines (47 loc) 1.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getJobPostings = getJobPostings; exports.default = void 0; var _srApi = require("./sr-api"); var _jobLocation = _interopRequireDefault(require("./job-location")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * A job posting. */ class JobPosting { constructor(srJobPosting, trId) { this.uuid = srJobPosting.uuid; this.title = srJobPosting.name; this.companyId = srJobPosting.company.identifier; this.experienceLevel = srJobPosting.experienceLevel.label; this.location = new _jobLocation.default(srJobPosting.location); this.typeOfEmployment = srJobPosting.typeOfEmployment.label; this.trId = trId; this.industry = srJobPosting.industry.label; this.datePosted = srJobPosting.releasedDate; } /** * Returns the URL to this job's ad on SmartRecruiters. */ get url() { return (0, _srApi.getJobAdUrl)(this.companyId, this.uuid, this.trId); } } /** * Fetches job postings from SmartRecruiters' and returns them as JobPosting * objects. * * @param {*} companyId The company ID (e.g. "WiproDigital") * @param {*} customFieldId Optional custom field ID to filter results on * @param {*} customFieldValueId Optional custom field value to use with the field ID * @param {*} trId Optional tracking ID * * @return {Promise<Array>} Promise that resolves to an array of job posting objects. */ exports.default = JobPosting; async function getJobPostings(companyId, customFieldId, customFieldValueId, trId) { const postingsData = await (0, _srApi.getJobPostingsData)(companyId, customFieldId, customFieldValueId); return postingsData.map(posting => new JobPosting(posting, trId)); }