Skip to content

Commit 509f341

Browse files
committed
[Components] everhour #13219
Sources - New Client (Instant) - New Task (Instant) - New Task Time Updated (Instant) Actions - Create Task - Start Timer - Stop Timer
1 parent 190f0b7 commit 509f341

File tree

6 files changed

+88
-92
lines changed

6 files changed

+88
-92
lines changed

components/everhour/everhour.app.mjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,11 @@ export default {
103103
_makeRequest({
104104
$ = this, path, ...opts
105105
}) {
106-
const config = {
106+
return axios($, {
107107
url: this._baseUrl() + path,
108108
headers: this._headers(),
109109
...opts,
110-
};
111-
console.log("config: ", config);
112-
return axios($, config);
110+
});
113111
},
114112
listProjects(opts = {}) {
115113
return this._makeRequest({

components/everhour/sources/common/base.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ export default {
4444
}) {
4545
console.log("headers: ", headers);
4646

47-
if (headers["X-Hook-Secret"]) {
47+
if (headers["x-hook-secret"]) {
4848
return this.http.respond({
4949
status: 200,
5050
headers: {
51-
"X-Hook-Secret": headers["X-Hook-Secret"],
51+
"X-Hook-Secret": headers["x-hook-secret"],
5252
},
5353
});
5454
}

components/everhour/sources/new-client-instant/new-client-instant.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "everhour-new-client-instant",
77
name: "New Client (Instant)",
88
description: "Emit new event when a client is added.",
9-
version: "0.0.{{ts}}",
9+
version: "0.0.1",
1010
type: "source",
1111
dedupe: "unique",
1212
methods: {
Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,24 @@
1-
import everhour from "../../everhour.app.mjs";
1+
import common from "../common/base.mjs";
2+
import sampleEmit from "./test-event.mjs";
23

34
export default {
5+
...common,
46
key: "everhour-new-task-instant",
5-
name: "New Task Created",
6-
description: "Emit new event when a task is created. [See the documentation](https://everhour.docs.apiary.io/)",
7-
version: "0.0.{{ts}}",
7+
name: "New Task Created (Instant)",
8+
description: "Emit new event when a task is created.",
9+
version: "0.0.1",
810
type: "source",
911
dedupe: "unique",
10-
props: {
11-
everhour,
12-
db: "$.service.db",
13-
projectId: {
14-
propDefinition: [
15-
everhour,
16-
"projectId",
17-
],
12+
methods: {
13+
...common.methods,
14+
getEventType() {
15+
return [
16+
"api:task:created",
17+
];
1818
},
19-
},
20-
hooks: {
21-
async deploy() {
22-
const tasks = await this.everhour.getProjectTasks(this.projectId);
23-
for (const task of tasks.slice(0, 50)) {
24-
this.$emit(task, {
25-
id: task.id,
26-
summary: `New task: ${task.name}`,
27-
ts: Date.parse(task.createdAt),
28-
});
29-
}
30-
},
31-
async activate() {
32-
await this.everhour.emitTaskCreatedEvent(this.projectId);
19+
getSummary(body) {
20+
return `New Task Created: ${body.payload.data.id}`;
3321
},
34-
async deactivate() {
35-
// Implement deactivation if an API endpoint exists
36-
},
37-
},
38-
async run() {
39-
const tasks = await this.everhour.getProjectTasks(this.projectId);
40-
for (const task of tasks) {
41-
this.$emit(task, {
42-
id: task.id,
43-
summary: `New task: ${task.name}`,
44-
ts: Date.parse(task.createdAt),
45-
});
46-
}
4722
},
23+
sampleEmit,
4824
};
Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,24 @@
1-
import everhour from "../../everhour.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import common from "../common/base.mjs";
2+
import sampleEmit from "./test-event.mjs";
33

44
export default {
5+
...common,
56
key: "everhour-task-time-updated-instant",
6-
name: "Task Time Updated",
7-
description: "Emit new event when a task's time spent is modified in Everhour. [See the documentation](https://everhour.docs.apiary.io/)",
8-
version: "0.0.{{ts}}",
7+
name: "New Task Time Updated (Instant)",
8+
description: "Emit new event when a task's time spent is modified in Everhour.",
9+
version: "0.0.1",
910
type: "source",
1011
dedupe: "unique",
11-
props: {
12-
everhour,
13-
db: "$.service.db",
14-
projectId: {
15-
propDefinition: [
16-
everhour,
17-
"projectId",
18-
],
12+
methods: {
13+
...common.methods,
14+
getEventType() {
15+
return [
16+
"api:time:updated",
17+
];
1918
},
20-
},
21-
hooks: {
22-
async deploy() {
23-
await this.everhour.emitTimeUpdatedEvent(this.projectId);
24-
},
25-
async activate() {
26-
await this.everhour.emitTimeUpdatedEvent(this.projectId);
27-
},
28-
async deactivate() {
29-
// Currently, Everhour API does not provide an endpoint to delete a webhook.
30-
// If such an API becomes available, you should implement it here.
19+
getSummary(body) {
20+
return `Task Time Updated: ${body.payload.data.id}`;
3121
},
3222
},
33-
async run() {
34-
const events = await axios(this, {
35-
method: "GET",
36-
url: `${this.everhour._baseUrl()}/projects/${this.projectId}/time-record-events`,
37-
headers: {
38-
"Authorization": `Bearer ${this.everhour.$auth.api_key}`,
39-
},
40-
});
41-
42-
for (const event of events) {
43-
this.$emit(event, {
44-
id: event.id.toString(),
45-
summary: `Task Time Updated: ${event.id}`,
46-
ts: new Date(event.spentAt).getTime(),
47-
});
48-
}
49-
},
23+
sampleEmit,
5024
};
Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,55 @@
11
export default {
2-
"project": "project_slug",
3-
"translated": 100,
4-
"resource": "resource_slug",
5-
"event": "translation_completed",
6-
"language": "lang_code"
2+
"event": "api:time:updated",
3+
"payload": {
4+
"id": "ev:188193235916608",
5+
"data": {
6+
"user": 1362384,
7+
"history": [
8+
{
9+
"id": 370578249,
10+
"time": 60,
11+
"previousTime": 0,
12+
"action": "TIMER",
13+
"source": "internal",
14+
"createdAt": "2024-10-18 13:58:23",
15+
"createdBy": 1362384
16+
}
17+
],
18+
"lockReasons": [],
19+
"cost": 42,
20+
"isLocked": false,
21+
"manualTime": 0,
22+
"id": 214588860,
23+
"date": "2024-10-18",
24+
"time": 60,
25+
"timerTime": 60,
26+
"pastDateTime": 0,
27+
"task": {
28+
"createdBy": 1362384,
29+
"position": 4,
30+
"projects": [
31+
"ev:188193235916605"
32+
],
33+
"section": 1163621,
34+
"comments": 0,
35+
"completed": false,
36+
"id": "ev:188193235916608",
37+
"type": "task",
38+
"name": "Project Management",
39+
"status": "open",
40+
"labels": [],
41+
"createdAt": "2024-10-15 19:25:59",
42+
"time": {
43+
"total": 60,
44+
"users": {
45+
"1362384": 60
46+
},
47+
"timerTime": 60
48+
}
49+
},
50+
"createdAt": "2024-10-18 13:58:23",
51+
"costRate": 2500
52+
}
53+
},
54+
"createdAt": "2024-10-18 13:59:20"
755
}

0 commit comments

Comments
 (0)