|
5 | 5 | * [Creating a time entry](#create) |
6 | 6 | * [Updating a time entry](#update) |
7 | 7 | * [Deleting a time entry](#delete) |
| 8 | +* [Timer](#timer) |
8 | 9 | * [The time entry object](#object) |
9 | 10 | * [Dependent objects](#dependencies) |
10 | 11 |
|
@@ -172,6 +173,56 @@ To delete a time entry, make a DELETE request to: |
172 | 173 |
|
173 | 174 | If successful, the response will have a `200 OK` status code. |
174 | 175 |
|
| 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 | + |
175 | 226 | <a name="object"></a> |
176 | 227 | ## The time entry object |
177 | 228 |
|
|
0 commit comments