Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import app from "../../homerun.app.mjs";

export default {
key: "homerun-add-candidate-note",
name: "Add Candidate Note",
description: "Adds a note to a candidate's profile in Homerun. [See the documentation](https://developers.homerun.co/#tag/Job-Application-Notes/operation/job-applications.job-application-id.notes.post).",
version: "0.0.1",
type: "action",
props: {
app,
jobApplicationId: {
propDefinition: [
app,
"jobApplicationId",
],
},
note: {
type: "string",
label: "Note Content",
description: "The content of the note to add.",
},
displayName: {
type: "string",
label: "Display Name",
description: "Name of the note's author.",
},
},
methods: {
addCandidateNote({
jobApplicationId, ...args
} = {}) {
return this.app.post({
path: `/job-applications/${jobApplicationId}/notes`,
...args,
});
},
},
async run({ $ }) {
const {
addCandidateNote,
jobApplicationId,
note,
displayName,
} = this;

const response = await addCandidateNote({
$,
jobApplicationId,
data: {
note,
display_name: displayName,
},
});

$.export("$summary", "Successfully added a note.");
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import app from "../../homerun.app.mjs";

export default {
key: "homerun-create-job-application",
name: "Create Job Application",
description: "Creates a new job application. [See the documentation](https://developers.homerun.co/#tag/Job-Applications/operation/job-applications.post).",
version: "0.0.1",
type: "action",
props: {
app,
firstName: {
type: "string",
label: "First Name",
description: "The first name of the applicant. Make sure you don't include numbers or special characters.",
},
lastName: {
type: "string",
label: "Last Name",
description: "The last name of the applicant. Make sure you don't include numbers or special characters.",
},
email: {
type: "string",
label: "Email",
description: "The email of the applicant.",
},
dateOfBirth: {
type: "string",
label: "Date of Birth",
description: "The date of birth of the applicant in the format of `YYYY-MM-DD`.",
optional: true,
},
vacancyId: {
optional: true,
propDefinition: [
app,
"vacancyId",
],
},
phoneNumber: {
type: "string",
label: "Phone Number",
description: "The phone number of the applicant.",
optional: true,
},
photo: {
type: "string",
label: "Photo",
description: "The URL of the applicant's photo.",
optional: true,
},
experience: {
type: "string",
label: "Experience",
description: "The experience of the applicant.",
optional: true,
},
education: {
type: "string",
label: "Education",
description: "The education of the applicant.",
optional: true,
},
facebook: {
type: "string",
label: "Facebook",
description: "The Facebook URL of the applicant. eg. `https://facebook.com/username`",
optional: true,
},
twitter: {
type: "string",
label: "X",
description: "The X URL of the applicant. eg. `https://x.com/username`",
optional: true,
},
linkedin: {
type: "string",
label: "LinkedIn",
description: "The LinkedIn URL of the applicant. eg. `https://linkedin.com/in/username`",
optional: true,
},
github: {
type: "string",
label: "GitHub",
description: "The GitHub URL of the applicant. eg. `https://github.com/username`",
optional: true,
},
website: {
type: "string",
label: "Website",
description: "The website URL of the applicant. eg. `https://username.com`",
optional: true,
},
},
methods: {
createJobApplication(args = {}) {
return this.app.post({
path: "/job-applications",
...args,
});
},
},
async run({ $ }) {
const {
createJobApplication,
firstName,
lastName,
email,
dateOfBirth,
vacancyId,
phoneNumber,
photo,
experience,
education,
facebook,
twitter,
linkedin,
github,
website,
} = this;

const response = await createJobApplication({
$,
data: {
vacancyId,
first_name: firstName,
last_name: lastName,
email,
date_of_birth: dateOfBirth,
phone_number: phoneNumber,
photo,
experience,
education,
facebook,
twitter,
linkedin,
github,
website,
},
});

$.export("$summary", "Successfully created a job application.");
return response;
},
};
14 changes: 14 additions & 0 deletions components/homerun/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const BASE_URL = "https://api.homerun.co";
const VERSION_PATH = "/v2";
const DEFAULT_LIMIT = 100;
const DEFAULT_MAX = 1000;

const LAST_DATE_AT = "lastDateAt";

export default {
BASE_URL,
VERSION_PATH,
DEFAULT_LIMIT,
DEFAULT_MAX,
LAST_DATE_AT,
};
17 changes: 17 additions & 0 deletions components/homerun/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
async function iterate(iterations) {
const items = [];
for await (const item of iterations) {
items.push(item);
}
return items;
}

function getNestedProperty(obj, propertyString) {
const properties = propertyString.split(".");
return properties.reduce((prev, curr) => prev?.[curr], obj);
}

export default {
iterate,
getNestedProperty,
};
140 changes: 136 additions & 4 deletions components/homerun/homerun.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,143 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";
import utils from "./common/utils.mjs";

export default {
type: "app",
app: "homerun",
propDefinitions: {},
propDefinitions: {
vacancyId: {
type: "string",
label: "Vacancy ID",
description: "The ID of the vacancy.",
async options({ page }) {
const { data } = await this.listVacancies({
params: {
page: page + 1,
},
});
return data.map(({
id: value,
title: label,
}) => ({
label,
value,
}));
},
Comment on lines +13 to +26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling to options methods.

Both vacancyId and jobApplicationId options methods should handle API errors gracefully to prevent UI disruption.

       async options({ page }) {
+        try {
           const { data } = await this.listVacancies({
             params: {
               page: page + 1,
             },
           });
           return data.map(({
             id: value,
             title: label,
           }) => ({
             label,
             value,
           }));
+        } catch (error) {
+          console.error('Failed to fetch vacancies:', error);
+          return [];
+        }
       },

Also applies to: 32-49

},
jobApplicationId: {
type: "string",
label: "Job Application ID",
description: "The ID of the job application.",
async options({ page }) {
const { data } = await this.listJobApplications({
params: {
page: page + 1,
},
});
return data.map(({
id: value,
personal_info: {
first_name: firstName,
last_name: lastName,
email,
},
}) => ({
label: `${firstName} ${lastName} (${email})`,
value,
}));
Comment on lines +38 to +48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove email from the job application label to protect PII.

The label construction exposes personal information (email) in the UI. Consider removing the email to protect candidate privacy.

-          label: `${firstName} ${lastName} (${email})`,
+          label: `${firstName} ${lastName}`,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return data.map(({
id: value,
personal_info: {
first_name: firstName,
last_name: lastName,
email,
},
}) => ({
label: `${firstName} ${lastName} (${email})`,
value,
}));
return data.map(({
id: value,
personal_info: {
first_name: firstName,
last_name: lastName,
email,
},
}) => ({
- label: `${firstName} ${lastName} (${email})`,
+ label: `${firstName} ${lastName}`,
value,
}));

},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
getUrl(path) {
return `${constants.BASE_URL}${constants.VERSION_PATH}${path}`;
},
getHeaders(headers) {
return {
Authorization: `Bearer ${this.$auth.api_key}`,
...headers,
};
},
_makeRequest({
$ = this, path, headers, ...args
} = {}) {
return axios($, {
...args,
url: this.getUrl(path),
headers: this.getHeaders(headers),
});
},
post(args = {}) {
return this._makeRequest({
method: "POST",
...args,
});
},
listVacancies(args = {}) {
return this._makeRequest({
path: "/vacancies",
...args,
});
},
listJobApplications(args = {}) {
return this._makeRequest({
path: "/job-applications",
...args,
});
},
async *getIterations({
resourcesFn, resourcesFnArgs, resourceName,
lastDateAt, dateField,
max = constants.DEFAULT_MAX,
}) {
let page = 1;
let resourcesCount = 0;

while (true) {
const response =
await resourcesFn({
...resourcesFnArgs,
params: {
...resourcesFnArgs?.params,
page,
perPage: constants.DEFAULT_LIMIT,
},
});

const nextResources = utils.getNestedProperty(response, resourceName);

if (!nextResources?.length) {
console.log("No more resources found");
return;
}

for (const resource of nextResources) {
const isDateGreaterThanLasDate =
lastDateAt
&& Date.parse(resource[dateField]) > Date.parse(lastDateAt);

if (!lastDateAt || isDateGreaterThanLasDate) {
yield resource;
resourcesCount += 1;
}

if (resourcesCount >= max) {
console.log("Reached max resources");
return;
}
}

if (nextResources.length < constants.DEFAULT_LIMIT) {
console.log("No next page found");
return;
}

page += 1;
}
},
paginate(args = {}) {
return utils.iterate(this.getIterations(args));
},
},
};
Loading
Loading