Skip to content

Commit 1a6b1ac

Browse files
committed
[Components] procore - new components - untested
1 parent 74caf69 commit 1a6b1ac

File tree

31 files changed

+1713
-738
lines changed

31 files changed

+1713
-738
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import app from "../../procore.app.mjs";
2+
3+
export default {
4+
key: "procore-create-incident",
5+
name: "Create Incident",
6+
description: "Create a new incident. [See the documentation](https://developers.procore.com/reference/rest/incidents?version=latest#create-incident).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
companyId: {
12+
propDefinition: [
13+
app,
14+
"companyId",
15+
],
16+
},
17+
projectId: {
18+
propDefinition: [
19+
app,
20+
"projectId",
21+
({ companyId }) => ({
22+
companyId,
23+
}),
24+
],
25+
},
26+
title: {
27+
type: "string",
28+
label: "Title",
29+
description: "Incident Title",
30+
},
31+
description: {
32+
type: "string",
33+
label: "Description",
34+
description: "Description of the Incident",
35+
optional: true,
36+
},
37+
eventDate: {
38+
type: "string",
39+
label: "Event Date",
40+
description: "Iso8601 datetime of Incident occurrence. If time is unknown, send in the date at `0:00` project time converted to UTC.",
41+
optional: true,
42+
},
43+
isPrivate: {
44+
type: "boolean",
45+
label: "Private",
46+
description: "Indicates whether an Incident is private",
47+
optional: true,
48+
},
49+
recordable: {
50+
type: "boolean",
51+
label: "Recordable",
52+
description: "Indicates whether an Incident is recordable",
53+
optional: true,
54+
},
55+
timeUnknown: {
56+
type: "boolean",
57+
label: "Time Unknown",
58+
description: "Indicates that the time of the Incident occurrence is unknown",
59+
optional: true,
60+
},
61+
},
62+
methods: {
63+
createIncident({
64+
projectId, ...args
65+
} = {}) {
66+
return this.app.post({
67+
path: `/projects/${projectId}/incidents`,
68+
...args,
69+
});
70+
},
71+
},
72+
async run({ $ }) {
73+
const {
74+
createIncident,
75+
companyId,
76+
projectId,
77+
title,
78+
description,
79+
eventDate,
80+
isPrivate,
81+
recordable,
82+
timeUnknown,
83+
} = this;
84+
85+
const response = await createIncident({
86+
$,
87+
companyId,
88+
projectId,
89+
data: {
90+
incident: {
91+
title,
92+
description,
93+
event_date: eventDate,
94+
private: isPrivate,
95+
recordable,
96+
time_unknown: timeUnknown,
97+
},
98+
},
99+
});
100+
$.export("$summary", `Succesfully created incident with ID \`${response.id}\`.`);
101+
return response;
102+
},
103+
};
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import app from "../../procore.app.mjs";
2+
3+
export default {
4+
key: "procore-create-manpower-log",
5+
name: "Create Manpower Log",
6+
description: "Create a new manpower log. [See the documentation](https://developers.procore.com/reference/rest/manpower-logs?version=latest#create-manpower-log).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
companyId: {
12+
propDefinition: [
13+
app,
14+
"companyId",
15+
],
16+
},
17+
projectId: {
18+
propDefinition: [
19+
app,
20+
"projectId",
21+
({ companyId }) => ({
22+
companyId,
23+
}),
24+
],
25+
},
26+
datetime: {
27+
type: "string",
28+
label: "Datetime",
29+
description: "The datetime of the record",
30+
optional: true,
31+
},
32+
notes: {
33+
type: "string",
34+
label: "Notes",
35+
description: "The notes for the record",
36+
optional: true,
37+
},
38+
numWorkers: {
39+
type: "integer",
40+
label: "Number Of Workers",
41+
description: "The number of workers",
42+
optional: true,
43+
},
44+
numHours: {
45+
type: "string",
46+
label: "Number Of Hours",
47+
description: "The number of hours for each worker",
48+
optional: true,
49+
},
50+
userId: {
51+
propDefinition: [
52+
app,
53+
"userId",
54+
({ companyId }) => ({
55+
companyId,
56+
}),
57+
],
58+
},
59+
locationId: {
60+
propDefinition: [
61+
app,
62+
"locationId",
63+
({
64+
companyId, projectId,
65+
}) => ({
66+
companyId,
67+
projectId,
68+
}),
69+
],
70+
},
71+
},
72+
methods: {
73+
createManpowerLog({
74+
projectId, ...args
75+
} = {}) {
76+
return this.app.post({
77+
path: `/projects/${projectId}/manpower_logs`,
78+
...args,
79+
});
80+
},
81+
},
82+
async run({ $ }) {
83+
const {
84+
createManpowerLog,
85+
companyId,
86+
projectId,
87+
datetime,
88+
notes,
89+
numWorkers,
90+
numHours,
91+
userId,
92+
locationId,
93+
} = this;
94+
95+
const response = await createManpowerLog({
96+
$,
97+
companyId,
98+
projectId,
99+
data: {
100+
manpower_log: {
101+
datetime,
102+
notes,
103+
num_workers: numWorkers,
104+
num_hours: numHours,
105+
user_id: userId,
106+
location_id: locationId,
107+
},
108+
},
109+
});
110+
$.export("$summary", `Succesfully created manpower log with ID \`${response.id}\`.`);
111+
return response;
112+
},
113+
};
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import app from "../../procore.app.mjs";
2+
3+
export default {
4+
key: "procore-create-rfi",
5+
name: "Create RFI",
6+
description: "Create a new RFI. [See the documentation](https://developers.procore.com/reference/rest/rfis?version=latest#create-rfi).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
companyId: {
12+
propDefinition: [
13+
app,
14+
"companyId",
15+
],
16+
},
17+
projectId: {
18+
propDefinition: [
19+
app,
20+
"projectId",
21+
({ companyId }) => ({
22+
companyId,
23+
}),
24+
],
25+
},
26+
subject: {
27+
type: "string",
28+
label: "Subject",
29+
description: "The Subject of the RFI",
30+
},
31+
questionBody: {
32+
type: "string",
33+
label: "Question Body",
34+
description: "The Body of the Question",
35+
},
36+
rfiManagerId: {
37+
propDefinition: [
38+
app,
39+
"rfiPotentialManagerId",
40+
({
41+
companyId, projectId,
42+
}) => ({
43+
companyId,
44+
projectId,
45+
}),
46+
],
47+
},
48+
reference: {
49+
type: "string",
50+
label: "Reference",
51+
description: "The Reference of the RFI",
52+
optional: true,
53+
},
54+
isPrivate: {
55+
type: "boolean",
56+
label: "Private",
57+
description: "The Private status of the RFI",
58+
optional: true,
59+
},
60+
locationId: {
61+
propDefinition: [
62+
app,
63+
"locationId",
64+
({
65+
companyId, projectId,
66+
}) => ({
67+
companyId,
68+
projectId,
69+
}),
70+
],
71+
},
72+
},
73+
methods: {
74+
createRfi({
75+
projectId, ...args
76+
} = {}) {
77+
return this.app.post({
78+
path: `/projects/${projectId}/rfis`,
79+
...args,
80+
});
81+
},
82+
},
83+
async run({ $ }) {
84+
const {
85+
createRfi,
86+
companyId,
87+
projectId,
88+
subject,
89+
questionBody,
90+
rfiManagerId,
91+
reference,
92+
isPrivate,
93+
locationId,
94+
} = this;
95+
96+
const response = await createRfi({
97+
$,
98+
companyId,
99+
projectId,
100+
data: {
101+
rfi: {
102+
subject,
103+
question: {
104+
body: questionBody,
105+
},
106+
rfi_manager_id: rfiManagerId,
107+
reference,
108+
private: isPrivate,
109+
location_id: locationId,
110+
},
111+
},
112+
});
113+
$.export("$summary", `Succesfully created RFI with ID \`${response.id}\`.`);
114+
return response;
115+
},
116+
};

0 commit comments

Comments
 (0)