Skip to content

Commit b48e02b

Browse files
author
Lungu Dumitru
committed
Added running timers
1 parent 9299a1a commit b48e02b

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

sections/entries.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* [Creating a time entry](#create)
66
* [Updating a time entry](#update)
77
* [Deleting a time entry](#delete)
8+
* [Timer](#timer)
89
* [The time entry object](#object)
910
* [Dependent objects](#dependencies)
1011

@@ -172,6 +173,56 @@ To delete a time entry, make a DELETE request to:
172173

173174
If successful, the response will have a `200 OK` status code.
174175

176+
<a name="timer"></a>
177+
## Timer
178+
179+
A timer is a special kind of a time entry with the `end_time` not yet set.
180+
181+
Any user can have at most only one timer started at any time.
182+
183+
### Starting a timer
184+
185+
Starting the timer for a user is the same as creating a time entry for that user with `start_time` and no `end_time`.
186+
187+
For example, make a POST request to:
188+
189+
* `/api/entries` with the body:
190+
191+
```json
192+
{
193+
"task_id": 241184,
194+
"user_id": 1563,
195+
"description": "Running timer description",
196+
"start_time": "2017-06-20T09:30:00Z"
197+
}
198+
```
199+
200+
If another timer is already running for that user, the request will fail with a 409 error code.
201+
202+
### Stopping a timer
203+
204+
Stopping the timer is the same as updating the timer's `end_time` with a valid date and time value.
205+
206+
For example, make a PUT request to:
207+
208+
* `/api/entries/[TIMER_ID]` with the body:
209+
210+
```json
211+
{
212+
"end_time": "2017-06-20T15:00:00Z",
213+
"description": "Final time entry description"
214+
}
215+
```
216+
217+
Same restrictions as for time entries apply for timers. You cannot stop a timer if the final duration is less than a minute.
218+
To stop the timer in this case, make a DELETE request and delete the timer.
219+
220+
### Listing running timers
221+
222+
To get the running timer of any particular user, make a GET request to:
223+
224+
* `/api/entries?where=user_id=[USER_ID] and end_time=null`
225+
175226
<a name="object"></a>
176227
## The time entry object
177228

0 commit comments

Comments
 (0)