-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathclockify
85 lines (70 loc) · 1.54 KB
/
clockify
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env perl
use feature qw(signatures);
no warnings qw(experimental::signatures);
use Modern::Perl;
use Mojo::UserAgent;
use Mojo::URL;
use Data::Dumper;
my $api_url = Mojo::URL->new('https://api.clockify.me/api');
my $cmd_map = {
start => \&_start,
stop => \&_stop,
};
my $cmd = shift @ARGV;
die "Unknown subcommand $cmd" unless exists $cmd_map->{$cmd};
$cmd_map->{$cmd}->(@ARGV);
sub _start($args) {
my ($project, $task) = split(/\@/, $args);
say "PROJECT: $project";
say "TASK: $task" if $task;
# get all tasks for a project
#
# GET /workspaces/{workspaceId}/projects/{projectId}/tasks/
#
# add new task
#
# POST /workspaces/{workspaceId}/projects/{projectId}/tasks/
#
# PAYLOAD:
#
# {
# "id": "string",
# "name": "string",
# "projectId": "string",
# "assigneeId": "string",
# "estimate": "string",
# "status": "string"
# }
# start timer
#
# POST /workspaces/{workspaceId}/timeEntries/
#
# PAYLOAD:
# {
# c:xa
# "start": "string",
# "billable": "boolean",
# "description": "string",
# "projectId": "string",
# "taskId": "string",
# "end": "string",
# "tagIds": [
# "string"
# ]
# }
# TODO
# - if given a task
# - find the task
# - create if the task does not exist
# -
}
sub _stop {
#
# PUT /workspaces/{workspaceId}/timeEntries/endStarted
#
# TODO
# - get workspace id
# - build url with id
# - make PUT request to end timer
# - if the response is 204 it succeeded otherwise it failed
}