Skip to content

Commit d65068e

Browse files
authored
New Components - cats (#14656)
* cats init * [Components] cats #14489 Sources - New Candidate (Instant) - New Contact (Instant) - New Activity (Instant) Actions - Create Candidate - Add Candidate Pipeline - Create Contact * pnpm update
1 parent 3378c06 commit d65068e

File tree

14 files changed

+1436
-58
lines changed

14 files changed

+1436
-58
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import cats from "../../cats.app.mjs";
2+
3+
export default {
4+
key: "cats-add-candidate-pipeline",
5+
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/#jobs-create-a-job)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
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+
},
17+
candidateId: {
18+
propDefinition: [
19+
cats,
20+
"candidateId",
21+
],
22+
},
23+
jobId: {
24+
propDefinition: [
25+
cats,
26+
"jobId",
27+
],
28+
},
29+
rating: {
30+
type: "integer",
31+
label: "Rating",
32+
description: "The record's rating for the job (0-5).",
33+
optional: true,
34+
},
35+
},
36+
async run({ $ }) {
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+
});
49+
50+
const location = headers.location.split("/");
51+
const pipelineId = location[location.length - 1];
52+
53+
$.export("$summary", `Successfully added candidate ID ${this.candidateId} to job ID ${this.jobId}`);
54+
return {
55+
pipelineId,
56+
};
57+
},
58+
};
Lines changed: 308 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,308 @@
1+
import cats from "../../cats.app.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "cats-create-candidate",
6+
name: "Create Candidate",
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",
9+
type: "action",
10+
props: {
11+
cats,
12+
checkDuplicate: {
13+
propDefinition: [
14+
cats,
15+
"checkDuplicate",
16+
],
17+
},
18+
firstName: {
19+
propDefinition: [
20+
cats,
21+
"firstName",
22+
],
23+
},
24+
middleName: {
25+
propDefinition: [
26+
cats,
27+
"middleName",
28+
],
29+
optional: true,
30+
},
31+
lastName: {
32+
propDefinition: [
33+
cats,
34+
"lastName",
35+
],
36+
},
37+
title: {
38+
propDefinition: [
39+
cats,
40+
"title",
41+
],
42+
optional: true,
43+
},
44+
emails: {
45+
propDefinition: [
46+
cats,
47+
"emails",
48+
],
49+
optional: true,
50+
},
51+
phones: {
52+
propDefinition: [
53+
cats,
54+
"phones",
55+
],
56+
optional: true,
57+
},
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: {
80+
propDefinition: [
81+
cats,
82+
"addressPostalCode",
83+
],
84+
optional: true,
85+
},
86+
countryCode: {
87+
propDefinition: [
88+
cats,
89+
"countryCode",
90+
],
91+
optional: true,
92+
},
93+
socialMediaUrls: {
94+
propDefinition: [
95+
cats,
96+
"socialMediaUrls",
97+
],
98+
optional: true,
99+
},
100+
website: {
101+
type: "string",
102+
label: "Website",
103+
description: "The website of the record.",
104+
optional: true,
105+
},
106+
bestTimeToCall: {
107+
propDefinition: [
108+
cats,
109+
"bestTimeToCall",
110+
],
111+
optional: true,
112+
},
113+
currentEmployer: {
114+
propDefinition: [
115+
cats,
116+
"currentEmployer",
117+
],
118+
optional: true,
119+
},
120+
dateAvailable: {
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.",
130+
optional: true,
131+
},
132+
desiredPay: {
133+
propDefinition: [
134+
cats,
135+
"desiredPay",
136+
],
137+
optional: true,
138+
},
139+
isWillingToRelocate: {
140+
propDefinition: [
141+
cats,
142+
"isWillingToRelocate",
143+
],
144+
optional: true,
145+
},
146+
keySkills: {
147+
propDefinition: [
148+
cats,
149+
"keySkills",
150+
],
151+
optional: true,
152+
},
153+
notes: {
154+
propDefinition: [
155+
cats,
156+
"notes",
157+
],
158+
optional: true,
159+
},
160+
source: {
161+
propDefinition: [
162+
cats,
163+
"source",
164+
],
165+
optional: true,
166+
},
167+
ownerId: {
168+
propDefinition: [
169+
cats,
170+
"ownerId",
171+
],
172+
optional: true,
173+
},
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+
},
203+
workHistory: {
204+
propDefinition: [
205+
cats,
206+
"workHistory",
207+
],
208+
optional: true,
209+
},
210+
},
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+
},
225+
async run({ $ }) {
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;
254+
255+
const customFieldsObject = customFields
256+
? customFields.map(({ value }) => {
257+
return {
258+
id: value,
259+
value: data[value],
260+
};
261+
})
262+
: {};
263+
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+
};
307+
},
308+
};

0 commit comments

Comments
 (0)