updated sorting
This commit is contained in:
15
index.js
15
index.js
@@ -20,7 +20,7 @@ function Query(queryObj) {
|
||||
this.remoteFilter = queryObj.remoteFilter || "";
|
||||
this.salary = queryObj.salary || "";
|
||||
this.experienceLevel = queryObj.experienceLevel || "";
|
||||
|
||||
this.sortBy = queryObj.sortBy || "";
|
||||
//internal variable
|
||||
this.limit = Number(queryObj.limit) || 0;
|
||||
}
|
||||
@@ -84,13 +84,6 @@ Query.prototype.getSalary = function () {
|
||||
};
|
||||
return salaryRange[this.salary.toLowerCase()] ?? "";
|
||||
};
|
||||
Query.prototype.getSortBy = function () {
|
||||
const sortBy = {
|
||||
recent: "DD",
|
||||
relevant: "R",
|
||||
};
|
||||
return sortBy[this.salary.toLowerCase()] ?? "";
|
||||
};
|
||||
|
||||
/*
|
||||
* EXAMPLE OF A SAMPLE QUERY
|
||||
@@ -114,7 +107,11 @@ Query.prototype.url = function (start) {
|
||||
if (this.getRemoteFilter() !== "") query += `&f_WT=${this.getRemoteFilter()}`;
|
||||
if (this.getJobType() !== "") query += `&f_JT=${this.getJobType()}`;
|
||||
query += `&start=${start}`;
|
||||
if (this.sortBy !== "") query += `&sortBy=${this.getSortBy}`;
|
||||
if (this.sortBy == "recent" || this.sortBy == "relevant") {
|
||||
let sortMethod = "R";
|
||||
if (this.sortBy == "recent") sortMethod = "DD";
|
||||
query += `&sortBy=${sortMethod}`;
|
||||
}
|
||||
return encodeURI(query);
|
||||
};
|
||||
|
||||
|
||||
17
test.js
Normal file
17
test.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const linkedIn = require('./index');
|
||||
|
||||
const queryOptions = {
|
||||
keyword: 'software engineer',
|
||||
location: 'los angeles',
|
||||
dateSincePosted: 'past Week',
|
||||
jobType: 'full time',
|
||||
remoteFilter: 'remote',
|
||||
salary: '100000',
|
||||
experienceLevel: 'entry level',
|
||||
limit: '1',
|
||||
sortBy: 'recent'
|
||||
};
|
||||
|
||||
linkedIn.query(queryOptions).then(response => {
|
||||
console.log(response); // An array of Job objects
|
||||
});
|
||||
Reference in New Issue
Block a user