Skip to content

Commit 362bfea

Browse files
committed
init
1 parent cb21348 commit 362bfea

File tree

12 files changed

+311
-147
lines changed

12 files changed

+311
-147
lines changed

components/everhour/actions/create-task/create-task.mjs

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { STATUS_OPTIONS } from "../../common/constants.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
13
import everhour from "../../everhour.app.mjs";
2-
import { axios } from "@pipedream/platform";
34

45
export default {
56
key: "everhour-create-task",
@@ -18,19 +19,22 @@ export default {
1819
name: {
1920
type: "string",
2021
label: "Task Name",
21-
description: "The name of the task to be created",
22-
optional: true,
22+
description: "The name of the task to be created.",
2323
},
24-
section: {
25-
type: "string",
26-
label: "Section",
27-
description: "The section of the task",
28-
optional: true,
24+
sectionId: {
25+
propDefinition: [
26+
everhour,
27+
"sectionId",
28+
({ projectId }) => ({
29+
projectId,
30+
}),
31+
],
2932
},
30-
labels: {
31-
type: "string[]",
32-
label: "Labels",
33-
description: "An array of labels associated with the task",
33+
tags: {
34+
propDefinition: [
35+
everhour,
36+
"tags",
37+
],
3438
optional: true,
3539
},
3640
position: {
@@ -45,29 +49,33 @@ export default {
4549
description: "A description of the task",
4650
optional: true,
4751
},
48-
dueon: {
52+
dueOn: {
4953
type: "string",
5054
label: "Due Date",
51-
description: "The due date of the task (ISO 8601 format)",
55+
description: "The due date of the task. **Format: YYYY-MM-DD**",
5256
optional: true,
5357
},
5458
status: {
5559
type: "string",
5660
label: "Status",
5761
description: "The status of the task",
62+
options: STATUS_OPTIONS,
5863
optional: true,
5964
},
6065
},
6166
async run({ $ }) {
6267
const response = await this.everhour.createTask({
68+
$,
6369
projectId: this.projectId,
64-
name: this.name,
65-
section: this.section,
66-
labels: this.labels,
67-
position: this.position,
68-
description: this.description,
69-
dueon: this.dueon,
70-
status: this.status,
70+
data: {
71+
name: this.name,
72+
section: this.sectionId,
73+
tags: this.tags && parseObject(this.tags),
74+
position: this.position,
75+
description: this.description,
76+
dueOn: this.dueOn,
77+
status: this.status,
78+
},
7179
});
7280

7381
$.export("$summary", `Successfully created task with ID: ${response.id}`);

components/everhour/actions/start-timer/start-timer.mjs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import everhour from "../../everhour.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "everhour-start-timer",
@@ -9,19 +8,25 @@ export default {
98
type: "action",
109
props: {
1110
everhour,
11+
projectId: {
12+
propDefinition: [
13+
everhour,
14+
"projectId",
15+
],
16+
},
1217
taskId: {
1318
propDefinition: [
1419
everhour,
1520
"taskId",
16-
(c) => ({
17-
projectId: c.projectId,
21+
({ projectId }) => ({
22+
projectId,
1823
}),
1924
],
2025
},
21-
userdate: {
26+
userDate: {
2227
type: "string",
2328
label: "User Date",
24-
description: "Date string to associate with the timer. Format as 'YYYY-MM-DD'. Optional",
29+
description: "Date string to associate with the timer. Format as 'YYYY-MM-DD'",
2530
optional: true,
2631
},
2732
comment: {
@@ -33,9 +38,12 @@ export default {
3338
},
3439
async run({ $ }) {
3540
const response = await this.everhour.startTimer({
36-
taskId: this.taskId,
37-
userdate: this.userdate,
38-
comment: this.comment,
41+
$,
42+
data: {
43+
task: this.taskId,
44+
userDate: this.userDate,
45+
comment: this.comment,
46+
},
3947
});
4048

4149
$.export("$summary", `Successfully started a timer for task ID: ${this.taskId}`);

components/everhour/actions/stop-timer/stop-timer.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "everhour-stop-timer",
55
name: "Stop Timer",
66
description: "Halts the current running timer. [See the documentation](https://everhour.docs.apiary.io/#reference/timers/stop-timer)",
7-
version: "0.0.{{ts}}",
7+
version: "0.0.1",
88
type: "action",
99
props: {
1010
everhour,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export const LIMIT = 100;
2+
3+
export const STATUS_OPTIONS = [
4+
{
5+
label: "Open",
6+
value: "open",
7+
},
8+
{
9+
label: "Close",
10+
value: "close",
11+
},
12+
];
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const parseObject = (obj) => {
2+
if (!obj) return undefined;
3+
4+
if (Array.isArray(obj)) {
5+
return obj.map((item) => {
6+
if (typeof item === "string") {
7+
try {
8+
return JSON.parse(item);
9+
} catch (e) {
10+
return item;
11+
}
12+
}
13+
return item;
14+
});
15+
}
16+
if (typeof obj === "string") {
17+
try {
18+
return JSON.parse(obj);
19+
} catch (e) {
20+
return obj;
21+
}
22+
}
23+
return obj;
24+
};

0 commit comments

Comments
 (0)