File tree Expand file tree Collapse file tree 12 files changed +946
-6
lines changed Expand file tree Collapse file tree 12 files changed +946
-6
lines changed Original file line number Diff line number Diff line change 1+ import { ConfigurationError } from "@pipedream/platform" ;
2+ import { parseError } from "../../common/utils.mjs" ;
3+ import kiwihr from "../../kiwihr.app.mjs" ;
4+
5+ export default {
6+ key : "kiwihr-create-employee" ,
7+ name : "Create Employee" ,
8+ description : "Add a new employee to kiwiHR. [See the documentation](https://api.kiwihr.com/api/docs/mutation.doc.html)" ,
9+ version : "0.0.1" ,
10+ type : "action" ,
11+ props : {
12+ kiwihr,
13+ firstName : {
14+ propDefinition : [
15+ kiwihr ,
16+ "firstName" ,
17+ ] ,
18+ } ,
19+ lastName : {
20+ propDefinition : [
21+ kiwihr ,
22+ "lastName" ,
23+ ] ,
24+ } ,
25+ email : {
26+ propDefinition : [
27+ kiwihr ,
28+ "email" ,
29+ ] ,
30+ } ,
31+ workPhones : {
32+ propDefinition : [
33+ kiwihr ,
34+ "workPhones" ,
35+ ] ,
36+ optional : true ,
37+ } ,
38+ employmentStartDate : {
39+ propDefinition : [
40+ kiwihr ,
41+ "employmentStartDate" ,
42+ ] ,
43+ optional : true ,
44+ } ,
45+ aboutMe : {
46+ propDefinition : [
47+ kiwihr ,
48+ "aboutMe" ,
49+ ] ,
50+ optional : true ,
51+ } ,
52+ gender : {
53+ propDefinition : [
54+ kiwihr ,
55+ "gender" ,
56+ ] ,
57+ optional : true ,
58+ } ,
59+ managerId : {
60+ propDefinition : [
61+ kiwihr ,
62+ "managerId" ,
63+ ] ,
64+ optional : true ,
65+ } ,
66+ nationality : {
67+ propDefinition : [
68+ kiwihr ,
69+ "nationality" ,
70+ ] ,
71+ optional : true ,
72+ } ,
73+ teamIds : {
74+ propDefinition : [
75+ kiwihr ,
76+ "teamIds" ,
77+ ] ,
78+ optional : true ,
79+ } ,
80+ positionId : {
81+ propDefinition : [
82+ kiwihr ,
83+ "positionId" ,
84+ ] ,
85+ optional : true ,
86+ } ,
87+ locationId : {
88+ propDefinition : [
89+ kiwihr ,
90+ "locationId" ,
91+ ] ,
92+ optional : true ,
93+ } ,
94+ birthDate : {
95+ propDefinition : [
96+ kiwihr ,
97+ "birthDate" ,
98+ ] ,
99+ optional : true ,
100+ } ,
101+ personalPhone : {
102+ propDefinition : [
103+ kiwihr ,
104+ "personalPhone" ,
105+ ] ,
106+ optional : true ,
107+ } ,
108+ personalEmail : {
109+ propDefinition : [
110+ kiwihr ,
111+ "personalEmail" ,
112+ ] ,
113+ optional : true ,
114+ } ,
115+ addressStreet : {
116+ propDefinition : [
117+ kiwihr ,
118+ "addressStreet" ,
119+ ] ,
120+ optional : true ,
121+ } ,
122+ addressCity : {
123+ propDefinition : [
124+ kiwihr ,
125+ "addressCity" ,
126+ ] ,
127+ optional : true ,
128+ } ,
129+ addressState : {
130+ propDefinition : [
131+ kiwihr ,
132+ "addressState" ,
133+ ] ,
134+ optional : true ,
135+ } ,
136+ addressPostalCode : {
137+ propDefinition : [
138+ kiwihr ,
139+ "addressPostalCode" ,
140+ ] ,
141+ optional : true ,
142+ } ,
143+ addressCountry : {
144+ propDefinition : [
145+ kiwihr ,
146+ "addressCountry" ,
147+ ] ,
148+ optional : true ,
149+ } ,
150+ pronouns : {
151+ propDefinition : [
152+ kiwihr ,
153+ "pronouns" ,
154+ ] ,
155+ optional : true ,
156+ } ,
157+ } ,
158+ async run ( { $ } ) {
159+ try {
160+ const {
161+ kiwihr,
162+ addressStreet,
163+ addressCity,
164+ addressState,
165+ addressPostalCode,
166+ addressCountry,
167+ ...user
168+ } = this ;
169+
170+ const address = { } ;
171+ if ( addressStreet ) address . street = addressStreet ;
172+ if ( addressCity ) address . city = addressCity ;
173+ if ( addressState ) address . state = addressState ;
174+ if ( addressPostalCode ) address . postalCode = addressPostalCode ;
175+ if ( addressCountry ) address . country = addressCountry ;
176+
177+ if ( Object . keys ( address ) . length > 0 ) {
178+ user . address = address ;
179+ }
180+
181+ const response = await kiwihr . createEmployee ( {
182+ user,
183+ } ) ;
184+
185+ $ . export ( "$summary" , `Successfully created employee ${ this . firstName } ${ this . lastName } ` ) ;
186+ return response ;
187+ } catch ( { response } ) {
188+ const error = parseError ( response ) ;
189+ throw new ConfigurationError ( error ) ;
190+ }
191+ } ,
192+ } ;
Original file line number Diff line number Diff line change 1+ import { ConfigurationError } from "@pipedream/platform" ;
2+ import { parseError } from "../../common/utils.mjs" ;
3+ import kiwihr from "../../kiwihr.app.mjs" ;
4+
5+ export default {
6+ key : "kiwihr-update-employee-record" ,
7+ name : "Update Employee Record" ,
8+ description : "Update an existing employee's record in kiwiHR. [See the documentation](https://api.kiwihr.it/api/docs/mutation.doc.html)" ,
9+ version : "0.0.1" ,
10+ type : "action" ,
11+ props : {
12+ kiwihr,
13+ employeeId : {
14+ propDefinition : [
15+ kiwihr ,
16+ "employeeId" ,
17+ ] ,
18+ } ,
19+ firstName : {
20+ propDefinition : [
21+ kiwihr ,
22+ "firstName" ,
23+ ] ,
24+ optional : true ,
25+ } ,
26+ lastName : {
27+ propDefinition : [
28+ kiwihr ,
29+ "lastName" ,
30+ ] ,
31+ optional : true ,
32+ } ,
33+ workPhones : {
34+ propDefinition : [
35+ kiwihr ,
36+ "workPhones" ,
37+ ] ,
38+ optional : true ,
39+ } ,
40+ employmentStartDate : {
41+ propDefinition : [
42+ kiwihr ,
43+ "employmentStartDate" ,
44+ ] ,
45+ optional : true ,
46+ } ,
47+ aboutMe : {
48+ propDefinition : [
49+ kiwihr ,
50+ "aboutMe" ,
51+ ] ,
52+ optional : true ,
53+ } ,
54+ gender : {
55+ propDefinition : [
56+ kiwihr ,
57+ "gender" ,
58+ ] ,
59+ optional : true ,
60+ } ,
61+ managerId : {
62+ propDefinition : [
63+ kiwihr ,
64+ "managerId" ,
65+ ] ,
66+ optional : true ,
67+ } ,
68+ nationality : {
69+ propDefinition : [
70+ kiwihr ,
71+ "nationality" ,
72+ ] ,
73+ optional : true ,
74+ } ,
75+ teamIds : {
76+ propDefinition : [
77+ kiwihr ,
78+ "teamIds" ,
79+ ] ,
80+ optional : true ,
81+ } ,
82+ positionId : {
83+ propDefinition : [
84+ kiwihr ,
85+ "positionId" ,
86+ ] ,
87+ optional : true ,
88+ } ,
89+ locationId : {
90+ propDefinition : [
91+ kiwihr ,
92+ "locationId" ,
93+ ] ,
94+ optional : true ,
95+ } ,
96+ birthDate : {
97+ propDefinition : [
98+ kiwihr ,
99+ "birthDate" ,
100+ ] ,
101+ optional : true ,
102+ } ,
103+ personalPhone : {
104+ propDefinition : [
105+ kiwihr ,
106+ "personalPhone" ,
107+ ] ,
108+ optional : true ,
109+ } ,
110+ personalEmail : {
111+ propDefinition : [
112+ kiwihr ,
113+ "personalEmail" ,
114+ ] ,
115+ optional : true ,
116+ } ,
117+ addressStreet : {
118+ propDefinition : [
119+ kiwihr ,
120+ "addressStreet" ,
121+ ] ,
122+ optional : true ,
123+ } ,
124+ addressCity : {
125+ propDefinition : [
126+ kiwihr ,
127+ "addressCity" ,
128+ ] ,
129+ optional : true ,
130+ } ,
131+ addressState : {
132+ propDefinition : [
133+ kiwihr ,
134+ "addressState" ,
135+ ] ,
136+ optional : true ,
137+ } ,
138+ addressPostalCode : {
139+ propDefinition : [
140+ kiwihr ,
141+ "addressPostalCode" ,
142+ ] ,
143+ optional : true ,
144+ } ,
145+ addressCountry : {
146+ propDefinition : [
147+ kiwihr ,
148+ "addressCountry" ,
149+ ] ,
150+ optional : true ,
151+ } ,
152+ pronouns : {
153+ propDefinition : [
154+ kiwihr ,
155+ "pronouns" ,
156+ ] ,
157+ optional : true ,
158+ } ,
159+ } ,
160+ async run ( { $ } ) {
161+ try {
162+ const {
163+ kiwihr,
164+ employeeId,
165+ addressStreet,
166+ addressCity,
167+ addressState,
168+ addressPostalCode,
169+ addressCountry,
170+ ...user
171+ } = this ;
172+
173+ const address = { } ;
174+ if ( addressStreet ) address . street = addressStreet ;
175+ if ( addressCity ) address . city = addressCity ;
176+ if ( addressState ) address . state = addressState ;
177+ if ( addressPostalCode ) address . postalCode = addressPostalCode ;
178+ if ( addressCountry ) address . country = addressCountry ;
179+
180+ if ( Object . keys ( address ) . length > 0 ) {
181+ user . address = address ;
182+ }
183+
184+ const response = await kiwihr . updateEmployee ( {
185+ id : employeeId ,
186+ user,
187+ } ) ;
188+
189+ $ . export ( "$summary" , `Successfully updated employee record for ID: ${ this . employeeId } ` ) ;
190+ return response ;
191+ } catch ( { response } ) {
192+ const error = parseError ( response ) ;
193+ throw new ConfigurationError ( error ) ;
194+ }
195+ } ,
196+ } ;
Original file line number Diff line number Diff line change 1+ export const LIMIT = 100 ;
2+
3+ export const GENDER_OPTIONS = [
4+ "MALE" ,
5+ "FEMALE" ,
6+ "DIVERSE" ,
7+ ] ;
You can’t perform that action at this time.
0 commit comments