ee-ts-util
Version:
typescript utilities and functions
56 lines • 2.96 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const Client_1 = require("bullhorn-client/lib/Client");
const fs_1 = require("fs");
exports.buildBullhornClient = (config) => {
const client = new Client_1.default({
server: config.bhServer,
authServer: config.bhAuthServer,
version: "2.0",
clientId: config.bhClientId,
secret: config.bhSecret,
});
return client.login(config.bhUserName, config.bhPassowrd);
};
// TODO: Fix intermittent error from bullhorn api (and not from library)
// Could not access HTTP invoker remote service at
// [http://sl121dataservices.vip.bos.bullhorn.com/data-services-2.6/sr/DataService];
// nested exception is java.io.InvalidObjectException: enum constant VIEW_CANDIDATE_VIEWABLE_CONFIDENTIAL_FIELDS
// does not exist in class com.bullhorn.entity.acl.AclAction
exports.buildBullhornPayRateAdapter = (bhClient) => {
return (emails) => {
// TODO - for each candidate (email), we are making a separate api call
// if this is an issue think of optimising it just by making 1 api call
// Load test this
const associatePayRates = emails.map((emailAddress) => __awaiter(this, void 0, void 0, function* () {
const candidate = yield bhClient.search("Candidate", {
query: `email:${emailAddress} or email2:${emailAddress} or email3:${emailAddress}`,
fields: ["id,firstName,lastName,placements"],
});
const hasPlacements = candidate.data.length > 0 && candidate.data[0].placements !== undefined;
let payRates = [];
if (hasPlacements) {
const placementsQuery = candidate.data[0].placements.data.map((p) => "id:" + p.id).join(" or ");
const placementsList = yield bhClient.search("Placement", {
query: placementsQuery,
fields: ["id,payRate"],
});
payRates = placementsList.data.map((placement) => placement.payRate);
}
return { email: emailAddress, rates: payRates };
}));
return Promise.all(associatePayRates);
};
};
function log(msg) {
fs_1.appendFileSync("/tmp/jest.log.txt", new Date() + " - " + msg + "\n", { encoding: "utf8" });
}
//# sourceMappingURL=payRateAdapter.js.map