Skip to content

Commit 72e7bfa

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 509f341 commit 72e7bfa

File tree

6 files changed

+78
-20
lines changed

6 files changed

+78
-20
lines changed

components/everhour/sources/common/base.mjs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ export default {
88
customResponse: true,
99
},
1010
db: "$.service.db",
11-
projectId: {
12-
propDefinition: [
13-
everhour,
14-
"projectId",
15-
],
16-
},
1711
},
1812
methods: {
1913
_getHookId() {
@@ -22,14 +16,17 @@ export default {
2216
_setHookId(hookId) {
2317
this.db.set("hookId", hookId);
2418
},
19+
getExtraData() {
20+
return {};
21+
},
2522
},
2623
hooks: {
2724
async activate() {
2825
const response = await this.everhour.createWebhook({
2926
data: {
3027
targetUrl: this.http.endpoint,
3128
events: this.getEventType(),
32-
project: this.projectId,
29+
...this.getExtraData(),
3330
},
3431
});
3532
this._setHookId(response.id);
@@ -42,8 +39,6 @@ export default {
4239
async run({
4340
body, headers,
4441
}) {
45-
console.log("headers: ", headers);
46-
4742
if (headers["x-hook-secret"]) {
4843
return this.http.respond({
4944
status: 200,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default {
1717
];
1818
},
1919
getSummary(body) {
20-
return `New Client: ${body.name}`;
20+
return `New Client: ${body.payload.data.name}`;
2121
},
2222
},
2323
sampleEmit,
Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
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:client:created",
3+
"payload": {
4+
"id": "9381500",
5+
"data": {
6+
"projects": [],
7+
"id": 9381500,
8+
"name": "Client Name",
9+
"createdAt": "2024-10-22 14:25:29",
10+
"lineItemMask": "%MEMBER% :: %PROJECT% :: for %PERIOD%",
11+
"paymentDueDays": 0,
12+
"reference": "",
13+
"businessDetails": "",
14+
"email": [
15+
16+
],
17+
"invoicePublicNotes": "",
18+
"excludedLabels": [],
19+
"status": "active",
20+
"enableResourcePlanner": false,
21+
"favorite": false
22+
}
23+
},
24+
"createdAt": "2024-10-22 14:25:29"
725
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,22 @@ export default {
99
version: "0.0.1",
1010
type: "source",
1111
dedupe: "unique",
12+
props: {
13+
...common.props,
14+
projectId: {
15+
propDefinition: [
16+
common.props.everhour,
17+
"projectId",
18+
],
19+
},
20+
},
1221
methods: {
1322
...common.methods,
23+
getExtraData() {
24+
return {
25+
project: this.projectId,
26+
};
27+
},
1428
getEventType() {
1529
return [
1630
"api:task:created",
Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
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:task:created",
3+
"payload": {
4+
"id": "ev:188217209666811",
5+
"data": {
6+
"createdBy": 1362384,
7+
"iteration": "Section Name",
8+
"position": 5,
9+
"projects": [
10+
"ev:188193235916605"
11+
],
12+
"section": 1164091,
13+
"comments": 0,
14+
"completed": false,
15+
"id": "ev:188217209666811",
16+
"type": "task",
17+
"name": "Task name",
18+
"status": "open",
19+
"labels": [],
20+
"createdAt": "2024-10-18 14:01:36"
21+
}
22+
},
23+
"createdAt": "2024-10-18 14:01:36"
724
}

components/everhour/sources/task-time-updated-instant/task-time-updated-instant.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,22 @@ export default {
99
version: "0.0.1",
1010
type: "source",
1111
dedupe: "unique",
12+
props: {
13+
...common.props,
14+
projectId: {
15+
propDefinition: [
16+
common.props.everhour,
17+
"projectId",
18+
],
19+
},
20+
},
1221
methods: {
1322
...common.methods,
23+
getExtraData() {
24+
return {
25+
project: this.projectId,
26+
};
27+
},
1428
getEventType() {
1529
return [
1630
"api:time:updated",

0 commit comments

Comments
 (0)