Skip to content

Commit f26fdfc

Browse files
committed
[Components] cats #14489
Sources - New Candidate (Instant) - New Contact (Instant) - New Activity (Instant) Actions - Create Candidate - Add Candidate Pipeline - Create Contact
1 parent 3dcdab8 commit f26fdfc

File tree

13 files changed

+997
-468
lines changed

13 files changed

+997
-468
lines changed

components/cats/actions/add-candidate-pipeline/add-candidate-pipeline.mjs

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ import cats from "../../cats.app.mjs";
33
export default {
44
key: "cats-add-candidate-pipeline",
55
name: "Add Candidate to Job Pipeline",
6-
description: "Adds a specific candidate to a job pipeline in CATS. [See the documentation](https://docs.catsone.com/api/v3/)",
7-
version: "0.0.{{ts}}",
6+
description: "Adds a specific candidate to a job pipeline in CATS. [See the documentation](https://docs.catsone.com/api/v3/#jobs-create-a-job)",
7+
version: "0.0.1",
88
type: "action",
99
props: {
1010
cats,
11+
createActivity: {
12+
type: "boolean",
13+
label: "Create Activity",
14+
description: "Whether a corresponding activity should be created automatically. This mimics what happens when a pipeline is created from the CATS UI.",
15+
optional: true,
16+
},
1117
candidateId: {
1218
propDefinition: [
1319
cats,
@@ -21,25 +27,32 @@ export default {
2127
],
2228
},
2329
rating: {
24-
propDefinition: [
25-
cats,
26-
"rating",
27-
],
30+
type: "integer",
31+
label: "Rating",
32+
description: "The record's rating for the job (0-5).",
2833
optional: true,
2934
},
3035
},
3136
async run({ $ }) {
32-
const data = {
33-
candidate_id: this.candidateId,
34-
job_id: this.jobId,
35-
};
37+
const { headers } = await this.cats.addCandidateToJobPipeline({
38+
$,
39+
returnFullResponse: true,
40+
params: {
41+
create_activity: this.createActivity,
42+
},
43+
data: {
44+
candidate_id: this.candidateId,
45+
job_id: this.jobId,
46+
rating: this.rating,
47+
},
48+
});
3649

37-
if (this.rating !== undefined) {
38-
data.rating = this.rating;
39-
}
50+
const location = headers.location.split("/");
51+
const pipelineId = location[location.length - 1];
4052

41-
const response = await this.cats.addCandidateToJobPipeline(data);
42-
$.export("$summary", `Successfully added candidate ID ${this.candidateId} to job pipeline ID ${this.jobId}`);
43-
return response;
53+
$.export("$summary", `Successfully added candidate ID ${this.candidateId} to job ID ${this.jobId}`);
54+
return {
55+
pipelineId,
56+
};
4457
},
4558
};

components/cats/actions/create-candidate/create-candidate.mjs

Lines changed: 171 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import cats from "../../cats.app.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
23

34
export default {
45
key: "cats-create-candidate",
56
name: "Create Candidate",
6-
description: "Create a new candidate in your CATS database. [See the documentation](https://docs.catsone.com/api/v3/#create-a-candidate)",
7-
version: "0.0.{{ts}}",
7+
description: "Create a new candidate in your CATS database. [See the documentation](https://docs.catsone.com/api/v3/#candidates-create-a-candidate)",
8+
version: "0.0.1",
89
type: "action",
910
props: {
1011
cats,
@@ -20,23 +21,30 @@ export default {
2021
"firstName",
2122
],
2223
},
24+
middleName: {
25+
propDefinition: [
26+
cats,
27+
"middleName",
28+
],
29+
optional: true,
30+
},
2331
lastName: {
2432
propDefinition: [
2533
cats,
2634
"lastName",
2735
],
2836
},
29-
middleName: {
37+
title: {
3038
propDefinition: [
3139
cats,
32-
"middleName",
40+
"title",
3341
],
3442
optional: true,
3543
},
36-
title: {
44+
emails: {
3745
propDefinition: [
3846
cats,
39-
"title",
47+
"emails",
4048
],
4149
optional: true,
4250
},
@@ -47,10 +55,31 @@ export default {
4755
],
4856
optional: true,
4957
},
50-
address: {
58+
addressStreet: {
59+
propDefinition: [
60+
cats,
61+
"addressStreet",
62+
],
63+
optional: true,
64+
},
65+
addressCity: {
66+
propDefinition: [
67+
cats,
68+
"addressCity",
69+
],
70+
optional: true,
71+
},
72+
addressState: {
73+
propDefinition: [
74+
cats,
75+
"addressState",
76+
],
77+
optional: true,
78+
},
79+
addressPostalCode: {
5180
propDefinition: [
5281
cats,
53-
"address",
82+
"addressPostalCode",
5483
],
5584
optional: true,
5685
},
@@ -69,10 +98,9 @@ export default {
6998
optional: true,
7099
},
71100
website: {
72-
propDefinition: [
73-
cats,
74-
"website",
75-
],
101+
type: "string",
102+
label: "Website",
103+
description: "The website of the record.",
76104
optional: true,
77105
},
78106
bestTimeToCall: {
@@ -90,10 +118,15 @@ export default {
90118
optional: true,
91119
},
92120
dateAvailable: {
93-
propDefinition: [
94-
cats,
95-
"dateAvailable",
96-
],
121+
type: "string",
122+
label: "Date Available",
123+
description: "The date the record is available for an opening. **Format: YYYY-MM-DD**.",
124+
optional: true,
125+
},
126+
currentPay: {
127+
type: "string",
128+
label: "Current Pay",
129+
description: "The current pay of the record.",
97130
optional: true,
98131
},
99132
desiredPay: {
@@ -138,6 +171,35 @@ export default {
138171
],
139172
optional: true,
140173
},
174+
isActive: {
175+
type: "boolean",
176+
label: "Is Active",
177+
description: "A flag indicating if the candidate is active.",
178+
optional: true,
179+
},
180+
isHot: {
181+
propDefinition: [
182+
cats,
183+
"isHot",
184+
],
185+
optional: true,
186+
},
187+
password: {
188+
type: "string",
189+
label: "password",
190+
description: "The candidate's password if they are \"registering\".",
191+
secret: true,
192+
optional: true,
193+
},
194+
customFields: {
195+
propDefinition: [
196+
cats,
197+
"customFields",
198+
],
199+
withLabel: true,
200+
reloadProps: true,
201+
optional: true,
202+
},
141203
workHistory: {
142204
propDefinition: [
143205
cats,
@@ -146,39 +208,101 @@ export default {
146208
optional: true,
147209
},
148210
},
211+
async additionalProps() {
212+
const props = {};
213+
(this.customFields || []).map(({
214+
label, value,
215+
}) => {
216+
props[value] = {
217+
type: "string",
218+
label: `Custom Field: ${label}`,
219+
optional: true,
220+
};
221+
}, {});
222+
223+
return props;
224+
},
149225
async run({ $ }) {
150-
const candidateData = {
151-
check_duplicate: this.checkDuplicate,
152-
first_name: this.firstName,
153-
last_name: this.lastName,
154-
middle_name: this.middleName,
155-
title: this.title,
156-
phones: this.phones
157-
? this.phones.map(JSON.parse)
158-
: undefined,
159-
address: this.address,
160-
country_code: this.countryCode,
161-
social_media_urls: this.socialMediaUrls
162-
? this.socialMediaUrls.map(JSON.parse)
163-
: undefined,
164-
website: this.website,
165-
best_time_to_call: this.bestTimeToCall,
166-
current_employer: this.currentEmployer,
167-
date_available: this.dateAvailable,
168-
desired_pay: this.desiredPay,
169-
is_willing_to_relocate: this.isWillingToRelocate,
170-
key_skills: this.keySkills,
171-
notes: this.notes,
172-
source: this.source,
173-
owner_id: this.ownerId,
174-
work_history: this.workHistory
175-
? this.workHistory.map(JSON.parse)
176-
: undefined,
177-
};
226+
const {
227+
cats, // eslint-disable-next-line no-unused-vars
228+
customFields,
229+
firstName,
230+
lastName,
231+
ownerId,
232+
middleName,
233+
checkDuplicate,
234+
bestTimeToCall,
235+
currentEmployer,
236+
emails,
237+
phones,
238+
addressStreet,
239+
addressCity,
240+
addressState,
241+
addressPostalCode,
242+
countryCode,
243+
socialMediaUrls,
244+
dateAvailable,
245+
currentPay,
246+
desiredPay,
247+
isWillingToRelocate,
248+
keySkills,
249+
isActive,
250+
isHot,
251+
workHistory,
252+
...data
253+
} = this;
178254

179-
const response = await this.cats.createCandidate(candidateData);
255+
const customFieldsObject = customFields
256+
? customFields.map(({ value }) => {
257+
return {
258+
id: value,
259+
value: data[value],
260+
};
261+
})
262+
: {};
180263

181-
$.export("$summary", `Created candidate with ID ${response.id}`);
182-
return response;
264+
const { headers } = await cats.createCandidate({
265+
$,
266+
returnFullResponse: true,
267+
params: {
268+
check_duplicate: checkDuplicate,
269+
},
270+
data: {
271+
first_name: firstName,
272+
middle_name: middleName,
273+
last_name: lastName,
274+
emails: parseObject(emails),
275+
phones: parseObject(phones),
276+
address: {
277+
street: addressStreet,
278+
city: addressCity,
279+
state: addressState,
280+
postal_code: addressPostalCode,
281+
},
282+
country_code: countryCode,
283+
social_media_urls: parseObject(socialMediaUrls),
284+
best_time_to_call: bestTimeToCall,
285+
current_employer: currentEmployer,
286+
date_available: dateAvailable,
287+
current_pay: currentPay,
288+
desired_pay: desiredPay,
289+
is_willing_to_relocate: isWillingToRelocate,
290+
key_skills: keySkills,
291+
owner_id: ownerId,
292+
is_active: isActive,
293+
is_hot: isHot,
294+
work_history: parseObject(workHistory),
295+
custom_fields: customFieldsObject,
296+
...data,
297+
},
298+
});
299+
300+
const location = headers.location.split("/");
301+
const candidateId = location[location.length - 1];
302+
303+
$.export("$summary", `Created candidate with ID ${candidateId}`);
304+
return {
305+
candidateId,
306+
};
183307
},
184308
};

0 commit comments

Comments
 (0)