@pipedream/trackingtime 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import app from "../../trackingtime.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
name: "Start Tracking Time",
|
|
5
|
+
version: "0.0.1",
|
|
6
|
+
key: "trackingtime-start-tracking-time",
|
|
7
|
+
description: "Start tracking time of a task. [See the documentation](https://api.trackingtime.co/doc/time_tracking.html#sync:~:text=Sync%20tracking%20event-,Start%20Tracking%20Time,-Starts%20a%20timer)",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
app,
|
|
11
|
+
taskId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
app,
|
|
14
|
+
"taskId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
projectId: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
app,
|
|
20
|
+
"projectId",
|
|
21
|
+
],
|
|
22
|
+
optional: true,
|
|
23
|
+
},
|
|
24
|
+
date: {
|
|
25
|
+
label: "Date",
|
|
26
|
+
description: "The event's start date. Format ISO 8601: `yyyy-MM-dd HH:mm:ss` like `2014-01-31 17:30:59`",
|
|
27
|
+
type: "string",
|
|
28
|
+
optional: true,
|
|
29
|
+
},
|
|
30
|
+
estimatedTime: {
|
|
31
|
+
label: "Estimated Time",
|
|
32
|
+
description: "Set a new estimated time for this task",
|
|
33
|
+
type: "string",
|
|
34
|
+
optional: true,
|
|
35
|
+
},
|
|
36
|
+
stopRunningTask: {
|
|
37
|
+
label: "Stop Running Task",
|
|
38
|
+
description: "If set to true, any currently running task will be stopped before the new one is started.",
|
|
39
|
+
type: "boolean",
|
|
40
|
+
optional: true,
|
|
41
|
+
},
|
|
42
|
+
returnTask: {
|
|
43
|
+
label: "Return Task",
|
|
44
|
+
description: "If set to true, a task object is returned",
|
|
45
|
+
type: "boolean",
|
|
46
|
+
optional: true,
|
|
47
|
+
},
|
|
48
|
+
tags: {
|
|
49
|
+
label: "Tags",
|
|
50
|
+
description: "An array of tags to be added to the newly created time entry. E.g. `[{\"n\":\"name\",\"c\":\"color\",\"v\":\"value\",\"t\":\"type\"}]`",
|
|
51
|
+
type: "boolean",
|
|
52
|
+
optional: true,
|
|
53
|
+
},
|
|
54
|
+
timezone: {
|
|
55
|
+
label: "Timezone",
|
|
56
|
+
description: "The user's timezone as `GMT+3` or `GMT+03:00`",
|
|
57
|
+
type: "string",
|
|
58
|
+
optional: true,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
async run({ $ }) {
|
|
62
|
+
const tags = typeof this.tags === "string"
|
|
63
|
+
? JSON.parse(this.tags)
|
|
64
|
+
: this.tags;
|
|
65
|
+
|
|
66
|
+
const response = await this.app.startTrackingTime({
|
|
67
|
+
$,
|
|
68
|
+
taskId: this.taskId,
|
|
69
|
+
params: {
|
|
70
|
+
date: this.date,
|
|
71
|
+
projectId: this.projectId,
|
|
72
|
+
return_task: this.returnTask,
|
|
73
|
+
stop_running_task: this.stopRunningTask,
|
|
74
|
+
estimated_time: this.estimatedTime,
|
|
75
|
+
timezone: this.timezone,
|
|
76
|
+
tags,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (response) {
|
|
81
|
+
$.export("$summary", `Successfully started tracking time of the task ID ${this.taskId}`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return response;
|
|
85
|
+
},
|
|
86
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import app from "../../trackingtime.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
name: "Stop Tracking Time",
|
|
5
|
+
version: "0.0.1",
|
|
6
|
+
key: "trackingtime-stop-tracking-time",
|
|
7
|
+
description: "Stop tracking time of a task. [See the documentation](https://api.trackingtime.co/doc/time_tracking.html#sync:~:text=Sync%20tracking%20event-,Start%20Tracking%20Time,-Starts%20a%20timer)",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
app,
|
|
11
|
+
taskId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
app,
|
|
14
|
+
"taskId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
async run({ $ }) {
|
|
19
|
+
const response = await this.app.stopTrackingTime({
|
|
20
|
+
$,
|
|
21
|
+
taskId: this.taskId,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if (response) {
|
|
25
|
+
$.export("$summary", `Successfully stopped tracking time of the task ID ${this.taskId}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return response;
|
|
29
|
+
},
|
|
30
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/trackingtime",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Pipedream TrackingTime Components",
|
|
5
5
|
"main": "trackingtime.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -11,5 +11,8 @@
|
|
|
11
11
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@pipedream/platform": "^1.5.1"
|
|
14
17
|
}
|
|
15
18
|
}
|
package/trackingtime.app.mjs
CHANGED
|
@@ -1,11 +1,83 @@
|
|
|
1
|
+
import { axios } from "@pipedream/platform";
|
|
2
|
+
|
|
1
3
|
export default {
|
|
2
4
|
type: "app",
|
|
3
5
|
app: "trackingtime",
|
|
4
|
-
propDefinitions: {
|
|
6
|
+
propDefinitions: {
|
|
7
|
+
taskId: {
|
|
8
|
+
label: "Task ID",
|
|
9
|
+
description: "The task ID",
|
|
10
|
+
type: "string",
|
|
11
|
+
async options() {
|
|
12
|
+
const { data: tasks } = await this.getTasks();
|
|
13
|
+
|
|
14
|
+
return tasks.map((task) => ({
|
|
15
|
+
label: task.name,
|
|
16
|
+
value: task.id,
|
|
17
|
+
}));
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
projectId: {
|
|
21
|
+
label: "Project ID",
|
|
22
|
+
description: "The project ID",
|
|
23
|
+
type: "string",
|
|
24
|
+
async options() {
|
|
25
|
+
const { data: projects } = await this.getProjects();
|
|
26
|
+
|
|
27
|
+
return projects.map((task) => ({
|
|
28
|
+
label: task.name,
|
|
29
|
+
value: task.id,
|
|
30
|
+
}));
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
5
34
|
methods: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
35
|
+
_appPassword() {
|
|
36
|
+
return this.$auth.app_password;
|
|
37
|
+
},
|
|
38
|
+
_apiUrl() {
|
|
39
|
+
return "https://app.trackingtime.co/api/v4";
|
|
40
|
+
},
|
|
41
|
+
_makeRequest({
|
|
42
|
+
$ = this, path, ...args
|
|
43
|
+
}) {
|
|
44
|
+
return axios($, {
|
|
45
|
+
url: `${this._apiUrl()}${path}`,
|
|
46
|
+
...args,
|
|
47
|
+
auth: {
|
|
48
|
+
username: "API_TOKEN",
|
|
49
|
+
password: this._appPassword(),
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
startTrackingTime({
|
|
54
|
+
taskId, args,
|
|
55
|
+
}) {
|
|
56
|
+
return this._makeRequest({
|
|
57
|
+
path: `/tasks/track/${taskId}`,
|
|
58
|
+
...args,
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
stopTrackingTime({
|
|
62
|
+
taskId, args,
|
|
63
|
+
}) {
|
|
64
|
+
return this._makeRequest({
|
|
65
|
+
path: `/tasks/stop/${taskId}`,
|
|
66
|
+
method: "post",
|
|
67
|
+
...args,
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
getTasks(args = {}) {
|
|
71
|
+
return this._makeRequest({
|
|
72
|
+
path: "/tasks",
|
|
73
|
+
...args,
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
getProjects(args = {}) {
|
|
77
|
+
return this._makeRequest({
|
|
78
|
+
path: "/projects",
|
|
79
|
+
...args,
|
|
80
|
+
});
|
|
9
81
|
},
|
|
10
82
|
},
|
|
11
|
-
};
|
|
83
|
+
};
|