|
| 1 | +import { SOURCED_FROM } from "../../common/constants.mjs"; |
1 | 2 | import gem from "../../gem.app.mjs"; |
2 | | -import { axios } from "@pipedream/platform"; |
3 | 3 |
|
4 | 4 | export default { |
5 | 5 | key: "gem-create-candidate", |
6 | 6 | name: "Create Candidate", |
7 | | - description: "Creates a new candidate in Gem. [See the documentation]()", |
8 | | - version: "0.0.{{ts}}", |
| 7 | + description: "Creates a new candidate in Gem. [See the documentation](https://api.gem.com/v0/reference#tag/Candidates/paths/~1v0~1candidates/post)", |
| 8 | + version: "0.0.1", |
9 | 9 | type: "action", |
10 | 10 | props: { |
11 | 11 | gem, |
12 | | - firstName: { |
| 12 | + createdBy: { |
13 | 13 | propDefinition: [ |
14 | 14 | gem, |
15 | | - "firstName", |
| 15 | + "createdBy", |
16 | 16 | ], |
17 | 17 | }, |
| 18 | + firstName: { |
| 19 | + type: "string", |
| 20 | + label: "First Name", |
| 21 | + description: "Candidate's first name", |
| 22 | + optional: true, |
| 23 | + }, |
18 | 24 | lastName: { |
19 | | - propDefinition: [ |
20 | | - gem, |
21 | | - "lastName", |
22 | | - ], |
| 25 | + type: "string", |
| 26 | + label: "Last Name", |
| 27 | + description: "Candidate's last name", |
| 28 | + optional: true, |
23 | 29 | }, |
24 | | - emails: { |
25 | | - propDefinition: [ |
26 | | - gem, |
27 | | - "emails", |
28 | | - ], |
| 30 | + nickname: { |
| 31 | + type: "string", |
| 32 | + label: "Nickname", |
| 33 | + description: "Candidate's nickname", |
| 34 | + optional: true, |
29 | 35 | }, |
30 | | - jobPosition: { |
31 | | - propDefinition: [ |
32 | | - gem, |
33 | | - "jobPosition", |
34 | | - ], |
| 36 | + primaryEmail: { |
| 37 | + type: "string", |
| 38 | + label: "Primary Email Address", |
| 39 | + description: "Candidate's primary email address", |
| 40 | + }, |
| 41 | + additionalEmails: { |
| 42 | + type: "string[]", |
| 43 | + label: "Email Addresses", |
| 44 | + description: "List of candidate's additional email addresses", |
35 | 45 | optional: true, |
36 | 46 | }, |
37 | | - source: { |
38 | | - propDefinition: [ |
39 | | - gem, |
40 | | - "source", |
41 | | - ], |
| 47 | + linkedInHandle: { |
| 48 | + type: "string", |
| 49 | + label: "LinkedIn Handle", |
| 50 | + description: "If `LinkedIn Handle` is provided, candidate creation will be de-duplicated. If a candidate with the provided `LinkedIn Handle already exists, a 400 error will be returned with `errors` containing information on the existing candidate in this shape: `{\"errors\": { \"duplicate_candidate\": { \"id\": \"string\", \"linked_in_handle\": \"string\" }}}`.", |
| 51 | + optional: true, |
| 52 | + }, |
| 53 | + title: { |
| 54 | + type: "string", |
| 55 | + label: "Title", |
| 56 | + description: "Candidate's job title", |
42 | 57 | optional: true, |
43 | 58 | }, |
44 | | - notes: { |
| 59 | + company: { |
| 60 | + type: "string", |
| 61 | + label: "Company", |
| 62 | + description: "Candidate's company name", |
| 63 | + optional: true, |
| 64 | + }, |
| 65 | + location: { |
| 66 | + type: "string", |
| 67 | + label: "Location", |
| 68 | + description: "Candidate's location", |
| 69 | + optional: true, |
| 70 | + }, |
| 71 | + school: { |
| 72 | + type: "string", |
| 73 | + label: "School", |
| 74 | + description: "Candidate's school", |
| 75 | + optional: true, |
| 76 | + }, |
| 77 | + educationalInfo: { |
| 78 | + type: "string[]", |
| 79 | + label: "Educational Info", |
| 80 | + description: "A list of objects containing candidate's educational information. **Format: [{\"school\": \"string\", \"parsed_university\": \"string\", \"parsed_school\": \"string\", \"start_date\": \"string\", \"end_date\": \"string\", \"field_of_study\": \"string\", \"parsed_major_1\": \"string\", \"parsed_major_2\": \"string\", \"degree\": \"string\"}]**. [See the documentation](https://api.gem.com/v0/reference#tag/Candidates/paths/~1v0~1candidates/post) for further details.", |
| 81 | + optional: true, |
| 82 | + }, |
| 83 | + workInfo: { |
| 84 | + type: "string", |
| 85 | + label: "Work Info", |
| 86 | + description: "A list of objects containing candidate's work information. **Format: [{\"company\": \"string\", \"title\": \"string\", \"work_start_date\": \"string\", \"work_end_date\": \"string\", \"is_current\": \"string\"}]**. [See the documentation](https://api.gem.com/v0/reference#tag/Candidates/paths/~1v0~1candidates/post) for further details.", |
| 87 | + optional: true, |
| 88 | + }, |
| 89 | + profileUrls: { |
| 90 | + type: "string[]", |
| 91 | + label: "Profile URLs", |
| 92 | + description: "If `Profile URLs` is provided with an array of urls, social `profiles` will be generated based on the provided urls and attached to the candidate", |
| 93 | + optional: true, |
| 94 | + }, |
| 95 | + phoneNumber: { |
| 96 | + type: "string", |
| 97 | + label: "Phone Number", |
| 98 | + description: "Candidate's phone number", |
| 99 | + optional: true, |
| 100 | + }, |
| 101 | + projectIds: { |
45 | 102 | propDefinition: [ |
46 | 103 | gem, |
47 | | - "notes", |
| 104 | + "projectIds", |
48 | 105 | ], |
49 | 106 | optional: true, |
50 | 107 | }, |
| 108 | + customFields: { |
| 109 | + type: "string[]", |
| 110 | + label: "Custom Fields", |
| 111 | + description: "Array of objects containing new custom field values. Only custom fields specified in the array are updated. **Format: [{\"custom_field_id\": \"string\", \"value\": \"string\"}]**. [See the documentation](https://api.gem.com/v0/reference#tag/Candidates/paths/~1v0~1candidates/post) for further details.", |
| 112 | + optional: true, |
| 113 | + }, |
| 114 | + sourcedFrom: { |
| 115 | + type: "string", |
| 116 | + label: "Sourced From", |
| 117 | + description: "Where the candidate was sourced from", |
| 118 | + options: SOURCED_FROM, |
| 119 | + optional: true, |
| 120 | + }, |
| 121 | + autofill: { |
| 122 | + type: "boolean", |
| 123 | + label: "Autofill", |
| 124 | + description: "Requires `Linked In Handle` to be non-null. Attempts to fill in any missing fields.", |
| 125 | + optional: true, |
| 126 | + }, |
51 | 127 | }, |
52 | 128 | async run({ $ }) { |
| 129 | + const emails = [ |
| 130 | + { |
| 131 | + email_address: this.primaryEmail, |
| 132 | + is_primary: true, |
| 133 | + }, |
| 134 | + ]; |
| 135 | + if (this.additionalEmails) emails.push(...this.additionalEmails.map((email) => ({ |
| 136 | + email_address: email, |
| 137 | + is_primary: false, |
| 138 | + }))); |
| 139 | + |
| 140 | + if (emails.length === 0) { |
| 141 | + throw new Error("Primary Email Address is required"); |
| 142 | + } |
53 | 143 | const candidate = await this.gem.createCandidate({ |
54 | | - firstName: this.firstName, |
55 | | - lastName: this.lastName, |
56 | | - emails: this.emails, |
57 | | - jobPosition: this.jobPosition, |
58 | | - source: this.source, |
59 | | - notes: this.notes, |
| 144 | + $, |
| 145 | + data: { |
| 146 | + created_by: this.createdBy, |
| 147 | + first_name: this.firstName, |
| 148 | + last_name: this.lastName, |
| 149 | + nickname: this.nickname, |
| 150 | + emails, |
| 151 | + linked_in_handle: this.linkedInHandle, |
| 152 | + title: this.title, |
| 153 | + company: this.company, |
| 154 | + location: this.location, |
| 155 | + school: this.school, |
| 156 | + educational_info: this.educationalInfo, |
| 157 | + work_info: this.workInfo, |
| 158 | + profile_urls: this.profileUrls, |
| 159 | + phone_number: this.phoneNumber, |
| 160 | + project_ids: this.projectIds, |
| 161 | + custom_fields: this.customFields, |
| 162 | + sourced_from: this.sourcedFrom, |
| 163 | + autofill: this.autofill, |
| 164 | + }, |
60 | 165 | }); |
61 | 166 | $.export( |
62 | | - "$summary", |
63 | | - `Created candidate ${candidate.first_name} ${candidate.last_name} with ID: ${candidate.id}`, |
| 167 | + "$summary", `Created candidate ${candidate.first_name} ${candidate.last_name} with ID: ${candidate.id}`, |
64 | 168 | ); |
65 | 169 | return candidate; |
66 | 170 | }, |
|
0 commit comments